Fix crash in player when no connection to server

This commit is contained in:
jarnedemeulemeester 2021-08-25 18:10:00 +02:00
parent be2c4dcb9a
commit 1417d97223
No known key found for this signature in database
GPG key ID: 60884A0C1EBA43E5

View file

@ -84,10 +84,14 @@ constructor(
private fun releasePlayer() {
_player.value?.let { player ->
runBlocking {
jellyfinRepository.postPlaybackStop(
UUID.fromString(player.currentMediaItem?.mediaId),
player.currentPosition.times(10000)
)
try {
jellyfinRepository.postPlaybackStop(
UUID.fromString(player.currentMediaItem?.mediaId),
player.currentPosition.times(10000)
)
} catch (e: Exception) {
Timber.e(e)
}
}
}
@ -107,11 +111,15 @@ constructor(
override fun run() {
viewModelScope.launch {
if (player.currentMediaItem != null) {
jellyfinRepository.postPlaybackProgress(
UUID.fromString(player.currentMediaItem!!.mediaId),
player.currentPosition.times(10000),
!player.isPlaying
)
try {
jellyfinRepository.postPlaybackProgress(
UUID.fromString(player.currentMediaItem!!.mediaId),
player.currentPosition.times(10000),
!player.isPlaying
)
} catch (e: Exception) {
Timber.e(e)
}
}
}
handler.postDelayed(this, 2000)