Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add onAudioInterruptionEnd and onAudioInterruptionBegin event call #118

Conversation

zhefengzhang
Copy link
Contributor

@zhefengzhang zhefengzhang commented May 12, 2020

Fixed an issue where audio playback could not be automatically resumed when the audio was unexpectedly interrupted

修复音频意外中断时无法自动恢复播放的问题

wx.onAudioInterruptionEnd && wx.onAudioInterruptionEnd(onShown);
wx.onAudioInterruptionBegin && wx.onAudioInterruptionBegin(onHidden);

Copy link
Collaborator

@PPpro PPpro May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

common 模块的实现会影响其他平台,麻烦在 platforms/wechat/wrapper/engine/ 里另外新建一个 Game.js ,在这里覆盖 _initEvents 接口的实现
platforms/wechat/wrapper/engine/index.js 引入 Game.js

Copy link
Collaborator

@PPpro PPpro May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

或者更简单点,可以在 platforms/wechat/wrapper/unify.js 里加

utils.cloneMethod(globalAdapter, wx, 'onAudioInterruptionEnd');
utils.cloneMethod(globalAdapter, wx, 'onAudioInterruptionBegin');

然后在 Game.js 里,你只要这样做就行里

__globalAdapter.onAudioInterruptionEnd && __globalAdapter.onAudioInterruptionEnd(onShown);
__globalAdapter.onAudioInterruptionBegin && __globalAdapter.onAudioInterruptionBegin(onHidden);

PPpro
PPpro approved these changes May 12, 2020
@PPpro PPpro merged commit 452d079 into cocos-creator-packages:v2.4.0 May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants