mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-16 07:10:29 +05:30
19 lines
380 B
Kotlin
19 lines
380 B
Kotlin
|
package com.github.libretube.extensions
|
||
|
|
||
|
import androidx.media3.common.Player
|
||
|
|
||
|
fun Player.togglePlayPauseState() {
|
||
|
when {
|
||
|
playerError != null -> {
|
||
|
prepare()
|
||
|
play()
|
||
|
}
|
||
|
|
||
|
!isPlaying && playbackState == Player.STATE_ENDED -> {
|
||
|
seekTo(0)
|
||
|
}
|
||
|
|
||
|
!isPlaying && !isLoading -> play()
|
||
|
else -> pause()
|
||
|
}
|
||
|
}
|