将视频流式传输(或渐进式下载)到 Droid 浏览器
我正在尝试将视频流式传输(或使用渐进式下载)到 Motorola Droid 浏览器,但运气不佳。使用我的 iPhone,我可以将 Safari 定向到 http://xxx.xxx.xxx/FileName.mp4(这是一个 MPEG-4 视频文件),Safari 将打开 Quicktime,然后播放视频。但是,使用 Droid,我访问相同的网址并遇到错误,指出“无法播放视频....抱歉,该视频对于流式传输到此设备无效”。
当我将 Droid 的浏览器定向到 WMV 文件时,它将完全下载该视频文件,然后如果我单击它,就会在 Droid 视频播放器中播放该文件。
理想情况下,我想在 Droid 上复制 iPhone 的行为,即弹出视频播放器并在完全下载之前开始播放视频。视频格式不是问题,因为我可以将视频编码为几乎任何标准。我正在尝试 .mp4 文件,因为 Droid 文档说它支持 MPEG-4 视频,尽管我无法让它在浏览器中工作。
任何见解将不胜感激。
I am trying to stream video (or use progressive download) to a Motorola Droid Browser and am not having a lot of luck. With my iPhone, I can direct Safari to http://xxx.xxx.xxx/FileName.mp4 (which is an MPEG-4 video file), and Safari opens quicktime, and the video plays. However, with the Droid, I go to the same web address and am faced with a error stating "Cannot play video.... Sorry, this video is not valid for streaming to this device".
When I direct the Droid's browser to a WMV file, it will fully download the video file and then play it in what appears to be the Droid video player if I click on it.
Ideally, I'd like to replicate the behavior of the iPhone on the Droid, where the video player pops up and the video starts before the complete download. Video format isn't an issue, as I can encode the video to pretty much any standard. I was trying the .mp4 file because the Droid documentation says that it supports MPEG-4 video, although I can't get it to work from the browser.
Any insight would be much appreciate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您应该启动一个意图并将类型设置为“video/*”,以便它直接使用视频播放器而不是浏览器打开。
You should launch an intent and set the type to "video/*" so that it opens directly with a video player instead of the browser.
Android 中的流媒体播放是一件令人头疼的事情。最好的选择是使用 RTSP 协议流式传输视频。
如果您的 Droid 更新到 2.2,您还可以设置一个带有嵌入式 Flash 播放器(如 jwplayer)的简单网页(当设备上未安装 Flash 播放器时,不要忘记设置备用内容,以便用户可以从 Adobe 下载) 。
我成功部署了这两种解决方案。 RTSP for <2.1 和嵌入式 Flash 播放器播放来自 RTMP 流的视频(您也可以从服务器播放本地文件)
请注意,在某些设备 (Hero) 中,您无法在应用程序中嵌入带有 Flash 播放器的 WebView。
如果您正在寻找快速解决方案,我会尝试 3gp。
此外,当连接速度不够快而无法播放视频时,您将收到您发布的相同错误(即使使用正确编码的视频)。
编辑:我在 RTSP 流上使用 H.264,在 RTMP 上使用 VP6。仅较新的设备支持 VP8。
Streaming in Android is a pain in the ass. The best option is to stream the video with RTSP protocol.
If your Droid is updated to 2.2 you can also set up a simple webpage with an embedded Flash player like jwplayer (don't forget to set up alternate content when Flash player is not installed on the device so the user can download it from Adobe).
I successfully deployed both solutions. RTSP for <2.1 and embedded Flash player playing video from RTMP stream (you can also play local file from the server)
Note that in some devices (Hero) you can't embed the WebView with the Flash player inside your app.
If you look for a fast solution I would give a try to 3gp.
Also, when connectivity is not fast enough to play the video you will get that same error you posted (even with properly encoded videos).
EDIT: I used H.264 on RTSP streams and VP6 on RTMP. VP8 is supported by newer devices only.
我对此并不完全确定,但我认为这实际上不可能。
据我所知,“支持”仅意味着它可以开箱即用地播放它,但浏览器没有插件,所以它不知道与它有关。
如果你想验证Android是否可以播放该文件,请将其放在SD卡上并通过图库播放。
I am not entirely sure about this but I don't think it's really possible.
As far as I know "supported" only means it can play it out of the box, but there are no plugins for the browser so it doesn't know that to do with it.
If you want to validate if Android can play the file, put it on the SD card and play it through the Gallery.
支持从浏览器播放 mp4 文件。如果您的特定链接不起作用,请发布该链接。另外,查看“adb logcat”显示的内容也会很有帮助。
Playing a mp4 file from the browser is supported. If you have a particular link that is not working, please post the link. Also, it would be helpful to see what "adb logcat" shows.