简体   繁体   中英

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 android 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM