Video stream (MPEG4 video) not showing on android using MediaPlayer?
There is an online stream that is 512Kb MPEG4 and total size of 312mb online and if I'm correct after looking over docs in order to play the movie I just simply put:
MediaPlayer mp = new MediaPlayer();
Try{
mp.setDataSource("http://site.com/movie.mp4");
}
Try {
mp.prepare();
}
mp.start();
It is triggered to play after a button press which after a few seconds after pressing the button it plays the audio BUT doesn't show the video, why not? Do I have to use a surface view or something for visual playback of the stream (the a开发者_开发知识库ndroid docs don't seem to help me much)?
First, yes, you need a SurfaceView
to play back video with a MediaPlayer
. Or, use a VideoView
and skip the MediaPlayer
.
Second, if you are trying to play this back in the emulator, this is typical behavior. Video playback will not work well on the emulator unless you have crazy-fast hardware. I recommend that video player development be done with actual Android devices.
精彩评论