Morning fixes and VHS/Horror samples. Ported from release-0.108 (0.108.104)
Continue watching from Catch Up only, Companion stays up in the background, guide clock right after full screen. Paul's royalty-free Pixabay cassette and scream samples (design/channels/sound/samples) laid into the ch306 and ch304 stings by build-samples.py and delivered to the standard; the synth-only stings are kept as sting-synth.wav. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -157,7 +157,9 @@ function nowCard() {
|
||||
}
|
||||
function remote() {
|
||||
const q = state.now?.queue || [];
|
||||
return head('Remote') + nowCard() + (q.length ? `<div class="small" style="margin-top:8px;flex:none;text-align:center">Then from your queue: <b style="color:var(--ink)">${esc(q[0].title)}</b>${q.length > 1 ? ` +${q.length - 1} more` : ''}</div>` : '') + `
|
||||
// Orbit in the background on the TV (another app on screen): connected, but say so rather than seem broken.
|
||||
const away = state.now && state.now.onTv === false ? `<div class="card small" style="margin-bottom:10px;border:2px solid var(--accent)"><b style="color:var(--ink)">Orbit isn't on screen on ${esc(room())}.</b> Another app is showing. Open Orbit on the TV and the remote works again.</div>` : '';
|
||||
return head('Remote') + away + nowCard() + (q.length ? `<div class="small" style="margin-top:8px;flex:none;text-align:center">Then from your queue: <b style="color:var(--ink)">${esc(q[0].title)}</b>${q.length > 1 ? ` +${q.length - 1} more` : ''}</div>` : '') + `
|
||||
<div class="padwrap"><div class="pad"><button class="up" data-key="up" aria-label="Up">${I.chev('up')}</button><button class="left" data-key="left" aria-label="Left">${I.chev('left')}</button>
|
||||
<button class="ok" data-key="ok">OK</button><button class="right" data-key="right" aria-label="Right">${I.chev('right')}</button><button class="down" data-key="down" aria-label="Down">${I.chev('down')}</button></div></div>
|
||||
<div class="row"><button class="round" data-key="back" aria-label="Back">${I.back}</button>
|
||||
@@ -858,6 +860,9 @@ document.addEventListener('click', e => {
|
||||
offerHome(); render(); (keptLook() || tab === 'more' ? load('more') : Promise.resolve()).then(() => load('now')); if (tab !== 'remote' && tab !== 'more') load(tab);
|
||||
// Kept fresh while the phone is looking: what's on every 15 seconds, and the open list every minute.
|
||||
setInterval(() => { if (!document.hidden) load('now'); }, 15000);
|
||||
// When the TV couldn't be reached, try again every few seconds, so the web app reconnects by itself (8 November 2026).
|
||||
setInterval(() => { if (!document.hidden && offline) load('now'); }, 4000);
|
||||
document.addEventListener('visibilitychange', () => { if (!document.hidden) load('now'); });
|
||||
setInterval(() => { if (!document.hidden && ['guide','catchup','rooms'].includes(tab)) load(tab); }, 60000);
|
||||
document.addEventListener('visibilitychange', () => { if (!document.hidden) load('now'); });
|
||||
</script>
|
||||
|
||||
@@ -151,7 +151,8 @@ internal fun catchUpMatches(entry: CatchUpEntry, channel: Int?, query: String):
|
||||
internal fun CatchUpScreen(channels: List<SampleChannel>, session: EmbySampleSession?, modifier: Modifier = Modifier, onOpen: (CatchUpEntry) -> Unit,
|
||||
onResume: (ContinueEntry) -> Unit = {}) {
|
||||
var now by remember { mutableLongStateOf(System.currentTimeMillis()) }
|
||||
LaunchedEffect(Unit) { while (true) { delay(30_000); if (!FullScreen.active) now = System.currentTimeMillis() } }
|
||||
val fullScreen = FullScreen.active
|
||||
LaunchedEffect(fullScreen) { if (!fullScreen) now = System.currentTimeMillis(); while (true) { delay(30_000); if (!FullScreen.active) now = System.currentTimeMillis() } }
|
||||
var channelFilter by remember { mutableStateOf<Int?>(null) }
|
||||
var query by remember { mutableStateOf("") }
|
||||
var searching by remember { mutableStateOf(false) }
|
||||
|
||||
@@ -8,7 +8,8 @@ import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Continue watching (Paul, 7 November 2026): where you left a programme part-way, from Catch Up or live, so Catch Up can
|
||||
* Continue watching (Paul, 7 November 2026): where you left a programme part-way in Catch Up (live viewing isn't counted, since
|
||||
* 8 November 2026), so Catch Up can
|
||||
* carry it on from there while it's still in Catch Up. One list per profile, on this box only. It only reads the plans.
|
||||
*/
|
||||
internal class ContinueMark(val number: Int, val startMs: Long, val itemId: String, val positionMs: Long, val durationMs: Long, val atMs: Long) {
|
||||
@@ -63,6 +64,12 @@ internal object ContinueWatching {
|
||||
private var file: File? = null
|
||||
|
||||
fun load(scheduleDir: File, profile: String?) {
|
||||
// Once: the lists made while live viewing counted too are set aside, now that only Catch Up adds to them.
|
||||
val flag = File(scheduleDir, "continue-catchup-only")
|
||||
if (!flag.exists()) runCatching {
|
||||
scheduleDir.listFiles { f -> Regex("continue-[A-Za-z0-9]{1,40}\\.json").matches(f.name) }?.forEach { it.renameTo(File(scheduleDir, it.name + ".before-catchup-only")) }
|
||||
flag.writeText("")
|
||||
}
|
||||
file = File(scheduleDir, "continue-${(profile ?: "all").filter { it.isLetterOrDigit() }.take(40)}.json")
|
||||
marks = runCatching { JSONArray(file!!.readText()).let { a -> (0 until minOf(a.length(), CONTINUE_MAX)).mapNotNull { runCatching { ContinueMark.fromJson(a.getJSONObject(it)) }.getOrNull() } } }.getOrDefault(emptyList())
|
||||
}
|
||||
|
||||
@@ -327,7 +327,8 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
catch (_: Exception) { message = "Connected, but this setup could not be saved securely. It will need sign-in after restart." }
|
||||
}
|
||||
}
|
||||
LaunchedEffect(Unit) { while (true) { delay(1000); if (!FullScreen.active) now = System.currentTimeMillis() } }
|
||||
val fullScreen = FullScreen.active
|
||||
LaunchedEffect(fullScreen) { if (!fullScreen) now = System.currentTimeMillis(); while (true) { delay(1000); if (!FullScreen.active) now = System.currentTimeMillis() } }
|
||||
LaunchedEffect(scheduledChannels) { windingDown = scheduledChannels[TOTS_NUMBER]?.stepIn?.let { it.endMs > System.currentTimeMillis() } == true }
|
||||
fun smartLoop(programming: ChannelProgramming) = (extraChannels + listOfNotNull(channel, afterDarkChannel, toonamiChannel)).firstOrNull { it.number == programming.number }
|
||||
LaunchedEffect(session != null) { if (session != null) onSignedIn() }
|
||||
@@ -380,7 +381,8 @@ internal fun EmbyConnectionScreen(modifier: Modifier = Modifier, visible: Boolea
|
||||
val now = System.currentTimeMillis(); val at = now + channelClockOffset
|
||||
val show = runCatching { channel.at(at) }.getOrNull() ?: continue
|
||||
if (show.endMs - show.startMs < 10 * 60_000L) continue
|
||||
runCatching { withContext(Dispatchers.IO) { ContinueWatching.note(channel.number, show, at - show.startMs, now) } }
|
||||
// Continue watching is for Catch Up only (Paul, 8 November 2026): what you watch live isn't added to it.
|
||||
if (channelClockOffset < 0) runCatching { withContext(Dispatchers.IO) { ContinueWatching.note(channel.number, show, at - show.startMs, now) } }
|
||||
runCatching { withContext(Dispatchers.IO) { Taste.watching(channel.number, show, channel.seriesIdAt(show.startMs), at - show.startMs, now) } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ internal fun clock(time: Long) = SimpleDateFormat("HH:mm", Locale.UK).format(Dat
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onStart() {
|
||||
super.onStart(); if (PhoneLink.phones.isNotEmpty()) PhoneLink.start()
|
||||
super.onStart(); OrbitCompanion.onTv = true; if (PhoneLink.phones.isNotEmpty()) PhoneLink.start()
|
||||
// Multiroom auto-scan: a set-up Orbit can be found by a new TV while it's open.
|
||||
if (Onboarding.done(this)) {
|
||||
RoomBeacon.on(this)
|
||||
@@ -54,7 +54,9 @@ class MainActivity : ComponentActivity() {
|
||||
lifecycleScope.launch { runCatching { RoomUpdates.look(this@MainActivity) } }
|
||||
}
|
||||
}
|
||||
override fun onStop() { RoomBeacon.off(this); PhoneLink.offerRoom(null); PhoneLink.stop(); super.onStop() }
|
||||
// Phones stay connected while Orbit is in the background (Paul, 8 November 2026: the web app couldn't connect while the TV
|
||||
// was in another app), and paired rooms keep syncing; the phone says Orbit isn't on screen instead of failing to load.
|
||||
override fun onStop() { OrbitCompanion.onTv = false; PhoneLink.offerRoom(null); if (PhoneLink.phones.isEmpty() && RoomLinks.links.none { it.on }) { RoomBeacon.off(this); PhoneLink.stop() }; super.onStop() }
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
OrbitCompanion.activity = java.lang.ref.WeakReference(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@@ -122,6 +122,8 @@ internal object OrbitCompanion {
|
||||
private fun channelJson(c: SampleChannel) = JSONObject().put("number", c.number).put("name", ChannelBrands.forNumber(c.number)?.displayName ?: c.name)
|
||||
|
||||
/** What the TV is on: the chosen channel, what it's showing at the TV's clock, and what's next. */
|
||||
/** Orbit is on the TV's screen; false while the TV shows another app (phones and paired rooms still connect). */
|
||||
@Volatile var onTv = true
|
||||
fun now(screen: CompanionScreen, nowMs: Long): JSONObject {
|
||||
val reply = JSONObject().put("room", Rooms.name).put("look", look()).put("serverMs", nowMs)
|
||||
val channel = screen.channels().firstOrNull { it.number == screen.selected() } ?: return reply.put("channel", JSONObject.NULL)
|
||||
|
||||
@@ -491,7 +491,7 @@ internal object PhoneLink {
|
||||
fun body() = runCatching { JSONObject(r.body) }.getOrNull() ?: JSONObject()
|
||||
fun onScreen(block: () -> Unit) = runBlocking { withContext(mainDispatcher) { block() } }
|
||||
when ("${r.method} ${r.path}") {
|
||||
"GET /api/now" -> json(out, 200, OrbitCompanion.now(s, now).put("queue", OrbitCompanion.queueJson()))
|
||||
"GET /api/now" -> json(out, 200, OrbitCompanion.now(s, now).put("queue", OrbitCompanion.queueJson()).put("onTv", OrbitCompanion.onTv))
|
||||
"GET /api/guide" -> json(out, 200, OrbitCompanion.guide(s, now))
|
||||
"GET /api/catchup" -> json(out, 200, JSONObject().put("shelves", OrbitCompanion.catchUp(s, now)))
|
||||
"GET /api/rooms" -> json(out, 200, OrbitCompanion.rooms(appContext))
|
||||
|
||||
@@ -15,7 +15,10 @@ import kotlinx.coroutines.delay
|
||||
@Composable
|
||||
internal fun rememberMinuteClock(): State<Long> {
|
||||
val now = remember { mutableLongStateOf(System.currentTimeMillis()) }
|
||||
LaunchedEffect(Unit) {
|
||||
// Back from full screen: the time is put right at once, not when the next minute turns (Paul, 8 November 2026).
|
||||
val full = FullScreen.active
|
||||
LaunchedEffect(full) {
|
||||
if (!full) now.longValue = System.currentTimeMillis()
|
||||
while (true) {
|
||||
val at = System.currentTimeMillis()
|
||||
delay(MINUTE_MS - at % MINUTE_MS + 50)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,20 @@
|
||||
package tv.orbit.classic
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import java.nio.file.Files
|
||||
|
||||
/** 8 November 2026: the lists made while live viewing counted are set aside once, and a new list then stays. */
|
||||
class ContinueCatchUpOnlyTest {
|
||||
@Test fun oldListsAreSetAsideOnceOnly() {
|
||||
val dir = Files.createTempDirectory("cw").toFile()
|
||||
val mark = ContinueMark(304, 1000, "abc123", 600_000, 3_600_000, 2000)
|
||||
java.io.File(dir, "continue-grown.json").writeText(org.json.JSONArray(listOf(mark.toJson())).toString())
|
||||
ContinueWatching.load(dir, "grown")
|
||||
assertTrue(ContinueWatching.marks.isEmpty())
|
||||
assertTrue(java.io.File(dir, "continue-grown.json.before-catchup-only").exists())
|
||||
java.io.File(dir, "continue-grown.json").writeText(org.json.JSONArray(listOf(mark.toJson())).toString())
|
||||
ContinueWatching.load(dir, "grown")
|
||||
assertEquals(1, ContinueWatching.marks.size)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user