From 2f41a76cc5bb3d52c6563d0aac296cb9ed90952d Mon Sep 17 00:00:00 2001 From: Pauljd Date: Sat, 7 Nov 2026 08:30:02 +0000 Subject: [PATCH] Create a channel: watch it now, or after this programme Once a channel is made, the phone offers Watch after this programme (it joins the queue) and Watch now, waiting while its first programmes are planned. Co-Authored-By: Claude Opus 5.5 (1M context) --- android/app/build.gradle.kts | 4 +-- .../app/src/main/assets/phone/companion.html | 27 ++++++++++++++++++- .../main/java/tv/orbit/classic/EmbyClient.kt | 4 +-- .../tv/orbit/classic/SecureMediaDataSource.kt | 2 +- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index 69f14c44..66dc8114 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -9,8 +9,8 @@ android { applicationId = "tv.orbit.classic" minSdk = 26 targetSdk = 36 - versionCode = 243 - versionName = "0.108.83-smart-setup" + versionCode = 244 + versionName = "0.108.84-smart-setup" } buildFeatures { compose = true } // The finished build for the TVs (Paul, 6 November 2026: the test build stuttered on the box). Not debuggable, so diff --git a/android/app/src/main/assets/phone/companion.html b/android/app/src/main/assets/phone/companion.html index da02b864..bb005127 100644 --- a/android/app/src/main/assets/phone/companion.html +++ b/android/app/src/main/assets/phone/companion.html @@ -258,6 +258,13 @@ const SLOTS = [['Daytime','06:00 to 17:00'],['Evening','17:00 to 22:00'],['Late' const sameHours = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null); function create() { const c = state.create, d = c.draft; + if (c.done) return `
✓
+
${esc(c.done.name)} is ready on ${c.done.number}
+
${esc(c.done.message || '')}
+ ${c.watching ? `
${esc(c.watching)}
` : ''} + + +
`; const bar = `
${STEPS.map((n, i) => `
${n}
`).join('')}
`; const top = `
${d.number ? 'Edit ' + esc(d.name) : 'Create a channel'}
` + bar; @@ -374,11 +381,27 @@ async function suggestShows() { catch (e) { c.note = e.message; } c.busy = false; render(); } +// A new channel takes a moment to plan its first programmes, so the phone keeps asking until the TV can tune it. +async function watchNew(when) { + const c = state.create; if (!c?.done || c.trying) return; + c.trying = true; c.watching = 'Planning its first programmes…'; render(); + for (let i = 0; i < 30; i++) { + try { + if (when === 'now') await api('/api/tune', {number: c.done.number}); + else await api('/api/queue', {number: c.done.number}); + state.create = null; tab = 'remote'; render(); load('now'); + toast(when === 'now' ? 'On the TV now' : 'Switches when this programme ends'); return; + } catch (e) { if (!/isn't on this TV/.test(e.message)) { c.watching = e.message; break; } } + await new Promise(r => setTimeout(r, 3000)); + } + c.trying = false; if (c.watching === 'Planning its first programmes…') c.watching = "It's still planning. Try again in a minute, or find it in the Guide."; render(); +} async function makeChannel() { const c = state.create, d = c.draft; if (c.busy) return; c.busy = true; render(); 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, slots: d.style === 'Shaped' ? d.slots : undefined, core: d.style === 'Shaped' ? d.core : undefined}); - state.create = null; toast(r.message || 'Saved'); load('more'); } + // Made: offer to watch it now, or straight after the programme on the TV (Paul, 7 November 2026). + c.done = {number: r.number, name: d.name, message: r.message, edit: !!d.number}; c.busy = false; render(); load('more'); } catch (e) { c.note = e.message; c.busy = false; render(); } } @@ -496,6 +519,8 @@ document.addEventListener('click', e => { if (d.cout) { const dr = state.create.draft; dr.shows = dr.shows.filter(x => x.id !== d.cout); dr.core = dr.core.filter(x => x !== d.cout); delete dr.slots[d.cout]; if (!dr.shows.length) { state.create.step = 1; } render(); return; } if (d.cmake) { makeChannel(); return; } + if (d.cdone) { state.create = null; render(); return; } + if (d.cwatch) { watchNew(d.cwatch); return; } if (d.homedone) { try { localStorage.setItem('orbit.home', '1'); } catch {} closeSheet(); return; } if (d.install) { installAsk?.prompt(); installAsk = null; try { localStorage.setItem('orbit.home', '1'); } catch {} closeSheet(); return; } if (d.home) { openSheet(homeSteps()); return; } diff --git a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt index dc1121bb..39419b3e 100644 --- a/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt +++ b/android/app/src/main/java/tv/orbit/classic/EmbyClient.kt @@ -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 = when (kind) { - ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.83\"") + + ServerKind.Emby -> mapOf("X-Emby-Authorization" to "Emby Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.84\"") + (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.83\"" + + ServerKind.Jellyfin -> mapOf("Authorization" to "MediaBrowser Client=\"Orbit TV\", Device=\"Orbit TV\", DeviceId=\"$deviceId\", Version=\"0.108.84\"" + (token?.let { ", Token=\"$it\"" } ?: "")) } /** One picture from the provider, or nothing. Same fixed origin and no redirects, and failures are never shown or logged. */ diff --git a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt index 64180002..1b1f4e41 100644 --- a/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt +++ b/android/app/src/main/java/tv/orbit/classic/SecureMediaDataSource.kt @@ -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.83") + next.setRequestProperty("User-Agent", "OrbitTV/0.108.84") 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()) {