Rooms sync, sound for every ident, profiles in the install check, a won't-play report
A room's copy now carries everyone's Taste and Continue watching with the profiles, merged on arrival (people join by id, events by id, the latest place wins); Settings › Rooms can bring them into a TV that's already set up without touching its channels or schedules. Every channel's ident has its own synthesised sting (Tots keeps its jingle), at most every 20 minutes a channel. The install snapshot includes profiles. Files that won't play keep their reason, shown in the phone's Director's Chair with Try again. 0.108.100. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -248,6 +248,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." })
|
||||
|
||||
|
||||
@@ -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.99\"") +
|
||||
ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.100\"") +
|
||||
(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.99\"" +
|
||||
ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.100\"" +
|
||||
(token?.let { ", Token=\"$it\"" } ?: ""))
|
||||
}
|
||||
/** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */
|
||||
|
||||
@@ -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())))
|
||||
/**
|
||||
|
||||
@@ -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.99")
|
||||
next.setRequestProperty("User-Agent", "OrbitTV/0.108.100")
|
||||
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()) {
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user