fix: playback progress is not saved when leaving player
This commit is contained in:
parent
5b1830c88b
commit
9133b2a273
1 changed files with 12 additions and 10 deletions
|
@ -27,6 +27,7 @@ import dev.jdtech.jellyfin.utils.postDownloadPlaybackProgress
|
||||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
@ -166,16 +167,17 @@ constructor(
|
||||||
|
|
||||||
@OptIn(DelicateCoroutinesApi::class)
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
private fun releasePlayer() {
|
private fun releasePlayer() {
|
||||||
player.let { player ->
|
val mediaId = player.currentMediaItem?.mediaId
|
||||||
GlobalScope.launch {
|
val position = player.currentPosition.times(10000)
|
||||||
try {
|
GlobalScope.launch {
|
||||||
jellyfinRepository.postPlaybackStop(
|
delay(1000L)
|
||||||
UUID.fromString(player.currentMediaItem?.mediaId),
|
try {
|
||||||
player.currentPosition.times(10000)
|
jellyfinRepository.postPlaybackStop(
|
||||||
)
|
UUID.fromString(mediaId),
|
||||||
} catch (e: Exception) {
|
position
|
||||||
Timber.e(e)
|
)
|
||||||
}
|
} catch (e: Exception) {
|
||||||
|
Timber.e(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue