What is the difference between MediaPlayer and VideoView in Android

前端 未结 4 1848
说谎
说谎 2020-12-07 15:36

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 Me

相关标签:
4条回答
  • 2020-12-07 15:52

    The VideoPlayer is a wrapper for MediaPlayer and SurfaceView, it's more easy to implement video player with VideoView than with a MediaPlayer, if the video files are stored in the internal storage of the app use content provider or store them as world readable, otherwise it will not work

    0 讨论(0)
  • 2020-12-07 15:56

    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

    0 讨论(0)
  • 2020-12-07 15:59

    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.

    0 讨论(0)
  • 2020-12-07 16:00

    Read below link, it will help you and will solve your question.

    http://eclipsesource.com/blogs/2012/08/24/lessons-learned-when-using-androids-mediaplayer-and-videoview/

    0 讨论(0)
提交回复
热议问题