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

能不能考虑将registerAudioPlaybackCallback替换为registerAudioPolicy以兼容低版本安卓 #1117

Open
gameboyout opened this issue Dec 22, 2024 · 4 comments

Comments

@gameboyout
Copy link

目前的registerAudioPlaybackCallback在低版本安卓上,thanos.getAudioManager().hasAudioFocus不工作,audioFocusChanged触发也不工作。
发现一个用registerAudioPolicy监测音频焦点变化的范例:https://github.com/dongpingwang/MyAudio/tree/main
这个方式可以兼容低版本安卓,并且方法onAudioFocusChange的参数值可以区分焦点变化是获取焦点还是丢失焦点,更加详细。
希望大神考虑一下😊

@Tornaco
Copy link
Owner

Tornaco commented Dec 26, 2024

@gameboyout 目前方案是Android 8+ 会通过registerAudioPlaybackCallback来监听。更低的android版本会hook MediaFocusControl来监听焦点切换。你测试的是Android7上不工作吗?

@gameboyout
Copy link
Author

是的,Android7不工作。thanos.getAudioManager().hasAudioFocus('com.maxmpz.audioplayer')即使poweramp在播放音乐也始终返回false,audioFocusChanged触发不了。hook MediaFocusControl好像只是hook到mFocusStack新建了一个代理列表,谁监听焦点变化后push进去这部分我没有读懂源码😭

@gameboyout
Copy link
Author

我是菜鸟,莫怪😉

@Tornaco
Copy link
Owner

Tornaco commented Dec 28, 2024

是的,Android7不工作。thanos.getAudioManager().hasAudioFocus('com.maxmpz.audioplayer')即使poweramp在播放音乐也始终返回false,audioFocusChanged触发不了。hook MediaFocusControl好像只是hook到mFocusStack新建了一个代理列表,谁监听焦点变化后push进去这部分我没有读懂源码😭

晚点我测试下android7看看啥原因吧。

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

No branches or pull requests

2 participants