Rooms sync, sound for every ident, profiles in the install check, a won't-play report
Ported from release-0.108 (0.108.100), with every channel's sting source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -641,11 +641,14 @@ function director() {
|
||||
<div style="margin:8px 0">${a.titles.slice(0, 6).map(t => `<div style="font-weight:600">${esc(t.title)}${t.year ? ` <span class="small">${t.year}</span>` : ''}</div>`).join('')}${a.titles.length > 6 ? `<div class="small">and ${a.titles.length - 6} more</div>` : ''}</div>
|
||||
<div class="row" style="gap:8px"><button class="btn gold" data-arrive="${a.number}:1">Add to ${esc(a.channel)}</button><button class="btn" data-arrive="${a.number}:0">Not now</button></div></div>`).join('');
|
||||
h += '<div class="label">Titles for your channels</div>';
|
||||
const later = () => (state.unplayable?.length ? `<div class="label">Won't play on this TV</div>` + state.unplayable.map(u => `<div class="rm"><h3 style="display:block">${esc(u.title)}</h3>
|
||||
<div class="small">${u.channel ? 'Channel ' + u.channel + ' · ' : ''}${esc(u.reason)}</div>
|
||||
<div class="row" style="gap:8px;margin-top:10px"><button class="btn" data-uretry="${esc(u.id)}">Try again</button></div></div>`).join('') : '');
|
||||
h += r.choices.length ? r.choices.map(c => `<div class="rm"><h3 style="display:block">${esc(c.title)}</h3><div class="small">${c.type === 'Movie' ? 'Film' : 'Series'}${c.year ? ' · ' + c.year : ''}${c.line ? ' · ' + esc(c.line) : ''}</div>
|
||||
<div class="chips" style="flex-wrap:wrap;margin:10px 0 0">${c.options.map((o, k) => `<button class="${k === 0 ? 'on' : ''}" data-place="${esc(c.id)}:${o.number}">${k === 0 ? 'Place on ' : ''}${o.number} ${esc(o.name)}</button>`).join('')}
|
||||
<button data-drop="${esc(c.id)}">Drop it</button></div>
|
||||
${c.options[0]?.reason ? `<div class="small" style="margin-top:6px">${esc(c.options[0].reason)}</div>` : ''}</div>`).join('') : '<div class="empty">Nothing new to place this week.</div>';
|
||||
return h + '<div class="small" style="margin:10px 0">Placing adds a title to that channel\'s list; it joins as the channel plans ahead, and nothing already booked changes.</div>';
|
||||
return h + '<div class="small" style="margin:10px 0">Placing adds a title to that channel\'s list; it joins as the channel plans ahead, and nothing already booked changes.</div>' + later();
|
||||
}
|
||||
|
||||
// Add to home screen (Paul, 6 November 2026): offered once after joining, and any time from More. The TV's page is plain
|
||||
@@ -684,7 +687,8 @@ async function load(what) {
|
||||
if (what === 'more') { const [l, c, p] = await Promise.all([api('/api/looks'), api('/api/channels').catch(() => null), api('/api/profiles').catch(() => null)]);
|
||||
state.looks = l.looks; state.channels = c; state.profiles = p; look(state.now?.look);
|
||||
if (p?.current?.kind !== 'Kids') api('/api/director').then(r => { state.directorCount = r.ready ? r.ideas.filter(i => i.decision !== 'approved').length + r.choices.length : 0; if (tab === 'more' && !state.create && !state.chair) render(); }).catch(() => {}); }
|
||||
if (what === 'director') { const [r, a] = await Promise.all([api('/api/director'), api('/api/arrivals').catch(() => ({arrivals: []}))]); state.director = r; state.arrivals = a.arrivals; }
|
||||
if (what === 'director') { const [r, a, u] = await Promise.all([api('/api/director'), api('/api/arrivals').catch(() => ({arrivals: []})), api('/api/unplayable').catch(() => ({items: []}))]);
|
||||
state.director = r; state.arrivals = a.arrivals; state.unplayable = u.items; }
|
||||
offline = false;
|
||||
} catch (e) { if (!offline) toast(e.message === 'Failed to fetch' ? "Orbit isn't open on the TV" : e.message); offline = true; }
|
||||
// Making a channel isn't redrawn by the background refresh, so typing is never lost.
|
||||
@@ -780,6 +784,7 @@ document.addEventListener('click', e => {
|
||||
if (d.kmake) { makeChannel(d.kmake); return; }
|
||||
if (d.kbrand !== undefined) { const c = state.create; c.draft.name = ($('#kname')?.value || c.draft.name || '').trim(); c.draft.brand = d.kbrand; render(); return; }
|
||||
if (d.create) { startCreate({name: '', description: '', style: 'Shaped', hours: null, shows: [], skipped: []}); return; }
|
||||
if (d.uretry) { api('/api/unplayable/retry', {id: d.uretry}).then(r => { toast(r.message); state.unplayable = state.unplayable.filter(u => u.id !== d.uretry); render(); }).catch(e => toast(e.message)); return; }
|
||||
if (d.kaddmore) { const c = state.create; c.quick = false; c.view = 'shows'; c.note = ''; render(); scrollTo(0, 0); return; }
|
||||
if (d.kdrop) { const dr = state.create.draft; dr.shows = dr.shows.filter(x => x.id !== d.kdrop); dr.core = dr.core.filter(i => i !== d.kdrop); delete dr.slots[d.kdrop]; render(); return; }
|
||||
if (d.kpower) { const [n, on] = d.kpower.split(':');
|
||||
|
||||
@@ -284,6 +284,8 @@ internal class ChannelScheduler(private val store: ScheduleStore,
|
||||
/** A file that wouldn't play. It stays in what's already planned, and is left out from here on. */
|
||||
fun markFailed(userId: String, itemId: String) {
|
||||
store.saveFailed(userId, store.loadFailed(userId) + itemId)
|
||||
// Why, for the Chair's "won't play" list.
|
||||
Unplayable.take(itemId)?.let { (title, channel, reason) -> runCatching { store.unplayable().add(itemId, title, channel, reason, clock()) } }
|
||||
}
|
||||
|
||||
/** Starts a channel that has no loop yet: reads its pool, then gives it a small fallback made from that pool. */
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.json.JSONObject
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.background
|
||||
@@ -65,6 +67,10 @@ internal class ChannelMaker(
|
||||
val power: suspend (Int, Boolean) -> String = { _, _ -> "That channel can't be changed here." },
|
||||
/** Brings back the channel removed a moment ago, as it was. */
|
||||
val restore: suspend (Int) -> String = { "That channel can't be brought back." },
|
||||
/** Files that won't play here: id, title, channel, why, when. */
|
||||
val unplayable: suspend () -> List<JSONObject> = { emptyList() },
|
||||
/** Gives one unplayable file another try: it comes off the list and is planned again. */
|
||||
val retryUnplayable: suspend (String) -> String = { "That can't be done here." },
|
||||
/** New titles from a channel's collection: added to it, or set aside as seen. */
|
||||
val arrivals: suspend (Int, List<String>, Boolean) -> String = { _, _, _ -> "That can't be done here." })
|
||||
|
||||
|
||||
@@ -641,6 +641,14 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
SmartChannels.firstOrNull { it.number == number }?.let { setSmartSchedule(it, true) }
|
||||
"${gone.name} is back on $number."
|
||||
},
|
||||
unplayable = { withContext(Dispatchers.IO) {
|
||||
val reasons = scheduleStore.unplayable().all()
|
||||
scheduleStore.loadFailed(active.accountId).map { id -> (reasons[id] ?: org.json.JSONObject().put("title", "A file Orbit couldn't play").put("reason", "Noted before Orbit kept reasons.")).put("id", id) }
|
||||
} },
|
||||
retryUnplayable = { id -> withContext(Dispatchers.IO) {
|
||||
scheduleStore.saveFailed(active.accountId, scheduleStore.loadFailed(active.accountId) - id); scheduleStore.unplayable().remove(id)
|
||||
"It'll be tried again as the channel plans ahead. If it still won't play, it comes back here."
|
||||
} },
|
||||
arrivals = { number, ids, add ->
|
||||
val ch = CustomChannels.of(number) ?: return@ChannelMaker "That channel has gone."
|
||||
val seen = ch.seen + ids
|
||||
|
||||
@@ -230,6 +230,8 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
|
||||
return
|
||||
}
|
||||
if (scheduled != null) {
|
||||
Unplayable.note(plan.item.id, plan.item.title, scheduled.channel.number,
|
||||
unplayableReason(error.errorCodeName, generateSequence(error.cause) { it.cause }.firstOrNull()?.message?.take(120)))
|
||||
onUnplayable?.invoke(plan.item.id)
|
||||
failure = "This programme won't play on this box. Orbit moves on at ${clock(scheduled.programme.endMs)}."
|
||||
ready = false
|
||||
@@ -252,6 +254,7 @@ internal fun EmbyPlaybackDialog(session: EmbySampleSession, plan: EmbyPlaybackPl
|
||||
if (scheduled != null && video.isNotEmpty() && video.none { it.isSupported }) {
|
||||
android.util.Log.w("OrbitSchedule", "channel=${scheduled.channel.number} noVideoDecoder=${video.first().getTrackFormat(0).sampleMimeType}")
|
||||
player.stop(); ready = false
|
||||
Unplayable.note(plan.item.id, plan.item.title, scheduled.channel.number, "This TV has no decoder for its picture (${video.first().getTrackFormat(0).sampleMimeType}).")
|
||||
onUnplayable?.invoke(plan.item.id)
|
||||
failure = "This programme won't play on this box. Orbit moves on at ${clock(scheduled.programme.endMs)}."
|
||||
return
|
||||
|
||||
@@ -151,6 +151,7 @@ private fun GuideLivePlayer(session: EmbySampleSession, plan: EmbyPlaybackPlan,
|
||||
val video = tracks.groups.filter { it.type == androidx.media3.common.C.TRACK_TYPE_VIDEO }
|
||||
if (video.isNotEmpty() && video.none { it.isSupported }) {
|
||||
android.util.Log.w("OrbitSchedule", "picture channel=$channelNumber noVideoDecoder=${video.first().getTrackFormat(0).sampleMimeType}")
|
||||
Unplayable.note(plan.item.id, plan.item.title, channelNumber, "This TV has no decoder for its picture (${video.first().getTrackFormat(0).sampleMimeType}).")
|
||||
onCantPlay(plan.item.id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,10 +39,9 @@ private val IdentVideos = mapOf(108 to R.raw.ident_108, 109 to R.raw.ident_109,
|
||||
|
||||
/** [atMs] is when the next programme starts, for a channel whose ident follows the time of day. */
|
||||
/**
|
||||
* Idents with a sound of their own (Paul, 7 November 2026; design/channels/sound): played with Ident sound on, at most once
|
||||
* every 20 minutes a channel, so a run of short programmes doesn't repeat it every few minutes.
|
||||
* Every channel's ident has a sound of its own (Paul, 7 November 2026; design/channels/sound), played with Ident sound on, at
|
||||
* most once every 20 minutes a channel, so a run of short programmes doesn't repeat it every few minutes. Tots keeps its jingle.
|
||||
*/
|
||||
internal val IdentsWithSound = setOf(R.raw.ident_mistletoe, R.raw.ident_sakura, R.raw.ident_109, R.raw.ident_110)
|
||||
internal object IdentStings {
|
||||
private val last = HashMap<Int, Long>()
|
||||
const val GAP_MS = 20 * 60_000L
|
||||
@@ -133,7 +132,7 @@ internal fun IdentOverlay(session: EmbySampleSession, channel: SampleChannel, ne
|
||||
seekTo(startedLateMs.coerceIn(0, identMs))
|
||||
volume = if (block != null) (if (settings.blockIdentSound) 1f else 0f)
|
||||
else if (mood != null && settings.identSound && TotsJingle.take(mood, System.currentTimeMillis())) 1f
|
||||
else if (mood == null && video in IdentsWithSound && settings.identSound && IdentStings.take(channel.number, System.currentTimeMillis())) 1f else 0f
|
||||
else if (mood == null && settings.identSound && IdentStings.take(channel.number, System.currentTimeMillis())) 1f else 0f
|
||||
prepare(); playWhenReady = true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ internal object InstallSnapshot {
|
||||
val schedule = File(data, "no_backup/schedule")
|
||||
schedule.copyRecursively(File(out, "no_backup/schedule"), overwrite = true)
|
||||
File(data, "shared_prefs/orbit_settings.xml").takeIf { it.exists() }?.copyTo(File(out, "shared_prefs/orbit_settings.xml"), overwrite = true)
|
||||
// Profiles too (7 November 2026), so an install can be shown to keep everyone; names and channels only, no PIN.
|
||||
File(data, "shared_prefs/orbit_profiles.xml").takeIf { it.exists() }?.copyTo(File(out, "shared_prefs/orbit_profiles.xml"), overwrite = true)
|
||||
File(out, "hashes.txt").writeText(listOf("no_backup/catalogue.db", "no_backup/orbit-connection.v1")
|
||||
.joinToString("\n") { "${sha256(File(data, it))} $it" } + "\n")
|
||||
"copied ${schedule.walk().count { it.isFile }}"
|
||||
|
||||
@@ -408,6 +408,13 @@ internal object PhoneLink {
|
||||
val said = runBlocking { withContext(mainDispatcher) { h.maker.restore(number) } }
|
||||
json(out, 200, JSONObject().put("message", said))
|
||||
}
|
||||
// Files that won't play, with why (7 November 2026), for the Director's Chair on the phone; Try again takes one off.
|
||||
"GET /api/unplayable" -> json(out, 200, JSONObject().put("items", JSONArray(runBlocking { h.maker.unplayable() }.take(50))))
|
||||
"POST /api/unplayable/retry" -> {
|
||||
if (!OrbitCompanion.grownUp) return json(out, 403, JSONObject().put("error", "Kids is watching. Switch to Adult."))
|
||||
val id = runCatching { JSONObject(r.body).getString("id") }.getOrNull()?.takeIf(EmbyClient::validId) ?: return json(out, 400, JSONObject())
|
||||
json(out, 200, JSONObject().put("message", runBlocking { h.maker.retryUnplayable(id) }))
|
||||
}
|
||||
// New in a channel's collection since you last looked, for the Director's Chair on the phone.
|
||||
"GET /api/arrivals" -> {
|
||||
val cols = runBlocking { h.maker.collections() }.associateBy { it.name }
|
||||
|
||||
@@ -62,7 +62,7 @@ internal object RoomCrypto {
|
||||
/** The parts of a set-up that can come across, each ticked on the new box before it's applied. */
|
||||
internal enum class RoomPart(val title: String, val line: String) {
|
||||
Channels("Channels and your own channels", "Which channels are on, the channels you've made, and the titles chosen for them"),
|
||||
Family("Profiles, Kids and the Adult PIN", "The PIN comes across scrambled, never as its digits"),
|
||||
Family("Profiles, Kids and the Adult PIN", "Everyone's profile, what Orbit has learnt for each, and their Continue watching. The PIN comes across scrambled, never as its digits"),
|
||||
Look("Look and On screen settings", "The look, subtitles, the cast, motion and the rest"),
|
||||
Director("Director's Chair decisions", "What you placed, dropped and taught it"),
|
||||
Arcade("Arcade bests", "High scores and games won")
|
||||
@@ -77,6 +77,44 @@ private const val BUNDLE_LIMIT = 12 * 1024 * 1024
|
||||
/** The files that make a room's schedules: plans, progress, the Drive-In's bookings and tickets, and what couldn't play. */
|
||||
private val ScheduleFiles = Regex("(schedule|progress|booked|tickets|failed)-\\d+\\.json")
|
||||
|
||||
/** Each person's Continue watching, and their Taste files, that travel with Family. */
|
||||
private val FamilyFiles = Regex("continue-[A-Za-z0-9]{1,40}\\.json")
|
||||
private val TasteFiles = Regex("[A-Za-z0-9_-]{1,40}\\.(events\\.jsonl|state\\.json)")
|
||||
|
||||
/** Both rooms' profiles: the same id is the same person (the incoming details win); the result always has a grown-up. */
|
||||
internal fun mergedProfiles(here: List<Profile>, incoming: List<Profile>): List<Profile> {
|
||||
val byId = LinkedHashMap<String, Profile>(); (here + incoming).forEach { byId[it.id] = it }
|
||||
return byId.values.toList().take(MAX_PROFILES).takeIf { list -> list.any { it.kind == ProfileKind.Grown } } ?: incoming.ifEmpty { here }
|
||||
}
|
||||
|
||||
/**
|
||||
* Taste and Continue watching from another room, merged into [dir]: Taste events joined by their ids (each counted once, kept in
|
||||
* bounds), a profile's Taste settings kept as they are here when already set, and Continue watching keeping the latest place
|
||||
* for each programme.
|
||||
*/
|
||||
internal fun mergeFamilyFiles(dir: File, files: JSONObject, nowMs: Long = System.currentTimeMillis()) {
|
||||
files.keys().forEach { name ->
|
||||
val text = files.getString(name)
|
||||
when {
|
||||
name.startsWith("taste/") && name.endsWith(".events.jsonl") && TasteFiles.matches(name.removePrefix("taste/")) -> {
|
||||
val target = File(dir, name).also { it.parentFile?.mkdirs() }
|
||||
val here = if (target.exists()) target.readLines().mapNotNull { TasteEvent.of(it) } else emptyList()
|
||||
val merged = compactTaste(here + text.lines().mapNotNull { TasteEvent.of(it) }, nowMs)
|
||||
target.writeText(merged.joinToString("") { it.toLine() + "\n" })
|
||||
}
|
||||
name.startsWith("taste/") && name.endsWith(".state.json") && TasteFiles.matches(name.removePrefix("taste/")) ->
|
||||
File(dir, name).let { if (!it.exists()) { it.parentFile?.mkdirs(); it.writeText(text) } }
|
||||
FamilyFiles.matches(name) -> {
|
||||
val target = File(dir, name)
|
||||
fun marks(t: String) = runCatching { JSONArray(t).let { a -> (0 until a.length()).mapNotNull { runCatching { ContinueMark.fromJson(a.getJSONObject(it)) }.getOrNull() } } }.getOrDefault(emptyList())
|
||||
val all = (if (target.exists()) marks(target.readText()) else emptyList()) + marks(text)
|
||||
val latest = all.groupBy { it.number to it.startMs }.values.map { same -> same.maxBy { it.atMs } }.sortedByDescending { it.atMs }.take(20)
|
||||
target.writeText(JSONArray(latest.map { it.toJson() }).toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** What one box sends another: plain settings and small files, read from the open workspace. Never a password or token. */
|
||||
internal object RoomBundle {
|
||||
private fun prefsJson(context: Context, name: String, keys: List<String>?): JSONObject {
|
||||
@@ -119,7 +157,10 @@ internal object RoomBundle {
|
||||
// Same schedules as this room, if the new one chooses: the plans, where each channel is up to, and the Drive-In's
|
||||
// bookings and tickets, copied once, so the same programme is on in both rooms.
|
||||
.put("schedules", gzip(files(dir, dir.list().orEmpty().filter { ScheduleFiles.matches(it) }.sorted()).toString()))
|
||||
.put(RoomPart.Family.name, JSONObject().put("profiles", prefsJson(context, "orbit_profiles", null)).put("lock", prefsJson(context, "orbit_lock", listOf("after_dark_salt", "after_dark_pin"))))
|
||||
.put(RoomPart.Family.name, JSONObject().put("profiles", prefsJson(context, "orbit_profiles", null)).put("lock", prefsJson(context, "orbit_lock", listOf("after_dark_salt", "after_dark_pin")))
|
||||
// Each person's Taste and Continue watching (Rooms sync, 7 November 2026): merged on arrival, never overwriting.
|
||||
.put("people", gzip(files(dir, dir.list().orEmpty().filter { FamilyFiles.matches(it) }.sorted() +
|
||||
File(dir, "taste").list().orEmpty().filter { TasteFiles.matches(it) }.sorted().map { "taste/$it" }).toString())))
|
||||
.put(RoomPart.Look.name, prefsJson(context, "orbit_settings", LookKeys))
|
||||
.put(RoomPart.Director.name, files(dir, DirectorFiles))
|
||||
.put(RoomPart.Arcade.name, prefsJson(context, "orbit_settings", ArcadeKeys))
|
||||
@@ -130,7 +171,12 @@ internal object RoomBundle {
|
||||
if (RoomPart.Look in parts) { putPrefs(context, "orbit_settings", bundle.optJSONObject(RoomPart.Look.name), LookKeys); OrbitTheme.load(context) }
|
||||
if (RoomPart.Arcade in parts) putPrefs(context, "orbit_settings", bundle.optJSONObject(RoomPart.Arcade.name), ArcadeKeys)
|
||||
if (RoomPart.Family in parts) bundle.optJSONObject(RoomPart.Family.name)?.let { f ->
|
||||
putPrefs(context, "orbit_profiles", f.optJSONObject("profiles"), listOf("profiles", "kids_on"))
|
||||
// Everyone from both rooms: the same profile id is the same person, the sender's details winning.
|
||||
val incoming = runCatching { f.getJSONObject("profiles").getJSONObject("profiles").getString("v") }.getOrNull()
|
||||
val here = context.getSharedPreferences("orbit_profiles", Context.MODE_PRIVATE).getString("profiles", null)
|
||||
putPrefs(context, "orbit_profiles", f.optJSONObject("profiles"), listOf("kids_on"))
|
||||
if (incoming != null) runCatching { mergedProfiles(here?.let { Profiles.decode(it) }.orEmpty(), Profiles.decode(incoming)) }.getOrNull()?.let { merged ->
|
||||
context.getSharedPreferences("orbit_profiles", Context.MODE_PRIVATE).edit().putString("profiles", Profiles.encode(merged)).apply() }
|
||||
putPrefs(context, "orbit_lock", f.optJSONObject("lock"), listOf("after_dark_salt", "after_dark_pin"))
|
||||
AfterDarkLock.load(context); Profiles.load(context)
|
||||
}
|
||||
@@ -150,6 +196,8 @@ internal object RoomBundle {
|
||||
lineup = c.optJSONArray("lineup")?.let { a -> (0 until minOf(a.length(), 200)).map { a.getInt(it) } }.orEmpty()
|
||||
}
|
||||
if (RoomPart.Director in parts) write(bundle.optJSONObject(RoomPart.Director.name))
|
||||
if (RoomPart.Family in parts) bundle.optJSONObject(RoomPart.Family.name)?.optString("people")?.takeIf { it.isNotBlank() }?.let { packed ->
|
||||
runCatching { mergeFamilyFiles(dir, JSONObject(gunzip(packed))) } }
|
||||
// Only with the channels: a schedule is for a channel that's on. Never over a schedule this box already has.
|
||||
if (sameSchedules && RoomPart.Channels in parts) bundle.optString("schedules").takeIf { it.isNotBlank() }?.let { packed ->
|
||||
runCatching { JSONObject(gunzip(packed)).let { files -> files.keys().forEach { n ->
|
||||
|
||||
@@ -166,6 +166,7 @@ internal class ScheduleStore(private val directory: File) {
|
||||
}
|
||||
|
||||
/** Files that wouldn't play on this box, across every channel. Never planned again. */
|
||||
fun unplayable() = UnplayableLog(File(directory, "failed-reasons-0.json"))
|
||||
fun saveFailed(userId: String, ids: Set<String>) =
|
||||
write(file("failed", 0), root(userId, 0).put("items", JSONArray(ids.toList())))
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,8 @@ import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import androidx.tv.material3.Text
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@@ -279,7 +281,7 @@ private fun ViewingDetail(firstSwitch: FocusRequester, modifier: Modifier, top:
|
||||
SettingLine("Idents", "Play each channel's ident between programmes. When off, Tots shows a still picture instead.") {
|
||||
OnOff(idents, Modifier, onClick = { idents = !idents; settings.idents = idents })
|
||||
}
|
||||
SettingLine("Ident sound", "Let Tots play its jingle, and channels with a sound of their own (Mistletoe, Sakura, Signature, Unscripted) play theirs, never too often.") {
|
||||
SettingLine("Ident sound", "Each channel's ident plays its own short sound, at most every 20 minutes a channel; Tots plays its jingle.") {
|
||||
OnOff(identSound, Modifier, onClick = { identSound = !identSound; settings.identSound = identSound })
|
||||
}
|
||||
SettingLine("Special idents", "Give named blocks and events their own ident as they begin, such as Riot Laughs or PPV Sunday. Off uses each channel's usual ident.") {
|
||||
@@ -350,7 +352,25 @@ private fun RoomsDetail(firstSwitch: FocusRequester, modifier: Modifier) {
|
||||
var adding by remember { mutableStateOf(false) }
|
||||
var naming by remember { mutableStateOf(false) }
|
||||
var connecting by remember { mutableStateOf(false) }
|
||||
var bringing by remember { mutableStateOf(false) }
|
||||
var brought by remember { mutableStateOf<String?>(null) }
|
||||
if (adding) { AddRoomPanel(onClose = { adding = false }, modifier = modifier); return }
|
||||
// Rooms sync (Paul, 7 November 2026): a TV already set up can bring in another room's family, Taste and Continue watching.
|
||||
// What's ticked is merged: people join, events join by id, nothing here is overwritten, and no schedule or channel changes.
|
||||
if (bringing) {
|
||||
Dialog(onDismissRequest = { bringing = false }, properties = DialogProperties(usePlatformDefaultWidth = false)) {
|
||||
Box(Modifier.fillMaxSize().background(Navy)) {
|
||||
JoinRoomFlow(onJoined = {
|
||||
RoomArrival.bundle?.let { got ->
|
||||
runCatching { RoomBundle.applyToWorkspace(Workspaces.current(context).scheduleDir, got, RoomArrival.parts - RoomPart.Channels, sameSchedules = false) }
|
||||
brought = "Brought in from ${got.optString("room").ifBlank { "the other room" }}."
|
||||
}
|
||||
RoomArrival.done(); bringing = false
|
||||
}, onBack = { RoomArrival.done(); bringing = false })
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
if (connecting) {
|
||||
// Orbit Companion (Paul, 6 November 2026): the same one-time code as Create your own's, from where phones are listed.
|
||||
BackHandler { connecting = false }
|
||||
@@ -372,6 +392,9 @@ private fun RoomsDetail(firstSwitch: FocusRequester, modifier: Modifier) {
|
||||
listOf("Living Room", "Lounge", "Bedroom", "Kids' room", "Kitchen", "Den").forEach { n -> OrbitButton(n, selected = n == Rooms.name, onClick = { Rooms.rename(context, n); naming = false }) }
|
||||
}
|
||||
Heading("Other rooms")
|
||||
SettingLine("Bring in from another room", brought ?: "Everyone's profiles, what Orbit has learnt for each, and their Continue watching, merged in from a TV that's already set up. Channels and schedules here stay as they are.") {
|
||||
OrbitButton("Bring in", onClick = { bringing = true })
|
||||
}
|
||||
SettingLine("Add a room", "Set up Orbit on another TV in your home by copying this one: channels, profiles, look and more. Your password never travels.") {
|
||||
OrbitButton("Add a room", onClick = { adding = true })
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Files that won't play, with why (Paul, 7 November 2026: The Twilight Zone S1 E3 failed and nobody knew). The player notes the
|
||||
* reason as it gives up on a file; the list beside the failed list keeps it, with the title and channel, so the phone's Director's
|
||||
* Chair can show each one and offer Try again. Only names, channels and the player's own error kinds are kept.
|
||||
*/
|
||||
internal object Unplayable {
|
||||
private val pending = HashMap<String, Triple<String, Int?, String>>()
|
||||
/** Noted by the player just before it reports [itemId] as unplayable. */
|
||||
@Synchronized fun note(itemId: String, title: String, channel: Int?, reason: String) { pending[itemId] = Triple(title, channel, reason) }
|
||||
@Synchronized fun take(itemId: String) = pending.remove(itemId)
|
||||
}
|
||||
|
||||
/** The player's error kind, in a sentence someone can act on. */
|
||||
internal fun unplayableReason(errorCodeName: String?, detail: String? = null): String = when {
|
||||
errorCodeName == null && detail != null -> detail
|
||||
errorCodeName == null -> "It stopped without saying why."
|
||||
"PARSING" in errorCodeName -> "The file's structure couldn't be read (${detail ?: errorCodeName})."
|
||||
"DECODER" in errorCodeName || "DECODING" in errorCodeName -> "This TV can't decode its picture or sound."
|
||||
"IO_" in errorCodeName -> "The file couldn't be fetched from the server."
|
||||
"AUDIO_TRACK" in errorCodeName -> "Its sound couldn't be played on this TV."
|
||||
else -> "The player stopped ($errorCodeName)."
|
||||
}
|
||||
|
||||
/** The reasons file: one entry per failed item, `{title, channel, reason, at}`. */
|
||||
internal class UnplayableLog(private val file: File) {
|
||||
@Synchronized fun all(): Map<String, JSONObject> = runCatching { JSONObject(file.readText()).let { o -> o.keys().asSequence().associateWith { o.getJSONObject(it) } } }.getOrDefault(emptyMap())
|
||||
@Synchronized fun add(itemId: String, title: String, channel: Int?, reason: String, nowMs: Long) {
|
||||
val o = runCatching { JSONObject(file.readText()) }.getOrDefault(JSONObject())
|
||||
o.put(itemId, JSONObject().put("title", title.take(160)).put("channel", channel ?: JSONObject.NULL).put("reason", reason.take(240)).put("at", nowMs))
|
||||
file.writeText(o.toString())
|
||||
}
|
||||
@Synchronized fun remove(itemId: String) {
|
||||
val o = runCatching { JSONObject(file.readText()) }.getOrNull() ?: return
|
||||
o.remove(itemId); file.writeText(o.toString())
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,54 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
/** Rooms sync (7 November 2026): profiles, Taste and Continue watching merge between rooms, never overwriting or doubling. */
|
||||
class RoomsFamilyTest {
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
@Test fun profilesFromBothRoomsJoin() {
|
||||
val wife = Profile("pwife01", "Wife", "sil-pink", ProfileKind.Grown)
|
||||
val renamed = DefaultProfiles.first().copy(name = "Paul")
|
||||
val merged = mergedProfiles(DefaultProfiles, listOf(renamed, DefaultProfiles[1], wife))
|
||||
assertEquals(listOf("grown", "kids", "pwife01"), merged.map { it.id })
|
||||
assertEquals("Paul", merged.first().name)
|
||||
}
|
||||
|
||||
@Test fun tasteAndContinueWatchingMergeByIdAndLatest() {
|
||||
val dir = tmp.newFolder("schedule")
|
||||
val now = 1_794_000_000_000L
|
||||
fun ev(id: String, item: String, at: Long) = TasteEvent(id, "grown", TasteKind.Chose, item, null, "T", 106, at, null, "test")
|
||||
java.io.File(dir, "taste").mkdirs()
|
||||
java.io.File(dir, "taste/grown.events.jsonl").writeText(ev("a", "1001", now - 5_000).toLine() + "\n")
|
||||
java.io.File(dir, "taste/grown.state.json").writeText(TasteState(false).toJson().toString())
|
||||
java.io.File(dir, "continue-grown.json").writeText(JSONArray(listOf(ContinueMark(106, 10, "1001", 60_000, 2_700_000, now - 9_000).toJson())).toString())
|
||||
val incoming = JSONObject()
|
||||
.put("taste/grown.events.jsonl", ev("a", "1001", now - 5_000).toLine() + "\n" + ev("b", "1002", now - 1_000).toLine() + "\n")
|
||||
.put("taste/grown.state.json", TasteState(true).toJson().toString())
|
||||
.put("taste/pwife01.events.jsonl", TasteEvent("c", "pwife01", TasteKind.Saved, "2001", null, "W", 205, now, null, "test").toLine() + "\n")
|
||||
.put("continue-grown.json", JSONArray(listOf(ContinueMark(106, 10, "1001", 900_000, 2_700_000, now - 1_000).toJson())).toString())
|
||||
.put("../evil.json", "x")
|
||||
mergeFamilyFiles(dir, incoming, now)
|
||||
val events = java.io.File(dir, "taste/grown.events.jsonl").readLines().mapNotNull { TasteEvent.of(it) }
|
||||
assertEquals(listOf("a", "b"), events.map { it.id })
|
||||
assertFalse("this room's own Personalise choice stays", JSONObject(java.io.File(dir, "taste/grown.state.json").readText()).getBoolean("personalise"))
|
||||
assertTrue(java.io.File(dir, "taste/pwife01.events.jsonl").exists())
|
||||
val marks = JSONArray(java.io.File(dir, "continue-grown.json").readText())
|
||||
assertEquals(1, marks.length()); assertEquals(900_000L, marks.getJSONObject(0).getLong("p"))
|
||||
assertFalse(java.io.File(tmp.root, "evil.json").exists())
|
||||
}
|
||||
|
||||
@Test fun unplayableReasonsReadPlainly() {
|
||||
assertTrue(unplayableReason("ERROR_CODE_PARSING_CONTAINER_MALFORMED", "ContentCompAlgo 0").startsWith("The file's structure"))
|
||||
assertEquals("This TV can't decode its picture or sound.", unplayableReason("ERROR_CODE_DECODER_INIT_FAILED"))
|
||||
val log = UnplayableLog(java.io.File(tmp.root, "failed-reasons-0.json"))
|
||||
log.add("7542928", "The Twilight Zone / S1 E3", 106, "x", 1); log.add("1", "Other", null, "y", 2)
|
||||
log.remove("1")
|
||||
assertEquals(setOf("7542928"), log.all().keys)
|
||||
}
|
||||
}
|
||||
@@ -190,6 +190,150 @@ def unscripted():
|
||||
return fade_out(reverb(b, .2, .9))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# ---- Every other channel (Paul, 7 November 2026: "sound for the remaining idents") ----------------------------------------
|
||||
# One family of sound per kind of channel, each channel its own key and motif, so they sound related but never the same.
|
||||
|
||||
MAJOR = [0, 2, 4, 7, 9, 12, 14, 16]
|
||||
MINOR = [0, 3, 7, 10, 12, 15, 19]
|
||||
|
||||
|
||||
def hz(root, semis):
|
||||
return root * 2 ** (semis / 12)
|
||||
|
||||
|
||||
def fam_bright(seed, root):
|
||||
"""Entertainment: a piano-bell arpeggio rising into a warm major chord."""
|
||||
random.seed(seed); b = blank()
|
||||
steps = random.sample(MAJOR[:6], 4); steps.sort()
|
||||
for k, s in enumerate(steps):
|
||||
add_bell(b, 1.2 + k * .16, hz(root * 2, s), .3, 1.8, ((1, 1), (2, .4), (3, .18), (4.02, .08)))
|
||||
add_pad(b, 1.0, 5.4, [hz(root, s) for s in (0, 7, 16, 23)], .45, attack=1.0)
|
||||
add_bell(b, 2.9, hz(root * 4, steps[-1]), .14, 2.0)
|
||||
return fade_out(reverb(b, .28, 1.1))
|
||||
|
||||
|
||||
def fam_mystery(seed, root):
|
||||
"""Mystery and crime: a low thud, a minor cluster creeping in, a cold bell with a tritone under it."""
|
||||
random.seed(seed); b = blank()
|
||||
add_thump(b, .5, .5, 70, 35, .8)
|
||||
add_pad(b, .6, 5.5, [hz(root / 2, s) for s in (0, 3, 7, 13)], .5, attack=2.2, harmonics=(1, .25, .1), detune=.006)
|
||||
add_bell(b, 2.8, hz(root * 2, 0), .22, 2.6); add_bell(b, 2.8, hz(root * 2, 6), .1, 2.4)
|
||||
return fade_out(reverb(b, .38, 1.4))
|
||||
|
||||
|
||||
def fam_nature(seed, root):
|
||||
"""Nature and the world: marimba rolling a pentatonic phrase over an open, airy fifth."""
|
||||
random.seed(seed); b = blank()
|
||||
phrase = [0, 2, 4, 7, 9, 12, 9, 14]
|
||||
for k, s in enumerate(phrase[: random.choice((5, 6, 7))]):
|
||||
add_bell(b, .9 + k * .17, hz(root * 2, s), .3, .55, ((1, 1), (3.99, .3), (10.1, .06)))
|
||||
add_pad(b, .8, 5.6, [hz(root / 2, 0), hz(root / 2, 7), hz(root, 14)], .42, attack=1.6, harmonics=(1, .18))
|
||||
add_bell(b, 2.9, hz(root * 4, 7), .12, 2.4)
|
||||
return fade_out(reverb(b, .32, 1.3))
|
||||
|
||||
|
||||
def fam_kitchen(seed, root):
|
||||
"""Food and home: a bright ukulele-ish strum and a friendly two-note button."""
|
||||
random.seed(seed); b = blank()
|
||||
for t in (.6, 1.0, 1.4, 1.65):
|
||||
for k, s in enumerate((0, 4, 7, 12)):
|
||||
add_pluck(b, t + k * .012, hz(root * 2, s), .22, .993, .65)
|
||||
add_clap(b, 2.0, .2)
|
||||
add_bell(b, 2.6, hz(root * 4, 4), .2, .9); add_bell(b, 2.85, hz(root * 4, 12), .22, 1.4)
|
||||
return fade_out(reverb(b, .22, .9))
|
||||
|
||||
|
||||
def fam_cinema(seed, root, minor=False, pulses=False, glide=False, wobble=False):
|
||||
"""Films: a swell into a brass-like chord and a timpani hit, with a flavour for each channel."""
|
||||
random.seed(seed); b = blank()
|
||||
chord = (0, 3, 7, 12) if minor else (0, 4, 7, 12)
|
||||
add_pad(b, .3, 5.2, [hz(root / 2, s) for s in chord], .55, attack=2.4, harmonics=(1, .6, .4, .28, .18, .1), detune=.008 if wobble else .003)
|
||||
if pulses:
|
||||
for k in range(10): add_thump(b, .3 + k * .25, .22 + k * .02, 80, 50, .12)
|
||||
if glide:
|
||||
s0 = int(.6 * SR)
|
||||
for i in range(int(2.2 * SR)):
|
||||
t = i / SR; f = hz(root * 4, 0) * (1.6 - .6 * min(1, t / 2.2))
|
||||
b[s0 + i] += .08 * math.sin(2 * math.pi * f * t) * math.sin(math.pi * t / 2.2)
|
||||
add_thump(b, 2.8, .7, 120, 48, .6)
|
||||
add_bell(b, 2.8, hz(root * 2, chord[2]), .14, 1.6, ((1, 1), (2, .5), (3, .3)))
|
||||
return fade_out(reverb(b, .3, 1.3))
|
||||
|
||||
|
||||
def fam_horror(seed, root):
|
||||
"""Horror: a low drone, a creeping minor-second cluster and one high, glassy note."""
|
||||
random.seed(seed); b = blank()
|
||||
add_pad(b, .2, 5.6, [hz(root / 4, 0), hz(root / 2, 1), hz(root / 2, 6)], .55, attack=2.6, harmonics=(1, .3, .15), detune=.01)
|
||||
add_bell(b, 2.9, hz(root * 8, 1), .1, 3.0, ((1, 1), (2.01, .2)))
|
||||
add_thump(b, 2.9, .5, 60, 30, 1.0)
|
||||
return fade_out(reverb(b, .45, 1.5))
|
||||
|
||||
|
||||
def fam_romance(seed, root):
|
||||
"""Romance: a gentle piano phrase over strings."""
|
||||
random.seed(seed); b = blank()
|
||||
for k, s in enumerate((7, 4, 9, 7, 12)):
|
||||
add_bell(b, .8 + k * .3, hz(root * 2, s), .24, 2.2, ((1, 1), (2, .3), (3, .12)))
|
||||
add_pad(b, .8, 5.6, [hz(root, s) for s in (0, 4, 7, 11)], .45, attack=1.8, harmonics=(1, .4, .2))
|
||||
return fade_out(reverb(b, .35, 1.3))
|
||||
|
||||
|
||||
def fam_christmas(seed, root):
|
||||
"""Christmas: sleigh bells and a celesta tune."""
|
||||
random.seed(seed); b = blank()
|
||||
add_sleigh(b, .1, 3.0, .08)
|
||||
for k, s in enumerate((7, 7, 9, 7, 12, 11)):
|
||||
add_bell(b, .9 + k * .22, hz(root * 2, s), .26, 1.2)
|
||||
add_pad(b, 1.2, 5.6, [hz(root / 2, s) for s in (0, 7, 16)], .4, attack=1.2)
|
||||
return fade_out(reverb(b, .3, 1.1))
|
||||
|
||||
|
||||
def fam_sport(seed, root):
|
||||
"""Sport: drum hits building to a bright stab."""
|
||||
random.seed(seed); b = blank()
|
||||
for k, t in enumerate((.4, .7, 1.0, 1.15, 1.3, 1.45, 1.6, 1.75)):
|
||||
add_thump(b, t, .4 + k * .04, 110, 50, .15)
|
||||
add_clap(b, 1.9, .3)
|
||||
for s in (0, 4, 7, 12): add_bell(b, 2.0, hz(root, s), .16, .8, ((1, 1), (2, .6), (3, .4), (4, .3), (5, .2)))
|
||||
add_thump(b, 2.0, .7, 100, 40, .5)
|
||||
return fade_out(reverb(b, .2, .9))
|
||||
|
||||
|
||||
def fam_kids(seed, root):
|
||||
"""Kids: a bouncy xylophone tune and a springy boing."""
|
||||
random.seed(seed); b = blank()
|
||||
tune = random.choice([(0, 4, 7, 12, 7, 12), (0, 2, 4, 7, 4, 12), (7, 4, 0, 4, 7, 12)])
|
||||
for k, s in enumerate(tune):
|
||||
add_bell(b, .7 + k * .18, hz(root * 2, s), .3, .35, ((1, 1), (3.93, .35), (9.2, .1)))
|
||||
s0 = int(2.0 * SR)
|
||||
for i in range(int(.6 * SR)):
|
||||
t = i / SR; f = 180 + 260 * math.exp(-t / .12) + 18 * math.sin(2 * math.pi * 14 * t)
|
||||
b[s0 + i] += .18 * math.exp(-t / .25) * math.sin(2 * math.pi * f * t)
|
||||
add_bell(b, 2.6, hz(root * 4, 0), .18, 1.2, ((1, 1), (3.93, .3)))
|
||||
return fade_out(reverb(b, .2, .9))
|
||||
|
||||
|
||||
C3 = note("C3")
|
||||
CHANNELS = {
|
||||
101: (fam_bright, 0), 102: (fam_bright, 5), 103: (fam_romance, 1), 104: (fam_bright, 3), 105: (fam_kitchen, 7), 106: (fam_mystery, 9),
|
||||
107: (fam_mystery, 2), 108: (fam_bright, 7), 201: (fam_nature, 2), 202: (fam_nature, 5), 203: (fam_nature, 7), 204: (fam_mystery, 4),
|
||||
205: (fam_kitchen, 0), 206: (fam_kitchen, 5), 301: (lambda s, r: fam_cinema(s, r), 0), 302: (lambda s, r: fam_cinema(s, r, minor=True, pulses=True), 2),
|
||||
303: (lambda s, r: fam_cinema(s, r, glide=True), 7), 304: (fam_horror, 1), 305: (lambda s, r: fam_cinema(s, r, minor=True), 5),
|
||||
306: (lambda s, r: fam_cinema(s, r, wobble=True), 3), 307: (fam_romance, 5), 308: (lambda s, r: fam_cinema(s, r, pulses=True), 9),
|
||||
309: (lambda s, r: fam_cinema(s, r), 10), 310: (fam_christmas, 0), 401: (fam_sport, 2), 601: (lambda s, r: fam_cinema(s, r, glide=True, minor=True), 9),
|
||||
602: (fam_kids, 2), 603: (fam_kids, 7), 604: (fam_kids, 5), 605: (fam_kids, 0), 611: (fam_kids, 4), 612: (fam_kids, 9), 613: (fam_kids, 11),
|
||||
}
|
||||
|
||||
|
||||
def build_channels():
|
||||
for number, (family, key) in CHANNELS.items():
|
||||
write(f"ch{number}", family(number, hz(C3, key))); print("wrote", number)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
for name, make in (("mistletoe", mistletoe), ("sakura", sakura), ("signature", signature), ("unscripted", unscripted)):
|
||||
write(name, make()); print("wrote", name)
|
||||
build_channels()
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
Reference in New Issue
Block a user