diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index e40b8d63..89a8e8f9 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -3,7 +3,7 @@ plugins { id("org.jetbrains.kotlin.plugin.compose") } /** The release's build number: versionCode is this x 10 plus the edition's channel. */ -val ORBIT_BUILD = 61 +val ORBIT_BUILD = 62 android { namespace = "tv.orbit.classic" compileSdk = 36 diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt b/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt index af7c44ff..8b15fdc1 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyConnectionScreen.kt @@ -241,12 +241,13 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea val observer = LifecycleEventObserver { _, event -> if (event == Lifecycle.Event.ON_STOP) { clearPassword(); job?.cancel(); watchingChannel = false; busy = false + liveHandoff.dropReturned() if (session == null && !restoring) sessionSlot.clear()?.let { active -> EmbyCleanup.run { active.close() } } } } lifecycle.addObserver(observer) onDispose { - clearPassword(); job?.cancel(); lifecycle.removeObserver(observer) + clearPassword(); job?.cancel(); lifecycle.removeObserver(observer); liveHandoff.dropReturned() sessionSlot.clear()?.let { active -> EmbyCleanup.run { active.detach() } } } } diff --git a/android/app/src/main/java/tv/orbit/classic/GuidePicture.kt b/android/app/src/main/java/tv/orbit/classic/GuidePicture.kt index 449d4390..fdde4e40 100644 --- a/android/app/src/main/java/tv/orbit/classic/GuidePicture.kt +++ b/android/app/src/main/java/tv/orbit/classic/GuidePicture.kt @@ -50,8 +50,33 @@ internal class LiveHandoff { fun take(): LiveStream? = handed.also { handed = null } /** Left by the full-screen player on the way out, for the picture to carry on with. */ var returned: LiveStream? = null + private var returnedSession: EmbySampleSession? = null + + /** + * Full screen gives its stream back for the picture. One the picture doesn't take within a few seconds (Home pressed + * straight after Back, or the picture resting) is closed, and so is one still waiting when Orbit leaves the screen, so it + * never plays on unseen (Paul, 18 November 2026: Sleepaway Camp played on behind the home screen, under the next channel). + */ + fun giveBack(stream: LiveStream, session: EmbySampleSession) { + dropReturned() + returned = stream; returnedSession = session + android.os.Handler(android.os.Looper.getMainLooper()).postDelayed({ + if (returned === stream) { android.util.Log.i("OrbitSchedule", "picture back channel=${stream.channelNumber} untaken=true"); dropReturned() } + }, RETURN_TAKE_MS) + } + + /** Closes a given-back stream nobody took. */ + fun dropReturned() { + val stream = returned ?: return + returned = null + returnedSession?.let { stream.discard(it) } + returnedSession = null + } } +/** How long a stream given back by full screen waits for the picture to take it. */ +internal const val RETURN_TAKE_MS = 4_000L + private fun closeLiveStream(session: EmbySampleSession, plan: EmbyPlaybackPlan, player: ExoPlayer) { val position = player.currentPosition player.release() diff --git a/android/app/src/main/java/tv/orbit/classic/SampleChannelScreens.kt b/android/app/src/main/java/tv/orbit/classic/SampleChannelScreens.kt index bb89bf82..1c4b442d 100644 --- a/android/app/src/main/java/tv/orbit/classic/SampleChannelScreens.kt +++ b/android/app/src/main/java/tv/orbit/classic/SampleChannelScreens.kt @@ -219,7 +219,7 @@ internal fun ScheduledChannelPlayer(session: EmbySampleSession, channel: SampleC // The ident itself is drawn below, over the whole window. This only quietens the programme under it. ident = if (phase == IdentPhase.Showing) { {} } else null, intro = introPlayback, announce = announce, onUnplayable = onUnplayable, audioPreference = audioPreference, onHandBack = { running -> - if (handoff != null && clockOffsetMs == 0L) { handoff.returned = LiveStream(channel.number, current.startMs, plan, running); true } else false + if (handoff != null && clockOffsetMs == 0L) { handoff.giveBack(LiveStream(channel.number, current.startMs, plan, running), session); true } else false }, window = window, onShift = onShift, onLive = onLive, holdStart = !catchUpIdentDone, squeeze = squeeze, onFirstFrame = { if (heldIdent?.startMs == current.startMs) heldIdent = null; catchUpPicture = true },