Workaround exoplayer bug

This commit is contained in:
vfsfitvnm
2022-10-03 18:30:41 +02:00
parent 549e190965
commit 13028e41c7

View File

@@ -104,6 +104,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.cancellable
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import kotlinx.coroutines.plus
import kotlinx.coroutines.runBlocking
@@ -297,6 +298,8 @@ class PlayerService : InvincibleService(), Player.Listener, PlaybackStatsListene
if (totalPlayTimeMs > 30000) {
query {
// THANKS, EXOPLAYER
if (runBlocking { Database.song(mediaItem.mediaId).first() } != null) {
Database.insert(
Event(
songId = mediaItem.mediaId,
@@ -307,6 +310,7 @@ class PlayerService : InvincibleService(), Player.Listener, PlaybackStatsListene
}
}
}
}
override fun onMediaItemTransition(mediaItem: MediaItem?, reason: Int) {
maybeRecoverPlaybackError()