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

Bug: Android 15 audio focus #110

Open
SimonMarquis opened this issue Nov 8, 2024 · 2 comments · May be fixed by #111
Open

Bug: Android 15 audio focus #110

SimonMarquis opened this issue Nov 8, 2024 · 2 comments · May be fixed by #111
Labels
bug Something isn't working

Comments

@SimonMarquis
Copy link
Owner

It seems like the audio focus request is no longer working on Android 15, preventing the app to pause the media playback.

Restrictions on requesting audio focus
Apps that target Android 15 (API level 35) must be the top app or running a foreground service in order to request audio focus. If an app attempts to request focus when it does not meet one of these requirements, the call returns AUDIOFOCUS_REQUEST_FAILED.

https://developer.android.com/about/versions/15/behavior-changes-15#audio-focus

@SimonMarquis SimonMarquis added the bug Something isn't working label Nov 8, 2024
@SimonMarquis
Copy link
Owner Author

@SimonMarquis
Copy link
Owner Author

This might be an alternative to request audio focus:

dispatchMediaKeyEvent(KeyEvent(ACTION_DOWN, KEYCODE_MEDIA_PAUSE))
dispatchMediaKeyEvent(KeyEvent(ACTION_UP, KEYCODE_MEDIA_PAUSE))

SimonMarquis added a commit that referenced this issue Nov 10, 2024
Android 15 no longer allows requesting focus without a foreground `Activity` (or media session token), even when the request is performed from a foreground `Service`.

More info: https://developer.android.com/about/versions/15/behavior-changes-15#audio-focus

Fixes #110
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant