views:

346

answers:

1

I want to use a custom media controller in my Android app and therefore looking at the vidtry code (http://github.com/commonsguy/vidtry), especially Player.java:

The sample works fine as it comes. But I want the sample to play the fixed video automatically on app startup (so I don't want to enter a URL). I added:

 @Override
 public void onResume() {
  super.onResume(); 
  address.setText("/sdcard/mydata/category/1/video_agkkr6me.mp4");
  go.setEnabled(true);
  onGo.onClick(go);  
 }

Strange thing here is that if I run the app, the audio of the video plays but the image doesn't show. Everything else works fine (progress bar, etc.). I can't figure out the difference between the manual click on the go-button and the programmatic one. I looked at the code and didn't see any difference that might occur between manual and programmatic click.

I checked if any elements (esp. surface) might be hidden, but it's not. I even tried a

surface.setVisibility(View.INVISIBLE);
surface.setVisibility(View.VISIBLE);

in case of some issue with the redrawing, but no difference.

The video image does show when I manually hit the go button, but just not on start up automatically.

+2  A: 

It seemed that the surface wasn't ready at onResume yet. Implementing SurfaceHolder.Callback and then starting the video from surfaceCreated(SurfaceHolder holder) solves the problem.

Mathias Lin
I've whitnessed the same behaviour myself.
plouh