安全重置在$ P $ MediaPlayer在pparing状态? [英] Safe to reset a MediaPlayer in preparing state?

查看:78
本文介绍了安全重置在$ P $ MediaPlayer在pparing状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写用的MediaPlayer,允许用户跳过的实际调的音频播放器。跳过请求可能发生在任何时间,包括调用MediaPlayer的。prepareAsync和prepared回调即将到来之间。该医生说:

I'm writing an audio player using MediaPlayer that allows the user to skip the actual tune. A skip request might occur at any time, including between a call to MediaPlayer.prepareAsync and the upcoming onPrepared callback. The doc says:

值得注意的是,preparing状态是过渡状态,并呼吁有副作用的任何方法的行为而MediaPlayer对象是在preparing状态是不确定的,是非常重要的。

这是否包括调用reset,甚至释放?因为如果是这样,那我要么必须等待上prepared回调重用的MediaPlayer或者分配一个全新的MediaPlayer,如果我不想等待,释放过时一个在上prepared回调,对吧?

Does that include calls to reset, or even to release? Because if it so, then I would either have to wait for the onPrepared callback to reuse the MediaPlayer or allocate a brand new MediaPlayer if I don't want to wait and release the obsolete one on the onPrepared callback, right?

推荐答案

在我看来,我会遵循文档的建议,我发现了一些问题,球员在不同的设备(在某些设备并不稳定可言重用相同播放器)。

In my opinion i will follow the advice in the docs, i found several issues with player in different devices (in some devices is not stable at all reusing the same player).

我觉得一个很好的选择是要分配的的球员,当用户跳过调整它们之间进行切换,那么你就等着原作的玩家才能到达prepared状态,然后您安全地重置。

I think a good option is to have to players allocated, and switch between them when user skips a tune, then you wait for the original player to arrive to prepared state and then you reset it safely.

这篇关于安全重置在$ P $ MediaPlayer在pparing状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆