Android中MediaPlayer和VideoView有什么区别

发布于 2024-09-30 18:06:58 字数 305 浏览 8 评论 0原文

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

我知道 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

所谓喜欢 2024-10-07 18:06:58

我问了同样的问题,正如我从 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

坦然微笑 2024-10-07 18:06:58

VideoView 本质上是一个与 MediaPlayer 绑定的视图,可以更轻松地在应用程序中实现视频。如果您不做太多自定义工作,VideoView 就是您的最佳选择。

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

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

视频应该在设备上进行测试,因为模拟器播放效果很差,您还应该请注意,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:

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.

你的他你的她 2024-10-07 18:06:58

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文