Skip to content

StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.

Merge origin/master into feature/realtime-translation

a1fbec2cb540c
diff --cc app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt
index eaf05303,eabfe913..b4d16346
--- a/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/player/PlayerViewModel.kt
@@@ -101,7 -102,8 +103,8 @@@ class PlayerViewModel @Inject construct
internal val seekThumbnailProvider: SeekThumbnailProvider,
internal val livePreviewHandoffManager: LivePreviewHandoffManager,
internal val syncManager: SyncManager,
+ private val downloadManager: DownloadManager,
- private val okHttpClient: OkHttpClient,
+ internal val okHttpClient: OkHttpClient,
) : ViewModel() {
companion object {
private const val TAG = "PlayerViewModel"
@@@ -341,11 -358,9 +359,14 @@@
internal var playbackTimerDefaultsApplied = false
internal var sleepTimerExitEmitted = false
internal var activeStalkerPlaybackProviderId: Long? = null
+ internal val _liveTranslationEnabled = MutableStateFlow(false)
+ val liveTranslationEnabled: StateFlow<Boolean> = _liveTranslationEnabled.asStateFlow()
+ internal val _liveTranslationDetectedLanguage = MutableStateFlow<String?>(null)
+ val liveTranslationDetectedLanguage: StateFlow<String?> = _liveTranslationDetectedLanguage.asStateFlow()
+ internal var liveTranslationSession: LiveTranslationSession? = null
+ private var downloadPlaybackSlotActive = false
+ private var currentPlaybackUsesDownloadSlot = false
+ private var externalProviderPlaybackHold = false
val castConnectionState: StateFlow<CastConnectionState> = castManager.connectionState
@@@ -923,10 -984,12 +996,13 @@@
internal fun beginPlaybackSession(): Long {
recoveryJob?.cancel()
thumbnailPreloadJob?.cancel()
+ stopLiveTranslationSession(clearEnabledState = false)
hasRetriedXtreamAuthRefresh = false
lastRecordedVariantObservationSignature = null
+ livePlaybackReadyForCurrentSession = false
readySideEffectsRequestVersion = null
+ currentResolvedPlaybackUrl = ""
+ currentResolvedStreamInfo = null
playerEngine.setScrubbingMode(false)
return ++prepareRequestVersion
}
@@@ -1147,7 -1250,59 +1263,60 @@@
requestVersion: Long,
probeBeforePlayback: Boolean = true
): Boolean {
+ val preparedStreamInfo = prepareStreamInfoForPlayback(
+ streamInfo = streamInfo,
+ requestVersion = requestVersion,
+ probeBeforePlayback = probeBeforePlayback
+ ) ?: return false
+
+ applyPlaybackPreferences()
+ if (!isActivePlaybackSession(requestVersion)) return false
+ currentResolvedPlaybackUrl = preparedStreamInfo.url
+ currentResolvedStreamInfo = preparedStreamInfo
+ readySideEffectsRequestVersion = requestVersion
+ playerEngine.prepare(preparedStreamInfo)
++ evaluateLiveTranslationSession()
+ startTokenRenewalMonitoring(preparedStreamInfo.expirationTime)
+ maybeStartLiveTimeshift(preparedStreamInfo)
+ return true
+ }
+
+ internal suspend fun prepareExternalPlaybackUrl(
+ streamInfo: com.streamvault.domain.model.StreamInfo,
+ requestVersion: Long,
+ probeBeforePlayback: Boolean = true
+ ): Boolean {
+ val preparedStreamInfo = prepareStreamInfoForPlayback(
+ streamInfo = streamInfo,
+ requestVersion = requestVersion,
+ probeBeforePlayback = probeBeforePlayback
+ ) ?: return false
+
if (!isActivePlaybackSession(requestVersion)) return false
+ currentResolvedPlaybackUrl = preparedStreamInfo.url
+ currentResolvedStreamInfo = preparedStreamInfo
+ readySideEffectsRequestVersion = requestVersion
+ playerEngine.stopLiveTimeshift()
+ playerEngine.stop()
+ return true
+ }
+
+ fun playResolvedStreamInternally() {
+ val streamInfo = currentResolvedStreamInfo ?: return
+ viewModelScope.launch {
+ applyPlaybackPreferences()
+ playerEngine.prepare(streamInfo)
+ startTokenRenewalMonitoring(streamInfo.expirationTime)
+ maybeStartLiveTimeshift(streamInfo)
+ }
+ }
+
+ private suspend fun prepareStreamInfoForPlayback(
+ streamInfo: com.streamvault.domain.model.StreamInfo,
+ requestVersion: Long,
+ probeBeforePlayback: Boolean
+ ): com.streamvault.domain.model.StreamInfo? {
+ if (!isActivePlaybackSession(requestVersion)) return null
// Fast-path expiry check: if the stream URL already carries an expiration timestamp
// that is in the past, skip the network probe entirely and surface a clear message.
diff --cc app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPlaybackSection.kt
index 52dbd7e0,60d57414..e70552a4
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPlaybackSection.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPlaybackSection.kt
@@@ -141,34 -141,34 +143,62 @@@ internal fun LazyListScope.settingsPlay
}
}
HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
+ TvClickableSurface(
+ onClick = {
+ viewModel.setPlayerFastRetryOnTransientFailures(!uiState.playerFastRetryOnTransientFailures)
+ },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_fast_retry_on_transient_failures), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_fast_retry_on_transient_failures_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Switch(
+ checked = uiState.playerFastRetryOnTransientFailures,
+ onCheckedChange = { viewModel.setPlayerFastRetryOnTransientFailures(it) }
+ )
+ }
+ }
+ HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
+ TvClickableSurface(
+ onClick = { viewModel.setPlayerLiveTranslationEnabled(!uiState.playerLiveTranslationEnabled) },
+ shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
+ colors = ClickableSurfaceDefaults.colors(
+ containerColor = Color.Transparent,
+ focusedContainerColor = Primary.copy(alpha = 0.15f)
+ ),
+ scale = ClickableSurfaceDefaults.scale(focusedScale = 1f),
+ modifier = Modifier.fillMaxWidth()
+ ) {
+ Row(
+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 12.dp),
+ horizontalArrangement = Arrangement.SpaceBetween,
+ verticalAlignment = Alignment.CenterVertically
+ ) {
+ Column(modifier = Modifier.weight(1f)) {
+ Text(text = stringResource(R.string.settings_live_translation_enabled), style = MaterialTheme.typography.bodyMedium, color = OnSurface)
+ Text(text = stringResource(R.string.settings_live_translation_enabled_subtitle), style = MaterialTheme.typography.bodySmall, color = OnBackground.copy(alpha = 0.6f))
+ }
+ Switch(checked = uiState.playerLiveTranslationEnabled, onCheckedChange = { viewModel.setPlayerLiveTranslationEnabled(it) })
+ }
+ }
+ ClickableSettingsRow(
+ label = stringResource(R.string.settings_live_translation_endpoint),
+ value = liveTranslationEndpointLabel,
+ onClick = { onShowLiveTranslationEndpointDialogChange(true) }
+ )
+ HorizontalDivider(color = Color.White.copy(alpha = 0.07f), modifier = Modifier.padding(vertical = 4.dp))
TvClickableSurface(
onClick = { viewModel.setPlayerTimeshiftEnabled(!uiState.playerTimeshiftEnabled) },
shape = ClickableSurfaceDefaults.shape(RoundedCornerShape(8.dp)),
diff --cc app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceDialogs.kt
index 24437bba,704bcf8e..f6dd9cd2
--- a/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceDialogs.kt
+++ b/app/src/main/java/com/streamvault/app/ui/screens/settings/SettingsPreferenceDialogs.kt
@@@ -98,11 -102,28 +104,30 @@@ internal fun SettingsPreferenceDialogs
showNoticeTimeoutDialog = showNoticeTimeoutDialog,
onShowNoticeTimeoutDialogChange = onShowNoticeTimeoutDialogChange,
showDiagnosticsTimeoutDialog = showDiagnosticsTimeoutDialog,
- onShowDiagnosticsTimeoutDialogChange = onShowDiagnosticsTimeoutDialogChange
+ onShowDiagnosticsTimeoutDialogChange = onShowDiagnosticsTimeoutDialogChange,
+ showLiveTranslationEndpointDialog = showLiveTranslationEndpointDialog,
+ onShowLiveTranslationEndpointDialogChange = onShowLiveTranslationEndpointDialogChange
)
+ if (showLandingScreenDialog) {
+ PremiumSelectionDialog(
+ title = stringResource(R.string.settings_select_default_landing_screen),
+ onDismiss = { onShowLandingScreenDialogChange(false) }
+ ) {
+ AppLandingDestination.entries.forEachIndexed { index, destination ->
+ LevelOption(
+ level = index,
+ text = stringResource(destination.labelResId()),
+ currentLevel = if (uiState.appLandingDestination == destination) index else -1,
+ onSelect = {
+ viewModel.setAppLandingDestination(destination)
+ onShowLandingScreenDialogChange(false)
+ }
+ )
+ }
+ }
+ }
+
if (showGuideDefaultCategoryDialog) {
PremiumSelectionDialog(
title = stringResource(R.string.settings_select_guide_default_category),
diff --cc app/src/main/res/values/strings.xml
index b08191f7,4a99619b..c2ae428c
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@@ -402,13 -410,10 +410,15 @@@
<string name="settings_multiview_center_two_slot_layout_subtitle">When one or two multiview slots are active, center them on screen instead of using the default 2x2 grid.</string>
<string name="settings_media_session">System Media Session</string>
<string name="settings_media_session_subtitle">Expose playback to Android system media controls. Disable this if playback crashes on a specific device when opening the player.</string>
+ <string name="settings_fast_retry_on_transient_failures" translatable="false">Fast retry on transient failures</string>
+ <string name="settings_fast_retry_on_transient_failures_subtitle" translatable="false">Use 500 ms retries for live playback failures instead of exponential backoff.</string>
<string name="settings_live_timeshift">Enable Local Live Rewind</string>
<string name="settings_live_timeshift_subtitle">Keep a temporary local buffer for pausing and rewinding live TV even when the provider has no catch-up support.</string>
+ <string name="settings_live_translation_enabled">Enable Live Translation Subtitles</string>
+ <string name="settings_live_translation_enabled_subtitle">Translate spoken live-channel audio into English subtitles using your local Whisper service.</string>
+ <string name="settings_live_translation_endpoint">Live Translation Service Endpoint</string>
+ <string name="settings_live_translation_endpoint_subtitle">Base URL for the local translation service (emulator default: http://10.0.2.2:8765).</string>
+ <string name="settings_live_translation_endpoint_empty_error">Live translation endpoint cannot be empty.</string>
<string name="settings_live_timeshift_depth">Local Live Rewind Depth</string>
<string name="settings_live_timeshift_backend">Live Rewind Backend</string>
<string name="settings_live_timeshift_backend_value">Automatic</string>