StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
perf: isolate remaining player content state
David Nashash4635fbc60b8f
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerControlsOverlayHost.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerControlsOverlayHost.ktindex 973e6937..3fe2f782 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerControlsOverlayHost.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerControlsOverlayHost.kt@@ -33,7 +33,6 @@ import com.streamvault.app.ui.screens.player.overlay.PlayerControlsOverlayimport com.streamvault.app.ui.screens.player.overlay.PlayerResolutionBadgeimport com.streamvault.app.ui.screens.player.overlay.PlayerSleepTimerWarningOverlayimport com.streamvault.domain.model.Channel-import com.streamvault.domain.model.Programimport com.streamvault.domain.model.RecordingStatusimport com.streamvault.domain.model.VideoFormatimport com.streamvault.player.PLAYER_TRACK_AUTO_ID@@ -56,7 +55,6 @@ internal fun PlayerControlsOverlayHost(modifier: Modifier = Modifier,isCatchUpPlayback: Boolean = false,isPlaying: Boolean,- currentProgram: Program?,currentChannel: Channel?,currentChannelName: String?,displayChannelNumber: Int,@@ -71,7 +69,6 @@ internal fun PlayerControlsOverlayHost(onOpenStopPlaybackTimer: () -> Unit,onOpenIdleStandbyTimer: () -> Unit,onOpenAudioVideoSync: () -> Unit,- showEpisodesAction: Boolean,onOpenEpisodes: () -> Unit,onOpenSplitScreen: () -> Unit,onEnterPictureInPicture: () -> Unit,@@ -80,6 +77,9 @@ internal fun PlayerControlsOverlayHost() {val currentPosition by playerEngine.currentPosition.collectAsStateWithLifecycle()val duration by playerEngine.duration.collectAsStateWithLifecycle()+ val currentProgram by viewModel.currentProgram.collectAsStateWithLifecycle()+ val playbackTitle by viewModel.playbackTitle.collectAsStateWithLifecycle()+ val currentSeries by viewModel.currentSeries.collectAsStateWithLifecycle()val availableAudioTracks by viewModel.availableAudioTracks.collectAsStateWithLifecycle()val availableSubtitleTracks by viewModel.availableSubtitleTracks.collectAsStateWithLifecycle()val availableVideoQualities by viewModel.availableVideoQualities.collectAsStateWithLifecycle()@@ -93,10 +93,15 @@ internal fun PlayerControlsOverlayHost(val seekPreview by viewModel.seekPreview.collectAsStateWithLifecycle()val timeshiftUiState by viewModel.timeshiftUiState.collectAsStateWithLifecycle()val sleepTimerUiState by viewModel.sleepTimerUiState.collectAsStateWithLifecycle()+ val currentSeriesSeasons = remember(currentSeries) {+ currentSeries?.seasons.sanitizedForPlayer()+ }+ val canOpenEpisodePicker = contentType == "SERIES_EPISODE" &&+ currentSeriesSeasons?.any { it.episodes.isNotEmpty() } == truePlayerControlsOverlay(visible = visible,- title = title,+ title = playbackTitle.ifBlank { title },contentType = contentType,isCatchUpPlayback = isCatchUpPlayback,isPlaying = isPlaying,@@ -140,7 +145,7 @@ internal fun PlayerControlsOverlayHost(onOpenIdleStandbyTimer = onOpenIdleStandbyTimer,onOpenAudioVideoSync = onOpenAudioVideoSync,audioVideoSyncEnabled = audioVideoSyncEnabled,- showEpisodesAction = showEpisodesAction,+ showEpisodesAction = canOpenEpisodePicker,onOpenEpisodes = onOpenEpisodes,onOpenSplitScreen = onOpenSplitScreen,onEnterPictureInPicture = onEnterPictureInPicture,diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerLiveOverlayHost.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerLiveOverlayHost.ktindex f3bbe7a1..df99df90 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerLiveOverlayHost.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerLiveOverlayHost.kt@@ -60,8 +60,6 @@ internal fun BoxScope.PlayerLiveOverlayHost(currentChannel: Channel?,internalChannelId: Long,displayChannelNumber: Int,- currentProgram: Program?,- nextProgram: Program?,channelListFocusRequester: FocusRequester,categoryListFocusRequester: FocusRequester,channelInfoFocusRequester: FocusRequester,@@ -81,6 +79,8 @@ internal fun BoxScope.PlayerLiveOverlayHost(val currentChannelList by viewModel.currentChannelList.collectAsStateWithLifecycle()val recentChannels by viewModel.recentChannels.collectAsStateWithLifecycle()val lastVisitedCategory by viewModel.lastVisitedCategory.collectAsStateWithLifecycle()+ val currentProgram by viewModel.currentProgram.collectAsStateWithLifecycle()+ val nextProgram by viewModel.nextProgram.collectAsStateWithLifecycle()val upcomingPrograms by viewModel.upcomingPrograms.collectAsStateWithLifecycle()AnimatedVisibility(diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerModalHosts.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerModalHosts.ktindex 35537954..8fe0f510 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerModalHosts.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerModalHosts.kt@@ -1,6 +1,7 @@package com.streamvault.app.ui.screens.playerimport androidx.compose.runtime.Composable+import androidx.compose.runtime.rememberimport androidx.compose.runtime.LaunchedEffectimport androidx.compose.runtime.getValueimport androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel@@ -19,14 +20,13 @@ import com.streamvault.app.ui.screens.player.overlay.PlayerTrackSelectionDialogimport com.streamvault.domain.model.Channelimport com.streamvault.domain.model.Episodeimport com.streamvault.domain.model.Program-import com.streamvault.domain.model.Seasonimport com.streamvault.player.TrackType@Composableinternal fun PlayerTopLevelModalHost(+ viewModel: PlayerViewModel,isInPictureInPictureMode: Boolean,showProgramHistory: Boolean,- programHistory: List<Program>,onDismissProgramHistory: () -> Unit,onSelectProgramHistory: (Program) -> Unit,showSplitDialog: Boolean,@@ -35,6 +35,7 @@ internal fun PlayerTopLevelModalHost(onLaunchMultiView: () -> Unit,) {if (!isInPictureInPictureMode && showProgramHistory) {+ val programHistory by viewModel.programHistory.collectAsStateWithLifecycle()ProgramHistoryDialog(programs = programHistory,onDismiss = onDismissProgramHistory,@@ -66,10 +67,9 @@ internal fun PlayerControlsModalHost(canSaveChannel: Boolean,showAudioVideoOffsetDialog: Boolean,showEpisodePicker: Boolean,- seriesTitle: String,- seasons: List<Season>,- currentEpisodeId: Long,- currentSeasonNumber: Int?,+ fallbackTitle: String,+ fallbackEpisodeId: Long,+ fallbackSeasonNumber: Int?,onDismissModal: () -> Unit,) {if (showAudioVideoOffsetDialog) {@@ -172,12 +172,18 @@ internal fun PlayerControlsModalHost()}if (!isInPictureInPictureMode && showEpisodePicker) {+ val playbackTitle by viewModel.playbackTitle.collectAsStateWithLifecycle()+ val currentSeries by viewModel.currentSeries.collectAsStateWithLifecycle()+ val currentEpisode by viewModel.currentEpisode.collectAsStateWithLifecycle()+ val seasons = remember(currentSeries) {+ currentSeries?.seasons.sanitizedForPlayer().orEmpty()+ }PlayerEpisodeSelectionDialog(visible = true,- seriesTitle = seriesTitle,+ seriesTitle = currentSeries?.name ?: playbackTitle.ifBlank { fallbackTitle },seasons = seasons,- currentEpisodeId = currentEpisodeId,- currentSeasonNumber = currentSeasonNumber,+ currentEpisodeId = currentEpisode?.id ?: fallbackEpisodeId,+ currentSeasonNumber = currentEpisode?.seasonNumber ?: fallbackSeasonNumber,onDismiss = onDismissModal,onSelectEpisode = { episode ->onDismissModal()diff --git a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerScreen.kt b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerScreen.ktindex 5591025b..178fb6f7 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerScreen.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerScreen.kt@@ -47,7 +47,6 @@ import com.streamvault.domain.model.Channelimport com.streamvault.domain.model.DecoderModeimport com.streamvault.domain.model.StreamInfoimport com.streamvault.domain.model.VideoFormat-import com.streamvault.domain.model.Programimport com.streamvault.domain.repository.EpgRepositoryimport com.streamvault.player.PlaybackStateimport com.streamvault.player.PLAYER_TRACK_AUTO_ID@@ -156,20 +155,9 @@ fun PlayerScreen(val videoFormat by viewModel.videoFormat.collectAsStateWithLifecycle()val playerError by viewModel.playerError.collectAsStateWithLifecycle()val playbackResolutionUiState by viewModel.playbackResolutionUiState.collectAsStateWithLifecycle()- val currentProgram by viewModel.currentProgram.collectAsStateWithLifecycle()- val nextProgram by viewModel.nextProgram.collectAsStateWithLifecycle()- val programHistory by viewModel.programHistory.collectAsStateWithLifecycle()val currentChannel by viewModel.currentChannel.collectAsStateWithLifecycle()- val currentSeries by viewModel.currentSeries.collectAsStateWithLifecycle()- val currentEpisode by viewModel.currentEpisode.collectAsStateWithLifecycle()val autoPlayCountdown by viewModel.autoPlayCountdown.collectAsStateWithLifecycle()- val playbackTitle by viewModel.playbackTitle.collectAsStateWithLifecycle()val resumePrompt by viewModel.resumePrompt.collectAsStateWithLifecycle()- val currentSeriesSeasons = remember(currentSeries) {- currentSeries?.seasons.sanitizedForPlayer()- }- val canOpenEpisodePicker = contentType == "SERIES_EPISODE" &&- currentSeriesSeasons?.any { it.episodes.isNotEmpty() } == trueval isCatchUpPlayback by viewModel.isCatchUpPlayback.collectAsStateWithLifecycle()val showChannelListOverlay by viewModel.showChannelListOverlay.collectAsStateWithLifecycle()@@ -270,9 +258,9 @@ fun PlayerScreen(}PlayerTopLevelModalHost(+ viewModel = viewModel,isInPictureInPictureMode = isInPictureInPictureMode,showProgramHistory = modalState.showProgramHistory,- programHistory = programHistory,onDismissProgramHistory = { modalState = modalState.dismiss() },onSelectProgramHistory = { program ->viewModel.playCatchUp(program)@@ -449,7 +437,9 @@ fun PlayerScreen(showEpisodePicker = modalState.showEpisodePicker,showControls = showControls,hasPendingNumericChannelInput = viewModel.hasPendingNumericChannelInput(),- canOpenEpisodePicker = canOpenEpisodePicker+ canOpenEpisodePicker = contentType == "SERIES_EPISODE" &&+ viewModel.currentSeries.value?.seasons.sanitizedForPlayer()+ ?.any { it.episodes.isNotEmpty() } == true)}@@ -716,11 +706,10 @@ fun PlayerScreen(playerEngine = playerEngine,viewModel = viewModel,visible = showControls,- title = playbackTitle.ifBlank { title },+ title = title,contentType = contentType,isCatchUpPlayback = isCatchUpPlayback,isPlaying = isPlaying,- currentProgram = currentProgram,currentChannel = currentChannel,currentChannelName = currentChannel?.name,displayChannelNumber = displayChannelNumber,@@ -736,7 +725,6 @@ fun PlayerScreen(onOpenStopPlaybackTimer = { modalState = modalState.open(PlayerModal.StopPlaybackTimer) },onOpenIdleStandbyTimer = { modalState = modalState.open(PlayerModal.IdleStandbyTimer) },onOpenAudioVideoSync = { modalState = modalState.open(PlayerModal.AudioVideoOffset) },- showEpisodesAction = canOpenEpisodePicker,onOpenEpisodes = { modalState = modalState.open(PlayerModal.EpisodePicker) },onOpenSplitScreen = { modalState = modalState.open(PlayerModal.Split) },onEnterPictureInPicture = enterPictureInPicture,@@ -816,10 +804,9 @@ fun PlayerScreen(canSaveChannel = currentChannel != null,showAudioVideoOffsetDialog = modalState.showAudioVideoOffsetDialog,showEpisodePicker = modalState.showEpisodePicker,- seriesTitle = currentSeries?.name ?: playbackTitle.ifBlank { title },- seasons = currentSeriesSeasons.orEmpty(),- currentEpisodeId = currentEpisode?.id ?: internalChannelId,- currentSeasonNumber = currentEpisode?.seasonNumber ?: seasonNumber,+ fallbackTitle = title,+ fallbackEpisodeId = internalChannelId,+ fallbackSeasonNumber = seasonNumber,onDismissModal = { modalState = modalState.dismiss() })@@ -843,8 +830,6 @@ fun PlayerScreen(currentChannel = currentChannel,internalChannelId = internalChannelId,displayChannelNumber = displayChannelNumber,- currentProgram = currentProgram,- nextProgram = nextProgram,channelListFocusRequester = channelListFocusRequester,categoryListFocusRequester = categoryListFocusRequester,channelInfoFocusRequester = channelInfoFocusRequester,diff --git a/docs/COMPOSE_REDUCTION_PHASE2_REPORT.md b/docs/COMPOSE_REDUCTION_PHASE2_REPORT.mdindex 4936177c..43b11e07 100644--- a/docs/COMPOSE_REDUCTION_PHASE2_REPORT.md+++ b/docs/COMPOSE_REDUCTION_PHASE2_REPORT.md@@ -25,7 +25,11 @@ request to annotate unstable domain models or to rewrite the UI in Views.- live channel, category, EPG, numeric-input, and channel-info state in`PlayerLiveOverlayHost`;- track, speed, timer, offset, and related dialog state in- `PlayerModalHosts`.+ `PlayerModalHosts`;+ - program-history state is collected only while the top-level history modal+ is visible;+ - current and next program state is collected by the controls and live+ overlay hosts that render it.- Preserved the two modal-host placement boundaries: top-level modal contentremains before player preparation, and controls modal content remains insidethe player surface layer after the resume prompt.@@ -131,6 +135,10 @@ The required Phase 2 live-TV validation passed on the connected emulator. Eachchannel was opened in the full player and captured at a two-second cadence for61 screenshots (roughly two minutes):+The same protocol was rerun after the follow-up player state-isolation slice;+the post-change captures are prefixed `post_` in `validation/phase2_live/` and+produced the same passing results below.+| Channel | Screenshots | Unique hashes | Final media session | Healthy log evidence | Error/fallback evidence || --- | ---: | ---: | --- | --- | --- || 00s Replay | 61 | 61 | `PLAYING`, `error=null` | HLS prepare and first-frame success | No fatal error, stuck timeout, or MPEG-TS fallback |