Mediaplayer doesn't display the video,

All your problems with Audio, Video and Images.

Mediaplayer doesn't display the video,

Postby nioupy » Sat Nov 12, 2011 8:47 pm

Hi,

I'm encountering a weird behavior on a Dell Streak with Android 2.2.2

I'm using the following code to display a video:
Code: Select all
      svVideo.setVisibility(VISIBLE);
      getWindow().setFormat(PixelFormat.TRANSLUCENT);
      videoPath = path;
      holder = svVideo.getHolder();
      holder.addCallback(this);
      holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
      holder.setFixedSize(getWindow().getWindowManager().getDefaultDisplay().getWidth(), getWindow().getWindowManager().getDefaultDisplay().getHeight());
      mVideoPlayer = new MediaPlayer();
      mVideoPlayer.setDisplay(holder);


Code: Select all
   @Override
   public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
   }

   public void surfaceCreated(SurfaceHolder holder) {
      iniPlayer();
   }

   @Override
   public void surfaceDestroyed(SurfaceHolder arg0) {
   }
   
   private void iniPlayer(){
      try {
         mVideoPlayer.setDataSource(videoPath);
         mVideoPlayer.prepare();
         mVideoPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
         mVideoPlayer.setVolume(0, 0);
         mVideoPlayer.start();
      }
      catch (IllegalArgumentException e) {
         Log.d(APPNAME, e.toString());
         mVideoPlayer = null;
         svVideo.setVisibility(GONE);
      } catch (IllegalStateException e) {
         Log.d(APPNAME, e.toString());
         mVideoPlayer = null;
         svVideo.setVisibility(GONE);
      } catch (IOException e) {
         Log.d(APPNAME, e.toString());
         mVideoPlayer = null;
         svVideo.setVisibility(GONE);
      }
   }


If I take a video non supported by the SurfaceView, no "problem" the behavior is ok. My view disappears.
If I take a video which should work, I desperately have a black screen only...

The same piece of code works fine on another device (Galaxy Tab with 2.3).
Am I missing something in my code?

Thanks in advance for any help or suggestions you could give :)

nico
nioupy
Developer
Developer
 
Posts: 36
Joined: Sat Apr 03, 2010 1:34 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: Exabot [Bot] and 24 guests