Android - 播放视频的不同方式
我刚刚遇到了 VideoView 的限制,无法播放宽度超过 320 像素的 mp4 视频文件。我想知道我们如何才能克服这些限制。我试图让我的应用程序尽可能宽容,所以除了使用 VideoViews 之外,还有其他方法来播放这些 mp4 视频吗?
克里斯
I just came across the limitation of VideoView of not being able to play mp4 video files that are wider than 320 pixels. I was wondering how can we overcome these limitations. I am trying to make my app as forgiving as possible, so other than using VideoViews is there another way to play these mp4 videos?
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道
VideoView
的宽度限制为 320px,尽管我还没有尝试过。您可以使用
MediaPlayer
和SurfaceView
来播放视频。事实上,这几乎就是VideoView
的全部内容。最后我查看了VideoView
源代码,只有大约 200 行。这是一个示例项目,它使用
MediaPlayer
和实现视频播放器SurfaceView
,通过屏幕点击来调出一些弹出面板(例如,时间轴)。I am not aware of a 320px wide limit on
VideoView
, though I haven't tried it.You can use
MediaPlayer
and aSurfaceView
to play back videos. In fact, that's pretty much allVideoView
is. Last I looked at theVideoView
source code, it was only ~200 lines.Here is a sample project that implements a video player using
MediaPlayer
andSurfaceView
, with screen taps to bring up some pop-up panels (e.g., timeline).