androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.58k stars 375 forks source link

Notification dismiss callback question #1733

Open rcolletrf opened 1 week ago

rcolletrf commented 1 week ago

Hello, I have an issue with notifications in Media3 (v1.4.1). I'm using it to play audio media items using HLS with the built-in notification system of Media3 to show notifications with custom actions when items are playing. With this built-in notification feature, I would like to get a callback to know when the user is dismissing the notification manually. I use the PlayerNotificationManager class attached to my player but for some reason, the onNotificationCancelled function is not called when I manually dismiss the player notification. Do you know what might be missing? Device: Pixel 8, Android 14

marcbaechinger commented 1 week ago

There is #211 that discusses the event coming from a notification when the user dismisses it. Regarding that event, I think it concluded with this comment where I was claiming that the System isn't giving apps such an event on all API levels. This then is the reason why Media3 doesn have such an event, as Media3 needs to have an API that work on all API levels.

I use the PlayerNotificationManager class attached to my player but for some reason, the onNotificationCancelled function is not called when I manually dismiss the player notification.

I understand that this used to work with PlayerNotificationManager at least on devices that run an OS before Device: Pixel 8, Android 14. If so, this notion does confirm what is said and discussed in #211. There isn't such an event fired from the OS on Android 14.

If the above is correct, you verify that it gives you such an event on Android 13 with the same implementation that doesn't give this on Android 14.