Android中MediaPlayer和VideoView有什么区别
我想知道它们在流媒体视频方面是否有区别。
我知道 VideoView
可用于流媒体,Mediaplayer
有何用途?据我所知, MediaPlayer
可以做与 VideoView
相同的事情,对吧?
谁能给我答案吗?
如果我想使用 RTSP 将视频从服务器流式传输到 Android,我应该从哪一个开始? VideoView
还是 MediaPlayer
?
有什么建议吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我问了同样的问题,正如我从 Mark (CommonsWare) 建议中了解到的这里的众多线程上,VideoView是MediaPlayer和SurfaceView的包装器(200百行代码),以提供嵌入式控件。
他还友善地分享了一些示例:
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
和来自 android sdk 的示例
http://developer.android .com/resources/samples/ApiDemos/src/com/example/android/apis/media/MediaPlayerDemo.html
另外,有些人在模拟器上播放视频时遇到问题,因此,如果您有的话,请务必在实际设备上进行测试问题
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
VideoView 本质上是一个与 MediaPlayer 绑定的视图,可以更轻松地在应用程序中实现视频。如果您不做太多自定义工作,VideoView 就是您的最佳选择。
也就是说,您还可以将 RTSP 链接传递给系统,以使用最合适的应用程序来播放视频,这更容易做到:
视频应该在设备上进行测试,因为模拟器播放效果很差,您还应该请注意,RTSP 需要打开额外的端口,该端口被某些防火墙阻止。
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:
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.
阅读下面的链接,它将帮助您并解决您的问题。
http://eclipsesource. com/blogs/2012/08/24/lessons-learned-when-using-androids-mediaplayer-and-videoview/
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/
VideoAdView是MediaPlayer和SurfaceView的包装,使用VideoView实现视频播放器比使用MediaPlayer更容易,如果视频文件存储在应用程序的内部存储中使用内容提供程序或将它们存储为世界可读的,否则它将不工作
The VideoAdView 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