diff --git a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/controller/TopUI.kt b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/controller/TopUI.kt index c9971c38..5a75e097 100644 --- a/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/controller/TopUI.kt +++ b/new-player/src/main/java/net/newpipe/newplayer/ui/videoplayer/controller/TopUI.kt @@ -161,14 +161,16 @@ private fun TrackSelectionMenu(viewModel: InternalNewPlayerViewModel, uiState: N } val context = LocalContext.current - val noOtherTracksText = stringResource( - id = R.string.no_other_tracks_available_toast - ) + val availableVideoTracks = uiState.currentlyAvailableTracks.filterIsInstance() Box { + val noOtherTracksText = stringResource( + id = R.string.no_other_tracks_available_toast + ) + Button( onClick = { if (1 < availableVideoTracks.size) { @@ -188,7 +190,14 @@ private fun TrackSelectionMenu(viewModel: InternalNewPlayerViewModel, uiState: N ), ) { Text( - "1080p", fontWeight = FontWeight.Bold, modifier = Modifier.padding(0.dp) + try { + uiState.currentlyPlayingTracks.filterIsInstance()[0] + .toShortIdentifierString() + } catch (_: IndexOutOfBoundsException) { + stringResource(R.string.loading) + }, + fontWeight = FontWeight.Bold, + modifier = Modifier.padding(0.dp) ) } DropdownMenu(expanded = menuVisible, onDismissRequest = { menuVisible = false }) { diff --git a/new-player/src/main/java/net/newpipe/newplayer/uiModel/NewPlayerUIState.kt b/new-player/src/main/java/net/newpipe/newplayer/uiModel/NewPlayerUIState.kt index 64e91236..648fad9d 100644 --- a/new-player/src/main/java/net/newpipe/newplayer/uiModel/NewPlayerUIState.kt +++ b/new-player/src/main/java/net/newpipe/newplayer/uiModel/NewPlayerUIState.kt @@ -57,6 +57,7 @@ data class NewPlayerUIState( val currentlyPlaying: MediaItem?, val currentPlaylistItemIndex: Int, val currentlyAvailableTracks: List, + val currentlyPlayingTracks: List, val enteringPip: Boolean, val currentSeekPreviewThumbnail: ImageBitmap?, val seekPreviewVisible: Boolean, @@ -86,6 +87,7 @@ data class NewPlayerUIState( currentlyPlaying = null, currentPlaylistItemIndex = 0, currentlyAvailableTracks = emptyList(), + currentlyPlayingTracks = emptyList(), enteringPip = false, currentSeekPreviewThumbnail = null, seekPreviewVisible = false, @@ -99,6 +101,10 @@ data class NewPlayerUIState( AudioStreamTrack(bitrate = 49000, language = "en", fileFormat = "MP4A"), AudioStreamTrack(bitrate = 49000, language = "es", fileFormat = "MP4A") ), + currentlyPlayingTracks = listOf( + VideoStreamTrack(width= 1920, height = 1080, frameRate = 30, fileFormat = "MPEG4"), + AudioStreamTrack(bitrate = 49000, language = "es", fileFormat = "MP4A") + ), uiMode = UIModeState.EMBEDDED_VIDEO, playing = true, seekerPosition = 0.3f, diff --git a/new-player/src/main/java/net/newpipe/newplayer/uiModel/NewPlayerViewModelImpl.kt b/new-player/src/main/java/net/newpipe/newplayer/uiModel/NewPlayerViewModelImpl.kt index bd4edf79..26fa8821 100644 --- a/new-player/src/main/java/net/newpipe/newplayer/uiModel/NewPlayerViewModelImpl.kt +++ b/new-player/src/main/java/net/newpipe/newplayer/uiModel/NewPlayerViewModelImpl.kt @@ -254,6 +254,16 @@ class NewPlayerViewModelImpl @Inject constructor( } } + viewModelScope.launch { + newPlayer.currentlyPlayingTracks.collect { playingTracks -> + mutableUiState.update { + it.copy( + currentlyPlayingTracks = playingTracks + ) + } + } + } + mutableUiState.update { it.copy( playing = newPlayer.exoPlayer.value?.isPlaying ?: false, diff --git a/new-player/src/main/res/values/strings.xml b/new-player/src/main/res/values/strings.xml index bc8fb8d9..db18cf5c 100644 --- a/new-player/src/main/res/values/strings.xml +++ b/new-player/src/main/res/values/strings.xml @@ -63,4 +63,5 @@ Playing in the background… Video seek preview thumbnaila No other stream tracks available. + Loading \ No newline at end of file