表面损坏后如何恢复视频播放?
我正在流媒体应用程序 (RTSP) 上使用媒体播放器:
视频和声音播放得很好,但是当来电暂停 Activity
时,Surface 会被破坏(我知道这一点是因为在SurfaceHolder.Callback)。
调用完成后,活动将恢复并创建一个新的 Surface
。我尝试通过 setDisplay(SurfaceHolder sh) 方法将其分配给播放器,但到目前为止,只能听到视频的声音。
恢复视频流的解决方法是:
- 重新启动
MediaPlayer
对象。 - 等待缓冲区填满。
- 通过 mediaPlayer 执行搜索。
- 等待缓冲区填满。
这很烦人,因为播放器应该能够在收到呼叫时暂停,在呼叫完成时绑定新表面,Activity
恢复并播放视频而根本没有缓冲。
I'm working with the media player on a streaming application (RTSP):
Video and sound are played great but when an incoming call pauses the Activity
, the Surface is destroyed (I know this because of traces in SurfaceHolder.Callback
).
Once the call finishes, the activity is resumed and a new Surface
is created. I've tried to assign it to the player via setDisplay(SurfaceHolder sh)
method but so far, only the sound of the video can be heard.
The work around to resume a video stream is:
- Restart the
MediaPlayer
object. - Wait for the buffer to fill.
- Perform a seek via the mediaPlayer.
- Wait for the buffer to fill.
This is annoying as the player should be able to be paused when a call is received, bind the new surface when the call completed and the Activity
resume and play the video with no buffering at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过覆盖“onStop”甚至“onDestroy”并以某种方式使玩家持久存在?
伊迪丝刚刚向我展示了这个问题的时间戳。还有兴趣吗?
Have you tried overriding "onStop" or even "onDestroy" and somehow make the player persitent?
Edith just showed me the timestamp of this question. Is it of any interest still?