What is the difference between MediaPlayer and VideoView in Android
Solution 1
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/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
Solution 2
VideoView is essentially a View that is tied to a MediaPlayer to make it a lot easier to implement videos in your app. If you aren't doing much custom work, VideoView is the way to go.
That said, you can also pass the RTSP link off to the system to use the most appropriate app for playing the video, which is even easier to do:
String url = "rtsp://yourrtsplink.com/blah";
Uri uri = Uri.parse(url);
startActivity(new Intent(Intent.ACTION_VIEW, uri));
Video should be tested on a device, since emulator playback is poor, and you should also be aware that RTSP requires an extra port to be open, which is blocked by some firewalls.
Solution 3
Read below link, it will help you and will solve your question.
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Admin
Updated on December 28, 2020Comments
-
Admin over 3 years
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 isMediaplayer
for? As far as I know,MediaPlayer
can do the same thing asVideoView
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
orMediaPlayer
?Any suggestion?