Throw an error if the media player which has completed is not the expected one

This commit is contained in:
Florian Renaud 2023-01-13 15:46:48 +01:00
parent 8a2f28bc37
commit 169c9b221c

View file

@ -436,7 +436,11 @@ class VoiceBroadcastPlayerImpl @Inject constructor(
override fun onCompletion(mp: MediaPlayer) {
// Release media player as soon as it completed
mp.release()
currentMediaPlayer = null
if (currentMediaPlayer == mp) {
currentMediaPlayer = null
} else {
error("The media player which has completed mismatches the current media player instance.")
}
// Next media player is already attached to this player and will start playing automatically
if (nextMediaPlayer != null) return