fix playback position in playlist

This commit is contained in:
Christian Schabesberger 2024-09-13 18:34:56 +02:00
parent f643c032a2
commit edc720590c
5 changed files with 9 additions and 9 deletions

View File

@ -45,7 +45,7 @@ enum class RepeatMode {
interface NewPlayer {
// preferences
val preferredVideoVariants: List<String>
val prefearedAudioVariants: List<String>
val preferredAudioVariants: List<String>
val preferredStreamLanguage: List<String>
val exoPlayer: StateFlow<Player?>

View File

@ -62,7 +62,7 @@ class NewPlayerImpl(
private val repository: MediaRepository,
override val preferredVideoVariants: List<String> = emptyList(),
override val preferredStreamLanguage: List<String> = emptyList(),
override val prefearedAudioVariants: List<String> = emptyList(),
override val preferredAudioVariants: List<String> = emptyList(),
val httpDataSourceFactory: HttpDataSource.Factory = DefaultHttpDataSource.Factory(),
) : NewPlayer {
@ -355,7 +355,7 @@ class NewPlayerImpl(
playMode,
availableStreamVariants,
preferredVideoVariants,
prefearedAudioVariants,
preferredAudioVariants,
preferredStreamLanguage
)

View File

@ -63,7 +63,7 @@ data class VideoPlayerUIState(
val isLoading: Boolean,
val durationInMs: Long,
val playbackPositionInMs: Long,
val playbackPositionInPlaylistS: Int,
val playbackPositionInPlaylistMs: Long,
val fastSeekSeconds: Int,
val soundVolume: Float,
val brightness: Float?, // when null use system value
@ -87,7 +87,7 @@ data class VideoPlayerUIState(
bufferedPercentage = 0f,
isLoading = true,
durationInMs = 0,
playbackPositionInPlaylistS = 0,
playbackPositionInPlaylistMs = 0,
playbackPositionInMs = 0,
fastSeekSeconds = 0,
soundVolume = 0f,
@ -109,7 +109,7 @@ data class VideoPlayerUIState(
bufferedPercentage = 0.5f,
isLoading = false,
durationInMs = 12000,
playbackPositionInPlaylistS = 5039,
playbackPositionInPlaylistMs = 5039,
playbackPositionInMs = 400,
fastSeekSeconds = 10,
soundVolume = 0.5f,

View File

@ -369,10 +369,10 @@ class VideoPlayerViewModelImpl @Inject constructor(
progress += item.mediaMetadata.durationMs
?: throw NewPlayerException("Media Item not containing duration. Media Item in question: ${item.mediaMetadata.title}")
}
progress += ((newPlayer?.currentPosition ?: 0) / 1000)
progress += (newPlayer?.currentPosition ?: 0)
mutableUiState.update {
it.copy(
playbackPositionInPlaylistS = progress.toInt()
playbackPositionInPlaylistMs = progress
)
}
}

View File

@ -69,7 +69,7 @@ fun StreamSelectTopBar(
val duration = getPlaylistDurationInMS(uiState.playList)
val durationString = getTimeStringFromMs(timeSpanInMs = duration, locale)
val playbackPositionString = getTimeStringFromMs(
timeSpanInMs = uiState.playbackPositionInPlaylistS.toLong() * 1000, locale = locale
timeSpanInMs = uiState.playbackPositionInPlaylistMs, locale = locale
)
Text(
text = "$playbackPositionString/$durationString",