在一个视频正在缓冲时播放另一个视频
我有两个视频。视频 A 存在于设备上,而视频 B 需要从互联网上流式传输。我的目标是在视频 B 开始缓冲时播放视频 A。据我了解,我需要为每个视频创建一个 MediaPlayer 实例。然后我可以在两者上调用prepareAsync()并开始在onPrepared()中播放。然而,Android 中似乎存在一些限制,这些限制共同阻止了其正常工作:
1) MediaPlayer 仅在提供了屏幕上存在的 SurfaceView 后才能开始缓冲。
2) 一次只能有一个MediaPlayer连接到SurfaceView。
3) 屏幕上仅支持单个SurfaceView。
我已经成功地通过一部手机获得了两个 MediaPlayer 实例来共享一个 SurfaceView。另一方面,我可以同时在屏幕上显示两个 SurfaceView。但据我了解,Android 官方均不支持?
我做错了什么吗?还有其他人可以做到这一点吗?
I have two videos. Video A is present on the device while video B needs to be streamed off the internet. My goal is to play video A while video B starts buffering. As I understand it I need to create one MediaPlayer instance for each video. Then I can call prepareAsync() on both and start playing in onPrepared(). However, there seem to be some limitations in Android which together prevent this from working properly:
1) MediaPlayer can only start buffering after it has been provided a SurfaceView which is present on screen.
2) Only one MediaPlayer at a time can be connected to a SurfaceView.
3) There is only support for a single SurfaceView on screen.
One one phone I have managed to get two MediaPlayer instances to share one SurfaceView. On another I can get two SurfaceViews on screen at the same time. But as I understand it neither is officially supported by Android?
Am I doing something wrong? Has anyone else got this working?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论