doublesymmetry / KotlinAudio

KotlinAudio is an Android audio player written in Kotlin, making it simpler to work with audio playback from streams and files.
Apache License 2.0
45 stars 70 forks source link

Incorrect notification image after fast switch #78

Closed mvn-hungtruong-dn closed 1 year ago

mvn-hungtruong-dn commented 1 year ago

https://developer.android.com/develop/ui/views/notifications#limits Android limits the notification update rate to 5, so if users tap the buttons recursively the notification won't be updated This is the cause of the issue https://github.com/doublesymmetry/react-native-track-player/issues/2021

So I have to limit the debounce of the invalidate call and also invalidate once again after 1s to make sure the UI is up-to-date. I also add the parameter androidNotificationDebounceInterval for react-native-track-player to use.

Please review NotificationManager and BaseAudioPlayer. If it is OK. I will create another PR from this repository instead of my forked repo. Thanks. 😄

puckey commented 1 year ago

How much of a delay will these debounces cause? What is the debounce time you are using?

kirillzyusko commented 1 year ago

@puckey we are using 300ms as a debounce interval.

puckey commented 1 year ago

Why is the extra update after 1 second necessary? Which case does it solve?

mvn-hungtruong-dn commented 1 year ago

@puckey Because even with 300ms, if the user switches fast enough, there will be a chance to reproduce this issue. So 1 second after the user stops switching, we will invalidate again to make sure everything in the notification is up-to-date.

mvn-hungtruong-dn commented 1 year ago

@jspizziri I already notified this in the description. Please review NotificationManager and BaseAudioPlayer, if it's OK I will create another PR from this repository instead of my forked repository. I will also revert the style in both files. 😄

mvn-hungtruong-dn commented 1 year ago

Please review this PR instead. https://github.com/doublesymmetry/KotlinAudio/pull/81