视频流和 Android
今天,对于我的一个应用程序 (Android 2.1),我想从 URL 流式传输视频。
就我对 Android SDK 的探索而言,它非常好,我几乎喜欢它的每一个部分。 但现在谈到视频流,我有点迷失了。
如果您需要有关 Android SDK 的任何信息,您可以通过数以千计的博客来了解如何操作。当谈到视频流时,情况有所不同。信息就是这么丰富。
每个人都这样做,到处都是欺骗。
是否有任何众所周知的程序可以让人们流式传输视频?
谷歌是否想过让其开发者变得更容易?
Today for one of my app (Android 2.1), I wanted to stream a video from an URL.
As far as I explored Android SDK it's quite good and I loved almost every piece of it.
But now that it comes to video stream I am kind of lost.
For any information you need about Android SDK you have thousands of blogs telling you how to do it. When it comes to video streaming, it's different. Informations is that abundant.
Everyone did it it's way tricking here and there.
Is there any well-know procedure that allows one to stream a video?
Did google think of making it easier for its developers?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只想让操作系统使用默认播放器播放视频,您可以使用如下意图:
但是,如果您想自己创建一个视图并将视频流式传输到其中,一种方法是在布局中创建一个视频视图并使用媒体播放器将视频流式传输到它。这是 xml 中的视频视图:
然后在 Activity 的 onCreate 中找到视图并启动媒体播放器。
检查视频视图侦听器,以便在视频播放完毕或发生错误时收到通知(VideoView.setOnCompletionListener、VideoView.setOnErrorListener 等)。
If you want to just have the OS play a video using the default player you would use an intent like this:
However if you want to create a view yourself and stream video to it, one approach is to create a videoview in your layout and use the mediaplayer to stream video to it. Here's the videoview in xml:
Then in onCreate in your activity you find the view and start the media player.
Check out the videoview listeners for being notified when the video is done playing or an error occurs (VideoView.setOnCompletionListener, VideoView.setOnErrorListener, etc).