在两个 MediaPlayer 之间共享 VideoView 不起作用
我有一个主 MediaPlayer,它可以很好地播放 RTSP 流,并且我使用 AsyncTask 来缓冲另一个流的内容。它实现了这一点。当我尝试切换到第二个流时,我可以听到流已切换并且没有延迟,但我只听到声音。 SurfaceHolder持有一个VideoView,它已经准备好了,我将它注册为两者的Display 媒体播放器。 当我切换流时,我停止旧的 MediaPlayer 但表面不会被破坏,这很好,但它不会显示我的第二个视频。有什么想法吗?
I have one main MediaPlayer which plays nicely an RTSP stream and I have used an AsyncTask to buffer the content of another stream. It achieves this. When I try to switch to the second stream, I can hear that the stream switched and it doesn't lag, but I only get sound.
The SurfaceHolder holds a VideoView, it has been prepared, I registered it as Display for both
mediaplayers.
When I switch streams, I stop the old MediaPlayer but the surface doesn't get destroyed, which is good, but it doesn't display my second video. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您能否提供您的 VideoView 实例化代码以及用于切换 MediaPlayers 的代码?
无论如何,我怀疑这是否能正常工作,因为 VideoView 实例化了自己的 MediaPlayer 并使用它来播放媒体。 (参见 VideoView.java)
您可能需要切换 VideoView 本身,或者使用您自己的 SurfaceView 子类构建 VideoView 的替代品。
Could you supply your VideoView instantiation code and the code you use to switch out the MediaPlayers?
In any case, I doubt this will work well because the VideoView instantiates its own MediaPlayer and uses it to play media. (see VideoView.java)
You would probably need to switch out the VideoView itself, or build a replacement for the VideoView using your own subclass of SurfaceView.