Open
Conversation
实例:我依赖了 FlutterPerfectVolumeControl 插件,当我在听歌时,打开我的App,则会中断我的音乐播放。 原因:当plugin 调用 register()时,会调用AVAudioSession.sharedInstance().setActive(true)方法,如果此时其他音频正在播放音乐(QQ音乐),则会暂停其他音频。 解决方案:把设置 setActive() 方法提取出来作为公共方法,让开发人员自由选择,默认false 不做处理。 setActive(true) 抢夺音频焦点,中断其他音频, setActive(false)不会抢夺音频焦点 建议:我只是简单处理了一下,还有其他 Category,需要设置。
Owner
|
I'll check it and merge it. |
Owner
|
It works on Ios, but it doesn't work on android. I'll try to unify it. Do you have a better way to unify it? |
Author
|
是的,预期是这样的。这个设置active方法只针对ios,对安卓不起作用。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
实例:我依赖了 FlutterPerfectVolumeControl 插件,当我在听歌时,打开我的App,则会中断我的音乐播放。
原因:当plugin 调用 register()时,会调用AVAudioSession.sharedInstance().setActive(true)方法,如果此时其他音频正在播放音乐(QQ音乐),则会暂停其他音频。
解决方案:把设置 setActive() 方法提取出来作为公共方法,让开发人员自由选择,默认false 不做处理。
setActive(true) 抢夺音频焦点,中断其他音频,
setActive(false)不会抢夺音频焦点
建议:我只是简单处理了一下,还有其他 Category,需要设置。