Several things potentially wrong with your code: - you're using MediaPlayer.create(), which calls prepare() for you. IIRC, setDisplay() needs to be called *before* prepare(), so you won't be able to use any of the MediaPlayer.create convenience methods. - the way you create and use the SurfaceView, you'll probably end up with a 0-sized Surface, so try specifying the SurfaceView in an xml layout and using that. - depending on the type of video, size information may not be available until decoding has started. There's a callback/listener for that.
On Sat, Feb 14, 2009 at 1:24 PM, Brendan <[email protected]> wrote: > > I'm just trying to play a local video that is a resource with the > MediaPlayer class in the most simple way possible. I have confirmed > that the video works with players that I download from the > marketplace, so I'm assuming that's not the issue. > > The problem is that I just get a black screen with no video. There is > audio from the file playing though, so I know that the file resource > is being accessed correctly, it's just not showing anything on the > screen in the emulator. > > The one other note is that at any time whenever I try to access > getVideoWidth() or getVideoHeight() I get this (non-blocking) error: > > ERROR/MediaPlayerService(24): getVideoSize returned -1 > > Any ideas as to what I could be doing wrong? > > > > import android.app.Activity; > import android.os.Bundle; > import android.view.SurfaceView; > import android.view.SurfaceHolder; > import android.media.MediaPlayer; > > public class Example extends Activity { > > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > > SurfaceView sv = new SurfaceView(this); > setContentView(sv); > > SurfaceHolder holder = sv.getHolder(); > holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); > > new MediaPlayer(); > MediaPlayer mp = MediaPlayer.create(this, R.raw.video); > //holder.setFixedSize(mp.getVideoWidth(), mp.getVideoHeight > ()); > mp.setDisplay(holder); > mp.start(); > } > } > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

