I was wondering if there's a difference between them when it comes to streaming videos.
I know VideoView
can be used for streaming and what is Mediaplayer
for? As far as I know, MediaPlayer
can do the same thing as VideoView
right?
Can anyone give me the answer?
And if I want to stream video from the server by using RTSP to Android, which one should I start with? VideoView
or MediaPlayer
?
Any suggestion?
MediaPlayer Class in Android is used to play media files. Those are Audio and Video files. It can also be used to play audio or video streams over the network.
Prepare media file: To play a media file, you need to first prepare it i.e. you need to load the file for playback. Methods used for doing this are prepare(), prepareAsync(), and setDataSource(). Start/Pause the playback: After loading the media file, you can start playing the media file by using the start() method.
mediaPlayer. start(); mediaPlayer. pause(); On call to start() method, the music will start playing from the beginning.
The feature is as simple as tapping and holding on the media card of any app then choosing Dismiss. Playback stops and the controls go away.
Was asking the same question and as I understood from what Mark (CommonsWare) advised on numerous threads here, VideoView is a wrapper (200 hundred lines of code) for MediaPlayer and SurfaceView to provide embedded controls.
He also kindly shared some examples:
https://github.com/commonsguy/cw-advandroid/blob/master/Media/Video/src/com/commonsware/android/video/VideoDemo.java
https://github.com/commonsguy/vidtry/blob/master/src/com/commonsware/android/vidtry/Player.java
and example from android sdk http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/MediaPlayerDemo.html
Also some people had issues playing video on emulator, so make sure to test it on actual device if you have issues
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With