diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackDialog.kt b/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackDialog.kt index f1a99a44..8354d7e2 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackDialog.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyPlaybackDialog.kt @@ -106,6 +106,8 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl var okHeld by remember { mutableStateOf(false) } var subtitleIndex by remember { mutableStateOf(null) } var trackMenu by remember { mutableStateOf?>(null) } + // Subtitle size and background for whoever's watching (SubtitleStyle). + var subtitleStyle by remember { mutableStateOf(SubtitleStyle.get(context, Profiles.current?.id)) } var trackCursor by remember { mutableIntStateOf(0) } // The key listener is made once, so it reads these as they are now. val currentScheduled by rememberUpdatedState(scheduled) @@ -141,6 +143,10 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl audioChosen = true } fun trackRows(): List { + val (subSize, subBox) = subtitleStyle + val styleRows = if (textTracks().isEmpty()) emptyList() else + SubtitleStyle.sizes.mapIndexed { i, (label, _) -> TrackRow("Subtitle size", label, subSize == i) { subtitleStyle = i to subBox; SubtitleStyle.set(context, Profiles.current?.id, i, subBox) } } + + listOf("Shadow" to false, "Box" to true).map { (label, box) -> TrackRow("Subtitle background", label, subBox == box) { subtitleStyle = subSize to box; SubtitleStyle.set(context, Profiles.current?.id, subSize, box) } } val subtitles = textTracks() val audio = player.currentTracks.groups.filter { it.type == C.TRACK_TYPE_AUDIO && it.isSupported } val subtitleRows = listOf(TrackRow("Subtitles", "Off", subtitles.none { it.isSelected }) { chooseSubtitle(null, subtitles); subtitlePreference?.value = SUBTITLES_OFF }) + @@ -159,7 +165,7 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl val left = if (on && choice != SleepChoice.Off) sleepLeft(SleepTimer.endsAt, System.currentTimeMillis())?.let { " ($it)" }.orEmpty() else "" TrackRow("Sleep timer", choice.label + left, on) { SleepTimer.set(choice, System.currentTimeMillis(), scheduled?.let { it.programme.endMs - it.clockOffsetMs }) } } - return subtitleRows + audioRows + sleepRows + return subtitleRows + styleRows + audioRows + sleepRows } fun submitNumber(entry: ChannelEntry) { if (onNumber(entry.number)) { numberEntry = null; numberProblem = null } @@ -545,7 +551,8 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl isFocusable = true; isFocusableInTouchMode = true post { requestFocus() } } - }, update = { it.player = player; it.subtitleView?.setBottomPaddingFraction(if (subtitlesLifted) .32f else androidx.media3.ui.SubtitleView.DEFAULT_BOTTOM_PADDING_FRACTION) }, onRelease = { it.player = null }) + }, update = { it.player = player; it.subtitleView?.setBottomPaddingFraction(if (subtitlesLifted) .32f else androidx.media3.ui.SubtitleView.DEFAULT_BOTTOM_PADDING_FRACTION) + it.subtitleView?.let { v -> SubtitleStyle.apply(v, subtitleStyle.first, subtitleStyle.second) } }, onRelease = { it.player = null }) if (scheduled != null && !ready && failure == null && foreground) ChannelTuningBackdrop(scheduled.channel.number) { ProgrammeArtwork(session, scheduled.channel, scheduled.programme) } if (scheduled?.catchingUp() == true && ready && failure == null) CatchUpBadge(Modifier.align(Alignment.TopStart).padding(top = 28.dp, start = 40.dp)) diff --git a/android/app/src/main/java/tv/orbit/classic/PlayerSwitches.kt b/android/app/src/main/java/tv/orbit/classic/PlayerSwitches.kt index 37bb289a..0ca33ffa 100644 --- a/android/app/src/main/java/tv/orbit/classic/PlayerSwitches.kt +++ b/android/app/src/main/java/tv/orbit/classic/PlayerSwitches.kt @@ -126,3 +126,26 @@ internal object EvenVolume { android.media.audiofx.DynamicsProcessing(0, audioSessionId, config) }.getOrNull() } + +/** + * Subtitle size and background, per profile (9 November 2026): chosen in the watching menu (press right), remembered for + * whoever's watching. Sizes scale Media3's default; the background is a soft shadow or a dark box behind the words. + */ +internal object SubtitleStyle { + val sizes = listOf("Small" to 0.8f, "Normal" to 1f, "Large" to 1.25f, "Extra large" to 1.5f) + private fun prefs(context: Context) = context.getSharedPreferences("orbit_settings", Context.MODE_PRIVATE) + private fun key(profile: String?) = "subtitle_style_" + (profile ?: "all").filter { it.isLetterOrDigit() }.take(40) + /** (size index, box) for [profile]: Normal with a shadow until chosen. */ + fun get(context: Context, profile: String?): Pair = prefs(context).getString(key(profile), null)?.split(',') + ?.let { (it.getOrNull(0)?.toIntOrNull()?.coerceIn(sizes.indices) ?: 1) to (it.getOrNull(1) == "box") } ?: (1 to false) + fun set(context: Context, profile: String?, size: Int, box: Boolean) { prefs(context).edit().putString(key(profile), "${size.coerceIn(sizes.indices)},${if (box) "box" else "shadow"}").apply() } + + @androidx.annotation.OptIn(androidx.media3.common.util.UnstableApi::class) + fun apply(view: androidx.media3.ui.SubtitleView, size: Int, box: Boolean) { + view.setApplyEmbeddedFontSizes(false) + view.setFractionalTextSize(androidx.media3.ui.SubtitleView.DEFAULT_TEXT_SIZE_FRACTION * sizes[size.coerceIn(sizes.indices)].second) + view.setStyle(androidx.media3.ui.CaptionStyleCompat(android.graphics.Color.WHITE, if (box) 0xCC000000.toInt() else android.graphics.Color.TRANSPARENT, + android.graphics.Color.TRANSPARENT, if (box) androidx.media3.ui.CaptionStyleCompat.EDGE_TYPE_NONE else androidx.media3.ui.CaptionStyleCompat.EDGE_TYPE_DROP_SHADOW, + android.graphics.Color.BLACK, null)) + } +}