fix playback position in playlist
This commit is contained in:
parent
f643c032a2
commit
edc720590c
|
@ -45,7 +45,7 @@ enum class RepeatMode {
|
||||||
interface NewPlayer {
|
interface NewPlayer {
|
||||||
// preferences
|
// preferences
|
||||||
val preferredVideoVariants: List<String>
|
val preferredVideoVariants: List<String>
|
||||||
val prefearedAudioVariants: List<String>
|
val preferredAudioVariants: List<String>
|
||||||
val preferredStreamLanguage: List<String>
|
val preferredStreamLanguage: List<String>
|
||||||
|
|
||||||
val exoPlayer: StateFlow<Player?>
|
val exoPlayer: StateFlow<Player?>
|
||||||
|
|
|
@ -62,7 +62,7 @@ class NewPlayerImpl(
|
||||||
private val repository: MediaRepository,
|
private val repository: MediaRepository,
|
||||||
override val preferredVideoVariants: List<String> = emptyList(),
|
override val preferredVideoVariants: List<String> = emptyList(),
|
||||||
override val preferredStreamLanguage: 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(),
|
val httpDataSourceFactory: HttpDataSource.Factory = DefaultHttpDataSource.Factory(),
|
||||||
) : NewPlayer {
|
) : NewPlayer {
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ class NewPlayerImpl(
|
||||||
playMode,
|
playMode,
|
||||||
availableStreamVariants,
|
availableStreamVariants,
|
||||||
preferredVideoVariants,
|
preferredVideoVariants,
|
||||||
prefearedAudioVariants,
|
preferredAudioVariants,
|
||||||
preferredStreamLanguage
|
preferredStreamLanguage
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ data class VideoPlayerUIState(
|
||||||
val isLoading: Boolean,
|
val isLoading: Boolean,
|
||||||
val durationInMs: Long,
|
val durationInMs: Long,
|
||||||
val playbackPositionInMs: Long,
|
val playbackPositionInMs: Long,
|
||||||
val playbackPositionInPlaylistS: Int,
|
val playbackPositionInPlaylistMs: Long,
|
||||||
val fastSeekSeconds: Int,
|
val fastSeekSeconds: Int,
|
||||||
val soundVolume: Float,
|
val soundVolume: Float,
|
||||||
val brightness: Float?, // when null use system value
|
val brightness: Float?, // when null use system value
|
||||||
|
@ -87,7 +87,7 @@ data class VideoPlayerUIState(
|
||||||
bufferedPercentage = 0f,
|
bufferedPercentage = 0f,
|
||||||
isLoading = true,
|
isLoading = true,
|
||||||
durationInMs = 0,
|
durationInMs = 0,
|
||||||
playbackPositionInPlaylistS = 0,
|
playbackPositionInPlaylistMs = 0,
|
||||||
playbackPositionInMs = 0,
|
playbackPositionInMs = 0,
|
||||||
fastSeekSeconds = 0,
|
fastSeekSeconds = 0,
|
||||||
soundVolume = 0f,
|
soundVolume = 0f,
|
||||||
|
@ -109,7 +109,7 @@ data class VideoPlayerUIState(
|
||||||
bufferedPercentage = 0.5f,
|
bufferedPercentage = 0.5f,
|
||||||
isLoading = false,
|
isLoading = false,
|
||||||
durationInMs = 12000,
|
durationInMs = 12000,
|
||||||
playbackPositionInPlaylistS = 5039,
|
playbackPositionInPlaylistMs = 5039,
|
||||||
playbackPositionInMs = 400,
|
playbackPositionInMs = 400,
|
||||||
fastSeekSeconds = 10,
|
fastSeekSeconds = 10,
|
||||||
soundVolume = 0.5f,
|
soundVolume = 0.5f,
|
||||||
|
|
|
@ -369,10 +369,10 @@ class VideoPlayerViewModelImpl @Inject constructor(
|
||||||
progress += item.mediaMetadata.durationMs
|
progress += item.mediaMetadata.durationMs
|
||||||
?: throw NewPlayerException("Media Item not containing duration. Media Item in question: ${item.mediaMetadata.title}")
|
?: 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 {
|
mutableUiState.update {
|
||||||
it.copy(
|
it.copy(
|
||||||
playbackPositionInPlaylistS = progress.toInt()
|
playbackPositionInPlaylistMs = progress
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ fun StreamSelectTopBar(
|
||||||
val duration = getPlaylistDurationInMS(uiState.playList)
|
val duration = getPlaylistDurationInMS(uiState.playList)
|
||||||
val durationString = getTimeStringFromMs(timeSpanInMs = duration, locale)
|
val durationString = getTimeStringFromMs(timeSpanInMs = duration, locale)
|
||||||
val playbackPositionString = getTimeStringFromMs(
|
val playbackPositionString = getTimeStringFromMs(
|
||||||
timeSpanInMs = uiState.playbackPositionInPlaylistS.toLong() * 1000, locale = locale
|
timeSpanInMs = uiState.playbackPositionInPlaylistMs, locale = locale
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = "$playbackPositionString/$durationString",
|
text = "$playbackPositionString/$durationString",
|
||||||
|
|
Loading…
Reference in New Issue