Your channels play in the sound they have; planning is shown, not silent

Channels of your own no longer leave out episodes without English sound: Sakura's anime is
mostly Japanese with subtitles, and its first read was finding almost nothing to play. The
phone says how long a new channel's first plan takes, Your channels shows Planning… until it's
done, and the TV's switch says when it is still planning another channel instead of doing
nothing. 0.108.91.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-07 13:57:47 +00:00
co-authored by Claude Opus 5.5
parent c04029533c
commit dec0628a5a
7 changed files with 34 additions and 15 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ android {
applicationId = "tv.orbit.classic"
minSdk = 26
targetSdk = 36
versionCode = 250
versionName = "0.108.90-director-plan"
versionCode = 251
versionName = "0.108.91-planning-shown"
}
buildFeatures { compose = true }
// The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so
@@ -82,6 +82,7 @@ body:has(main.kpad) .toast{bottom:calc(250px + env(safe-area-inset-bottom))}
/* While typing, the keyboard pushes fixed bars up over the search results (Paul, 7 November 2026): hide them until it's down. */
body.typing .kbar,body.typing nav{display:none}
.toast button{margin-left:10px;font-weight:800;text-decoration:underline;color:inherit}
@keyframes kplan{0%{margin-left:-35%}100%{margin-left:100%}}.kplan{animation:kplan 1.6s ease-in-out infinite}
.toast{position:fixed;left:50%;bottom:90px;transform:translateX(-50%);background:var(--accent);color:var(--on-accent);padding:9px 16px;border-radius:999px;font-weight:700;font-size:13px;z-index:9;display:none;max-width:90vw;text-align:center}
.empty{color:var(--muted);text-align:center;padding:30px 10px}
</style></head><body>
@@ -261,8 +262,8 @@ function more() {
<div style="display:flex;gap:10px;overflow-x:auto;padding-bottom:4px;scrollbar-width:none">${(yours?.channels || []).map(c => `<div style="flex:0 0 140px;position:relative"><button data-edit="${c.number}" style="width:100%;height:100%;text-align:left;background:var(--surface);border-radius:16px;padding:14px">
<div style="color:var(--accent);font-weight:800;font-size:18px">${c.number}</div><div style="font-weight:700;margin-top:6px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${esc(c.name)}</div>
<div class="small">${esc((c.styleTitle || '').replace(' by the Director', ''))}</div><div class="small" style="color:var(--accent);font-weight:700;margin-top:8px;padding-bottom:30px">Edit</div></button>
<button data-kpower="${c.number}:${c.on ? 0 : 1}" aria-label="Turn ${esc(c.name)} ${c.on ? 'off' : 'on'}" style="position:absolute;left:14px;bottom:12px;display:flex;align-items:center;gap:6px;font-size:12px;font-weight:700;color:${c.on ? 'var(--mint)' : 'var(--muted)'}">
<span style="width:30px;height:18px;border-radius:9px;background:${c.on ? 'var(--mint)' : 'var(--deep)'};position:relative;display:inline-block"><span style="position:absolute;top:2px;${c.on ? 'right:2px' : 'left:2px'};width:14px;height:14px;border-radius:7px;background:${c.on ? 'var(--deep)' : 'var(--muted)'}"></span></span>${c.on ? 'On' : 'Off'}</button>
${c.planning ? `<span style="position:absolute;left:14px;bottom:14px;font-size:12px;font-weight:700;color:var(--accent)">Planning…</span>` : `<button data-kpower="${c.number}:${c.on ? 0 : 1}" aria-label="Turn ${esc(c.name)} ${c.on ? 'off' : 'on'}" style="position:absolute;left:14px;bottom:12px;display:flex;align-items:center;gap:6px;font-size:12px;font-weight:700;color:${c.on ? 'var(--mint)' : 'var(--muted)'}">
<span style="width:30px;height:18px;border-radius:9px;background:${c.on ? 'var(--mint)' : 'var(--deep)'};position:relative;display:inline-block"><span style="position:absolute;top:2px;${c.on ? 'right:2px' : 'left:2px'};width:14px;height:14px;border-radius:7px;background:${c.on ? 'var(--deep)' : 'var(--muted)'}"></span></span>${c.on ? 'On' : 'Off'}</button>`}
<button data-kremove="${c.number}" aria-label="Remove ${esc(c.name)}" style="position:absolute;top:6px;right:6px;width:32px;height:32px;border-radius:16px;display:flex;align-items:center;justify-content:center;color:var(--muted);font-size:18px">×</button></div>`).join('')}
${!yours || yours.next ? `<button data-create="1" aria-label="Create a channel" style="flex:0 0 ${yours?.channels?.length ? '64px' : '100%'};border:2px dashed var(--accent);border-radius:16px;color:var(--accent);font-size:${yours?.channels?.length ? '28px' : '16px'};font-weight:700;padding:14px">${yours?.channels?.length ? '+' : '+ Create a channel'}</button>` : ''}</div>`;
const line = (label, value, attr, first) => `<button ${attr} style="display:flex;width:100%;align-items:center;padding:15px 16px;${first ? '' : 'border-top:1px solid var(--raised);'}text-align:left"><span style="flex:1;font-weight:600">${label}</span><span class="small" style="margin-right:8px">${value}</span>${fold(false).replace('M6 9l6 6 6-6', 'M9 6l6 6-6 6')}</button>`;
@@ -443,8 +444,11 @@ const brandOf = d => d.brand !== undefined ? d.brand : ((state.brands || []).fin
function doneView() {
const c = state.create, k = c.done;
return `<div style="text-align:center;padding:40px 8px 0"><div style="font-size:44px;color:var(--mint)">✓</div>
<div class="title" style="white-space:normal">${esc(k.name)} is ready on ${k.number}</div>
<div class="small" style="margin:8px 0 22px">${esc(k.message || '')}</div>
<div class="title" style="white-space:normal">${esc(k.name)} is on ${k.number}</div>
${k.minutes ? `<div class="card" style="margin:14px 0 18px;text-align:left"><b>Planning its first week</b>
<div style="height:6px;border-radius:3px;background:var(--deep);margin:10px 0;overflow:hidden"><div class="kplan" style="height:100%;width:35%;border-radius:3px;background:var(--accent)"></div></div>
<div class="small">About ${k.minutes === 1 ? 'a minute' : k.minutes + ' minutes'}. Orbit reads every title's episodes, then lays out the week. It comes on by itself, and Your channels shows when it's done. Watch anything else meanwhile.</div></div>`
: `<div class="small" style="margin:8px 0 22px">${esc(k.message || '')}</div>`}
${c.watching ? `<div class="card small" style="margin-bottom:12px">${esc(c.watching)}</div>` : ''}
${k.queued ? '' : `<button class="btn gold" data-cwatch="next" style="margin-bottom:8px">Watch after this programme</button><button class="btn" data-cwatch="now" style="margin-bottom:8px">Watch now</button>`}
<button class="btn" data-cdone="1" style="background:none;color:var(--muted)">Done</button></div>`;
@@ -596,7 +600,7 @@ async function makeChannel(ending) {
try { const r = await api('/api/channels', {number: d.number, name: d.name, description: d.description, style: d.style, hours: d.hours, shows: d.shows.map(x => ({id: x.id, title: x.title, year: x.year ?? null, type: x.type})),
slots: d.style === 'Shaped' ? d.slots : undefined, core: d.style === 'Shaped' ? d.core : undefined, season: d.season || null,
brand: d.brand !== undefined ? d.brand : undefined, collection: d.collection || undefined});
c.done = {number: r.number, name: d.name, message: r.message, edit: !!d.number}; c.busy = false; render(); load('more');
c.done = {number: r.number, name: d.name, message: r.message, minutes: d.number ? 0 : r.minutes, edit: !!d.number}; c.busy = false; render(); load('more');
// Create & watch next: queued for after the programme on now, never interrupting it (Paul, 7 November 2026).
if (ending === 'next') { await watchNew('next'); }
} catch (e) { c.note = e.message; c.busy = false; render(); }
@@ -99,6 +99,11 @@ internal object CustomChannels {
fun clear() { list = emptyList() }
fun nextNumber(): Int? = (YOURS_FIRST..YOURS_LAST).firstOrNull { n -> list.none { it.number == n } }
fun of(number: Int) = list.firstOrNull { it.number == number }
/** The channel of your own whose first week is being planned right now, if any, for the phone to show. */
@Volatile var planning: Int? = null
/** Roughly how long a first plan takes, from what it has to read: each series' episodes, a quick look for each film. */
fun planMinutes(series: Int, films: Int) = ((series * 9 + films) / 60.0).let { kotlin.math.ceil(it).toInt() }.coerceAtLeast(1)
@Volatile private var cached: Pair<List<CustomChannel>, List<ChannelProgramming>> = emptyList<CustomChannel>() to emptyList()
/** Every channel of your own as the planner sees it. */
@@ -117,6 +122,9 @@ internal fun programmingOf(channel: CustomChannel): ChannelProgramming = Channel
channel.number, channel.name, emptyList(), seriesCount = 60,
finishTogether = channel.style == PlayStyle.Standard || channel.style == PlayStyle.Blocks || channel.style == PlayStyle.Shaped,
exactTitles = true, shuffleEpisodes = channel.style == PlayStyle.Shuffled, mixedTurns = true,
// You chose these titles yourself, so they play in the sound they have: Sakura's anime is mostly Japanese with subtitles,
// and asking for English sound left nearly all of it out (7 November 2026).
englishAudio = false,
dayParts = when (channel.style) { PlayStyle.Blocks -> timetableParts(channel.shows); PlayStyle.Shaped -> shapedParts(channel.slots); else -> emptyList() },
storyGrouping = channel.style == PlayStyle.Standard || channel.style == PlayStyle.Shaped,
shorts = if (channel.style == PlayStyle.Standard || channel.style == PlayStyle.Shaped) YoursShorts else null,
@@ -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.90\"") +
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.91\"") +
(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.90\"" +
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.91\"" +
(token?.let { ", Token=\"$it\"" } ?: ""))
}
/** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */
@@ -504,10 +504,13 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
fun setSmartSchedule(programming: ChannelProgramming, turnOn: Boolean) {
val active = session ?: return
val existing = smartLoop(programming)
// Planning another channel: say so, rather than the switch seeming to do nothing (Paul, 7 November 2026).
if (busy) { message = "Orbit is still planning ${CustomChannels.planning?.let { CustomChannels.of(it)?.name } ?: "another channel"}. Try again when it's finished."; return }
// A second press straight after the first is taken as a slip.
if (busy || now - lastSmartPress < 5_000) return
if (now - lastSmartPress < 5_000) return
lastSmartPress = now
busy = true; busyLabel = "Reading ${programming.name}'s whole series and planning seven days…"; message = null
if (turnOn && CustomChannels.of(programming.number) != null) CustomChannels.planning = programming.number
job = scope.launch {
try {
if (turnOn) {
@@ -529,7 +532,7 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
} catch (cancelled: CancellationException) { throw cancelled }
catch (failure: EmbyCheckException) { withContext(Dispatchers.IO) { scheduler.setEnabled(active.accountId, programming.number, false) }; message = failure.message }
catch (_: Exception) { withContext(Dispatchers.IO) { scheduler.setEnabled(active.accountId, programming.number, false) }; message = "${programming.name} could not be scheduled, so it stays off." }
finally { busy = false }
finally { busy = false; CustomChannels.planning = null }
}
}
// Create your own from a phone and the Companion: kept here, before any screen returns early, so the phone can make
@@ -570,7 +573,9 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
}
android.util.Log.i("OrbitSchedule", "yours channel=${channel.number} style=${channel.style} titles=${shows.size}")
SmartChannels.firstOrNull { it.number == channel.number }?.let { setSmartSchedule(it, true) }
"${channel.name} is ready on ${channel.number}. Its first programmes are being planned now."
val minutes = CustomChannels.planMinutes(shows.count { it.type == "Series" }, shows.count { it.type != "Series" })
"${channel.name} is on ${channel.number}. Orbit is reading its titles and planning the week, which takes about " +
(if (minutes == 1) "a minute" else "$minutes minutes") + ". It comes on by itself, and you can watch anything else meanwhile."
},
remove = { number ->
val gone = CustomChannels.of(number) ?: return@ChannelMaker "That channel has already gone."
@@ -294,7 +294,8 @@ internal object PhoneLink {
val h = standIn ?: handler ?: return json(out, 403, JSONObject().put("error", "The TV isn't signed in to a library right now."))
when ("${r.method} ${r.path}") {
"GET /api/channels" -> json(out, 200, JSONObject().put("next", CustomChannels.nextNumber() ?: JSONObject.NULL).put("channels", JSONArray(CustomChannels.list.map { c ->
c.toJson().put("on", h.isOn(c.number)).put("styleTitle", c.style.title).put("hoursLabel", c.hours?.label ?: "All day") })))
c.toJson().apply { remove("seen") }.put("on", h.isOn(c.number)).put("planning", CustomChannels.planning == c.number)
.put("styleTitle", c.style.title).put("hoursLabel", c.hours?.label ?: "All day") })))
"GET /api/shows" -> {
val number = r.query["number"]?.toIntOrNull() ?: return json(out, 400, JSONObject())
json(out, 200, JSONArray(runBlocking { h.maker.showsOf(number) }.map(::suggestionJson)))
@@ -389,7 +390,8 @@ internal object PhoneLink {
slots = o.optJSONObject("slots")?.let { m -> m.keys().asSequence().mapNotNull { id -> titleOf[id]?.let { t -> runCatching { t to Slot.valueOf(m.getString(id)) }.getOrNull() } }.toMap() }.orEmpty(),
core = o.optJSONArray("core")?.let { a -> (0 until minOf(a.length(), 20)).mapNotNull { titleOf[a.getString(it)] }.toSet() }.orEmpty())
val said = runBlocking { withContext(mainDispatcher) { h.maker.create(laidOut, shows) } }
json(out, 200, JSONObject().put("message", said).put("number", number))
json(out, 200, JSONObject().put("message", said).put("number", number)
.put("minutes", CustomChannels.planMinutes(shows.count { it.type == "Series" }, shows.count { it.type != "Series" })))
}
// Off keeps a channel and its place; on plans it again (Paul, 7 November 2026: an Off switch beside Remove).
"POST /api/channels/power" -> {
@@ -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.90")
next.setRequestProperty("User-Agent", "OrbitTV/0.108.91")
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()) {