Character cameos, phase 3: The Chase (0.108.67)

The first cameo, drawn with the cast along the bottom of a quiet changeover
frame in place of the ident, on Riot, ToonZ evenings and Nite Owl, when
Character cameos is on (still off by default). Ollie rolls through, Blaze
storms after him; then Luna peeks in, looks straight at you and rolls her
eyes (about one in three), or Drift floats in too late and looks both ways.
Played over the ident's own length; Reduce motion shows the payoff as a still.
Settings › On screen › See The Chase shows one over a plain frame.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-06 18:30:15 +00:00
co-authored by Claude Opus 5.5
parent 99fa3adfb8
commit b07e2b7876
11 changed files with 159 additions and 12 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ android {
applicationId = "tv.orbit.classic"
minSdk = 26
targetSdk = 36
versionCode = 226
versionName = "0.108.66-cameo-rules"
versionCode = 227
versionName = "0.108.67-the-chase"
}
buildFeatures { compose = true }
// The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so
@@ -287,7 +287,9 @@ internal fun starPath(centre: Offset, outer: Float, inner: Float, turn: Float) =
*/
internal fun DrawScope.drawOrbChaser(centre: Offset, r: Float, who: OrbCharacter, dir: OrbDir, scared: Boolean, returning: Boolean, blink: Boolean, wobble: Float,
/** Eyes closed for a blink: lines where the eyes are. */
eyesShut: Boolean = false) {
eyesShut: Boolean = false,
/** Where the pupils look, each axis -1 to 1, in place of [dir]: Offset.Zero looks straight out of the screen (the cameos). */
lookAt: Offset? = null) {
if (!returning) {
val body = if (scared) (if (blink) Color(0xFFE8F0FF) else Color(0xFF4D6BFF)) else who.colour
when (who) {
@@ -329,7 +331,7 @@ internal fun DrawScope.drawOrbChaser(centre: Offset, r: Float, who: OrbCharacter
return
}
}
val look = Offset(dir.dx * r * .14f, dir.dy * r * .14f)
val look = lookAt?.let { Offset(it.x * r * .14f, it.y * r * .14f) } ?: Offset(dir.dx * r * .14f, dir.dy * r * .14f)
for (side in listOf(-1f, 1f)) {
val eye = centre + Offset(side * r * .34f, -r * .1f)
if (eyesShut && !returning) { drawLine(Color(0xFF14213D), eye - Offset(r * .2f, 0f), eye + Offset(r * .2f, 0f), r * .08f, StrokeCap.Round); continue }
@@ -66,7 +66,9 @@ internal fun cameoGap(channel: Int, atMs: Long) = CAMEO_MIN_GAP_MS + (mix(channe
* Whether this changeover gets a cameo, and which. [on] is Character cameos with the cast switched on; [kids] a Kids
* profile watching. Asked again for the same changeover, it gives the same answer and records nothing more.
*/
internal fun chooseCameo(c: Changeover, diary: CameoDiary, on: Boolean, kids: Boolean, zone: ZoneId = ZoneId.systemDefault()): Cameo? {
internal fun chooseCameo(c: Changeover, diary: CameoDiary, on: Boolean, kids: Boolean, zone: ZoneId = ZoneId.systemDefault(),
/** The gags drawn so far: only these are chosen (phase 3 has The Chase). */
drawn: Set<Gag> = Gag.entries.toSet()): Cameo? {
if (!on || kids) return null
val key = c.channel to c.nextStartMs
if (key in diary.decided) return diary.decided[key]
@@ -78,7 +80,7 @@ internal fun chooseCameo(c: Changeover, diary: CameoDiary, on: Boolean, kids: Bo
diary.lastByChannel[c.channel]?.let { if (c.nextStartMs - it < cameoGap(c.channel, it)) return@run null }
diary.lastAny?.let { if (c.nextStartMs - it < CAMEO_HOUSEHOLD_MS) return@run null }
val overnight = c.channel == NITE_OWL.channel
val left = Gag.entries.filter { it !in diary.seen && (!it.overnightOnly || overnight) }
val left = Gag.entries.filter { it in drawn && it !in diary.seen && (!it.overnightOnly || overnight) }
if (left.isEmpty()) return@run null
val m = mix(c.channel, c.nextStartMs)
Cameo(left[m % left.size], lunaEnds = (m / 7) % 3 == 0)
@@ -0,0 +1,105 @@
package tv.orbit.classic
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.ui.unit.dp
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.drawscope.DrawScope
import kotlin.math.PI
import kotlin.math.abs
import kotlin.math.cos
import kotlin.math.sin
/**
* The Chase, the first cameo (Paul, 6 November 2026, docs/character-continuity.md section 3.1), drawn along the bottom of
* a quiet changeover frame. Ollie rolls through looking back, Blaze storms after him, a flame puff lingers, then:
* - with [Cameo.lunaEnds], Luna peeks in, looks after them, looks straight at you for a beat, and rolls her eyes;
* - otherwise Drift floats in far too late, stops, looks both ways, and drifts on.
* The storyboard runs 10 seconds; it's played over the changeover's own length, so nothing waits for it.
*/
internal const val CHASE_STORY_S = 10f
/** The frame shown with Reduce motion: the payoff, Luna mid eye-roll or Drift looking about. */
internal const val CHASE_STILL_S = 7.3f
private fun lerp(a: Float, b: Float, u: Float) = a + (b - a) * u.coerceIn(0f, 1f)
private fun span(t: Float, from: Float, to: Float) = ((t - from) / (to - from)).coerceIn(0f, 1f)
private fun easeOut(u: Float) = 1f - (1f - u) * (1f - u) * (1f - u)
private fun easeInOut(u: Float) = if (u < .5f) 4 * u * u * u else 1 - (-2 * u + 2).let { it * it * it } / 2
/** Where Luna looks at [t]: after them, at you, then the eye-roll, up and over, then off to the side. */
internal fun lunaLook(t: Float): Offset = when {
t < 5.2f -> Offset(.6f, 0f)
t < 6.0f -> Offset(1f, 0f)
t < 6.8f -> Offset.Zero
t < 7.8f -> { val a = PI.toFloat() * span(t, 6.8f, 7.8f); Offset(cos(a), -sin(a)) }
else -> Offset(-1f, .2f)
}
/** Draws the gag at storyboard second [t] (0 to 10) across this band, characters along its lower part. */
internal fun DrawScope.drawChase(t: Float, lunaEnds: Boolean) {
val w = size.width; val ground = size.height * .62f; val r = size.height * .2f
fun at(x: Float, lift: Float = 0f) = Offset(x * w, ground - lift * size.height)
// Ollie rolls through, ring bobbing, looking back over his shoulder.
if (t in .4f..2.6f) {
val u = span(t, .4f, 2.4f)
drawOrbMascot(at(lerp(-.08f, 1.08f, u), abs(sin(u * 18f)) * .05f), r, OrbDir.Left)
}
// Blaze storms after him, flames streaming, brows down.
if (t in 1.4f..2.9f) drawOrbChaser(at(lerp(-.1f, 1.12f, span(t, 1.4f, 2.8f))), r * 1.05f, OrbCharacter.Blaze, OrbDir.Right, false, false, false, t * 14f)
// His last flame puff lingers at the edge, and fades.
if (t in 2.6f..3.3f) drawCircle(Color(0xFFFFC23D).copy(alpha = 1f - span(t, 2.6f, 3.3f)), r * .35f, at(.97f))
if (lunaEnds) {
if (t in 4.2f..9.8f) {
val x = if (t < 8.4f) lerp(-.07f, .045f, easeOut(span(t, 4.2f, 5.0f))) else lerp(.045f, -.09f, easeInOut(span(t, 8.4f, 9.8f)))
drawOrbChaser(at(x), r, OrbCharacter.Luna, OrbDir.Right, false, false, false, 0f, lookAt = lunaLook(t))
}
} else if (t in 4.2f..10f) {
// Drift, several seconds too late: floats in, stops, looks both ways, and drifts on.
val x = when { t < 7f -> lerp(-.08f, .5f, easeOut(span(t, 4.2f, 7f))); t < 8.6f -> .5f; else -> lerp(.5f, 1.1f, span(t, 8.6f, 10f)) }
val look = when { t < 7f -> Offset(1f, 0f); t < 7.6f -> Offset(-1f, 0f); t < 8.2f -> Offset(1f, 0f); t < 8.6f -> Offset.Zero; else -> Offset(1f, 0f) }
drawOrbChaser(at(x, .03f * sin(t * 2f)), r, OrbCharacter.Drift, OrbDir.Right, false, false, false, t * 3f, lookAt = look)
}
}
/** The Chase over [lengthMs] of a changeover that may already be [startedLateMs] in. */
@Composable
internal fun ChaseCameo(cameo: Cameo, lengthMs: Long, startedLateMs: Long, modifier: Modifier = Modifier) {
val calm = remember { Motion.reduce }
val lengthS = lengthMs / 1000f
var t by remember { mutableFloatStateOf(startedLateMs / 1000f) }
LaunchedEffect(Unit) {
if (calm) return@LaunchedEffect
val start = withFrameNanos { it } - startedLateMs * 1_000_000L
while (t < lengthS) { val now = withFrameNanos { it }; t = (now - start) / 1e9f }
}
Canvas(modifier) { drawChase(if (calm) CHASE_STILL_S else t * CHASE_STORY_S / lengthS, cameo.lunaEnds) }
}
/** Settings › On screen › Character cameos › Show one: The Chase over a plain frame, so it can be judged on the TV. */
internal object CameoPreview {
var showing by mutableStateOf<Cameo?>(null)
private var turn = 0
/** Luna's ending and Drift's in turn. */
fun next() { showing = Cameo(Gag.Chase, lunaEnds = turn++ % 2 == 0) }
}
/** The preview runs as long as a 7-second ident, the window it plays in. */
internal const val CHASE_PREVIEW_MS = 7_000L
@Composable
internal fun CameoPreviewOverlay() {
val cameo = CameoPreview.showing ?: return
androidx.activity.compose.BackHandler { CameoPreview.showing = null }
LaunchedEffect(cameo) { kotlinx.coroutines.delay(CHASE_PREVIEW_MS); CameoPreview.showing = null }
androidx.compose.foundation.layout.Box(Modifier.fillMaxSize().background(NightNavy), contentAlignment = androidx.compose.ui.Alignment.BottomCenter) {
ChaseCameo(cameo, CHASE_PREVIEW_MS, 0, Modifier.fillMaxWidth().height(170.dp).padding(bottom = 70.dp))
}
}
@@ -62,9 +62,9 @@ internal class HttpsEmbyTransport(internal val deviceId: String = UUID.randomUUI
}
/** The sign-in headers for this kind of server. */
internal fun authHeaders(token: String?): Map<String, String> = when (kind) {
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.66\"") +
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.67\"") +
(token?.let { mapOf("X-Emby-Token" to it) } ?: emptyMap())
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.66\"" +
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.67\"" +
(token?.let { ", Token=\"$it\"" } ?: ""))
}
/** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */
@@ -93,14 +93,16 @@ internal fun IdentOverlay(session: EmbySampleSession, channel: SampleChannel, ne
/** Entering a block or event with its own ident: that film instead of the channel's, with anything drawn over it. */
block: BlockIdent? = null,
/** In place of "NEXT" over the title, such as Catch Up's. */
heading: String? = null) {
heading: String? = null,
/** A cameo plays instead of the ident: the quiet frame (artwork and logo), with the gag drawn along its bottom. */
cameo: Cameo? = null) {
val context = LocalContext.current
val mood = if (channel.number == TOTS_NUMBER) totsMood(next.startMs) else null
val settings = remember { OrbitSettings(context) }
val fade = remember { Animatable(0f) }
LaunchedEffect(Unit) { fade.animateTo(1f, tween(mood?.fadeMs ?: 400)) }
Box(Modifier.fillMaxSize().graphicsLayer { alpha = fade.value }.background(NightNavy)) {
val video = block?.video ?: identVideo(channel.number, next.startMs)
val video = if (cameo != null) null else block?.video ?: identVideo(channel.number, next.startMs)
// With idents off, Tots still says goodbye with a picture that doesn't move.
if (mood != null && !settings.idents) Image(cachedPainter(mood.still), null, Modifier.fillMaxSize())
// Every third Tots changeover, a drawn bumper with the cast instead of the filmed ident.
@@ -133,6 +135,8 @@ internal fun IdentOverlay(session: EmbySampleSession, channel: SampleChannel, ne
}
}
// A booked event's own lower third says what's next instead.
// The cameo runs along the bottom, above what's next.
if (cameo != null && cameo.gag == Gag.Chase) ChaseCameo(cameo, identMs, startedLateMs, Modifier.align(Alignment.BottomCenter).fillMaxWidth().height(170.dp).padding(bottom = 70.dp))
if (block?.overlay != BlockOverlay.TonightsEvent || eventTitle(next) == null) Column(Modifier.align(Alignment.BottomStart).padding(start = 40.dp, bottom = 32.dp).background(NightNavy.copy(alpha = .72f)).padding(horizontal = 14.dp, vertical = 8.dp)) {
Text(heading ?: if (early) "NEXT AT ${clock(next.startMs)}" else "NEXT", color = Color(0xFFD5DCEA), fontSize = 12.sp, fontWeight = FontWeight.SemiBold, letterSpacing = 2.sp)
Text(guideTitleParts(next.media.item.title).first, color = Color.White, fontSize = 20.sp, fontWeight = FontWeight.SemiBold, maxLines = 1, overflow = TextOverflow.Ellipsis)
@@ -230,6 +230,8 @@ private fun OrbitApp() {
// A new TV joining (Multiroom auto-scan), over everything else; and a newer Orbit from another room.
RoomKnockOverlay()
RoomUpdateCard()
// Settings › Character cameos › Show one.
CameoPreviewOverlay()
}
}
}
@@ -69,6 +69,7 @@ internal fun ScheduledChannelPlayer(session: EmbySampleSession, channel: SampleC
val identsHere = channel is ScheduledChannel && clockOffsetMs == 0L && channel.number != DRIVE_IN_NUMBER && next.startMs == current.endMs && (identsOn || channel.number == TOTS_NUMBER)
// The squeeze-back (Paul, 6 November 2026): over the last minute, with the next programme loading from its start.
val squeezeOn = remember { OrbitSettings(settingsContext).squeezeBack }
val cameosOn = remember { OrbitSettings(settingsContext).let { it.characterCameos && it.castOn } }
val calmMotion = remember { OrbitSettings(settingsContext).reduceMotion }
val squeezing = squeezeOn && channel is ScheduledChannel && squeezeBackDue(channel.number, current.startMs, current.endMs, next.startMs, now, if (identsHere) identMs else 0L, clockOffsetMs, squeezeLength(current.media.item.type))
val squeeze by androidx.compose.animation.core.animateFloatAsState(if (squeezing) 1f else 0f,
@@ -232,7 +233,13 @@ internal fun ScheduledChannelPlayer(session: EmbySampleSession, channel: SampleC
lockedOut(item.channel) || profileHides(item.channel) || item.driveIn?.let { lockedOut(it) } == true || kidsAsleep(takeoverOf(item.channel, item.entry))
}?.also { PromoBoard.shown[channel.number] = held.startMs }
}
if (entering != null) TakeoverIdent(entering) else if (promo != null) PromoOverlay(session, promo) else IdentOverlay(session, channel, held, length, startedLate, early, heldAs)
// Now and then a cameo from the cast in place of the ident (docs/character-continuity.md), when switched on.
val cameo = if (entering != null || promo != null) null else remember {
if (early || heldAs != null || channel !is ScheduledChannel || clockOffsetMs != 0L) null
else chooseCameo(Changeover(channel.number, current.startMs, current.media.item.type, held.startMs, held.media.item.type), CameoSession.diary,
on = cameosOn, kids = Profiles.kids, drawn = setOf(Gag.Chase))
}
if (entering != null) TakeoverIdent(entering) else if (promo != null) PromoOverlay(session, promo) else IdentOverlay(session, channel, held, length, startedLate, early, heldAs, cameo = cameo)
}
}
if (catchUpFor != null && problem == null && (!catchUpIdentDone || !catchUpPicture)) key("catch-up-ident") {
@@ -39,7 +39,7 @@ internal class SecureMediaDataSource(private val session: EmbySampleSession) : B
next.instanceFollowRedirects = false
next.connectTimeout = 10_000
next.readTimeout = 20_000
next.setRequestProperty("User-Agent", "OrbitTV/0.108.66")
next.setRequestProperty("User-Agent", "OrbitTV/0.108.67")
next.setRequestProperty("Accept-Encoding", "identity")
session.mediaHeaders(address).forEach { (key, value) -> next.setRequestProperty(key, value) }
if (dataSpec.position != 0L || dataSpec.length != C.LENGTH_UNSET.toLong()) {
@@ -298,6 +298,9 @@ private fun ViewingDetail(firstSwitch: FocusRequester, modifier: Modifier, top:
SettingLine("Character cameos", if (castOn) "Now and then the cast pop up between programmes on Riot, ToonZ in the evening and Nite Owl. Never over a programme or a film." else "Turn on The cast first.") {
OnOff(cameos, Modifier, enabled = castOn, onClick = { cameos = !cameos; settings.characterCameos = cameos })
}
SettingLine("See The Chase", "The first cameo, over a plain frame: Luna's ending and Drift's in turn. It closes by itself.") {
OrbitButton("Show one", onClick = { CameoPreview.next() })
}
SettingLine("Mini shorts", if (castOn) "Rarer still: a short cartoon with the cast in a gap the schedule already has. Coming in a later update." else "Turn on The cast first.") {
OnOff(miniShorts, Modifier, enabled = castOn, onClick = { miniShorts = !miniShorts; settings.miniShorts = miniShorts })
}
@@ -0,0 +1,22 @@
package tv.orbit.classic
import androidx.compose.ui.geometry.Offset
import org.junit.Assert.*
import org.junit.Test
/** The Chase's timings against the storyboard (docs/character-continuity.md 3.1). */
class ChaseCameoTest {
@Test fun lunaLooksAfterThemThenAtYouThenRollsHerEyes() {
assertEquals(Offset(1f, 0f), lunaLook(5.5f))
assertEquals(Offset.Zero, lunaLook(6.4f)) // the fourth-wall glance, 6.0 to 6.8 s
assertTrue(lunaLook(7.3f).y < -.9f) // halfway through the roll: straight up
assertTrue(lunaLook(7.75f).x < -.9f) // and over
}
@Test fun onlyTheChaseIsChosenWhileItsTheOnlyOneDrawn() {
val c = Changeover(105, 0, "Episode", 30 * 60_000L, "Episode")
val cameo = chooseCameo(c, CameoDiary(), on = true, kids = false, drawn = setOf(Gag.Chase))
assertTrue(cameo == null || cameo.gag == Gag.Chase)
assertNull(chooseCameo(c, CameoDiary(), on = true, kids = false, drawn = emptySet()))
}
}