96

我想知道在流媒体视频方面它们之间是否有区别。

我知道VideoView可以用于流媒体,有什么Mediaplayer用?据我所知,MediaPlayer可以做同样的事情VideoView吗?

谁能给我答案?

如果我想通过使用 RTSP 将视频从服务器流式传输到 Android,我应该从哪一个开始?VideoView还是MediaPlayer

有什么建议吗?

4

4 回答 4

41

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

于 2011-01-19T20:12:52.167 回答
17

VideoView 本质上是一个与 MediaPlayer 相关联的视图,可以更轻松地在您的应用中实现视频。如果您没有做太多的自定义工作,那么 VideoView 是您的最佳选择。

也就是说,您还可以将 RTSP 链接传递给系统,以使用最合适的应用程序播放视频,这更容易做到:

String url = "rtsp://yourrtsplink.com/blah";
Uri uri = Uri.parse(url);
startActivity(new Intent(Intent.ACTION_VIEW, uri));

应该在设备上测试视频,因为模拟器播放效果很差,而且您还应该知道 RTSP 需要打开一个额外的端口,这被某些防火墙阻止。

于 2011-01-19T20:34:07.967 回答
3

阅读以下链接,它将帮助您并解决您的问题。

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

于 2013-06-10T12:47:49.070 回答
0

VideoAdView 是 MediaPlayer 和 SurfaceView 的包装器,如果视频文件存储在应用程序的内部存储中使用内容提供程序或将它们存储为全球可读,则使用 VideoView 比使用 MediaPlayer 更容易实现视频播放器,否则它将不行

于 2013-03-08T21:30:13.720 回答