视频查看和渐进式下载
在我的应用程序中,我需要为用户提供渐进式下载(视频文件)的预览。
为了实现这一目标,我使用 VideoView
组件来显示正在下载的视频(.mp4、.3gpp)的内容。
问题是我无法通过 http://
或 rtsp://
协议访问远程媒体,因此我被迫使用 VideoView.setVideoPath
在下载时播放视频的本地副本。
不幸的是,在 Android 设备上似乎无法使用 StageFright
框架(因此根据我的经验,OpenCore
和一些基于 Tegra2
的设备), VideoView
无法正确处理渐进式下载:它只能播放组件初始化期间识别的视频部分。
需要明确的是:如果用户在仅下载了 5% 的视频时按下“播放”,VideoView 将仅显示 5% 的视频,无论同时是否下载了更多视频内容。
根据我的经验,此问题不会影响使用 StageFright
框架的设备(例如:Nexus One 2.2、Nexus One 2.3.4)。
谁能指出我可能的解决方案? 提前致谢
In my application I need to provide the user with a preview on a progressive download (video file).
In order to achieve this, I'm using VideoView
component to show the content of the video (.mp4, .3gpp) which is being downloaded.
The problem is that I can't access remote media via http://
or rtsp://
protocol, so I'm forced to use VideoView.setVideoPath
to play local copy of the video while downloading.
Unfortunately it seems like on Android devices that can't use StageFright
framework (so OpenCore
and some Tegra2-based
devices in my experience), the VideoView
can't handle progressive download correctly: it can play only the portion of the video recognized during the component initialization.
So to be clear: if the user press "play" when only 5% of the video has been downloaded, VideoView will show only that 5% of video, no matter if more video content ha been downloaded in the meantime.
In my experience this issue doesn't affect devices using StageFright
framework (e.g.: Nexus One 2.2, Nexus One 2.3.4).
Can anyone point me to a possible solution ?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您尝试播放 .h264,您需要将 MOV 原子移动到文件的前面。这些告诉编解码器电影的长度等。
尝试 qtfaststart
http://ffmpeg.zeranoe.com/builds/
If you are trying to play .h264, You need to move the MOV atoms to the front of the file. These tell the codec the length of the movie among other things.
try qtfaststart
http://ffmpeg.zeranoe.com/builds/
VideoView 是 Android 应用程序框架中用于视频播放用例的现成类。它内部使用MediaPlayer类来实现播放。 MediaPlayer 根据某些标准(如文件格式、内容来源等)使用内部可用的媒体框架。
因此,限制来自底层框架,而不是 VideoView。如果您仍然怀疑 VideoView,请使用媒体播放器编写您自己的视频播放器活动。您将看到相同的结果。
此外,并非所有版本的 Android(读作 stagefright)都支持渐进式下载。
也许您可以使用 DownloadManager 类从 http 服务器下载内容,并提供媒体播放器/视频视图的路径以进行快速预览。
沙什316
VideoView is a ready to use class in Android Application Framework for video playback use case. It internally uses MediaPlayer class to achieve playback. MediaPlayer uses media frameworks available internally based on certain criteria like file format , origin of content etc.
So the limitation is from underlying framework and not VideoView. If you are still suspecting VideoView then write your own video player activity using media player. You will see the same result.
Also not all versions of Android (read as stagefright) support progressive download.
May be you can use DownloadManager class for downloading content from http server and provide the path to media player / video view for a quick preview.
Shash316