Android 中的 MediaPlayer 和 VideoView 有什么区别 [英] What is the difference between MediaPlayer and VideoView in Android
问题描述
我想知道它们在流式传输视频方面是否有区别.
I was wondering if there's a difference between them when it comes to streaming videos.
我知道 VideoView
可用于流式传输,Mediaplayer
有什么用?据我所知,MediaPlayer
可以和 VideoView
做同样的事情,对吗?
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?
谁能给我答案?
如果我想通过使用 RTSP 将视频从服务器流式传输到 Android,我应该从哪一个开始?VideoView
还是 MediaPlayer
?
And if I want to stream video from the server by using RTSP to Android, which one should I start with? VideoView
or MediaPlayer
?
有什么建议吗?
推荐答案
问了同样的问题,正如我从 Mark (CommonsWare) 建议 在这里的许多线程中,VideoView 是 MediaPlayer 和 SurfaceView 的包装器(20000 行代码)以提供嵌入式控件.
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
和来自 android sdk 的示例http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/MediaPlayerDemo.html
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
这篇关于Android 中的 MediaPlayer 和 VideoView 有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!