From 131ebf505788b126fbfade2f6b64c36fe38f3efb Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 13 Nov 2026 15:21:31 -0500 Subject: [PATCH] Overlay a three-row scrolling guide on live playback --- roku/README.md | 2 +- roku/components/Guide.brs | 132 +++++++++++++++++++-------------- roku/components/RetroScene.brs | 12 ++- roku/components/RetroScene.xml | 37 ++++++--- 4 files changed, 108 insertions(+), 75 deletions(-) diff --git a/roku/README.md b/roku/README.md index 5b5b240..16a823d 100644 --- a/roku/README.md +++ b/roku/README.md @@ -23,7 +23,7 @@ IP or hostname. Use `IP:port` if the bridge uses a port other than `4242`. - **Star** opens the guide. Press it from the guide for channel refresh and server selection. - **Back** closes the guide or menu, then exits from the tuner. -The app opens on the guide. The details pane shows current and upcoming titles for the highlighted channel. Channel 99 displays local weather. Playback starts from the live HLS playlist supplied by the bridge. +The app opens on the guide. The guide scrolls three channels at a time in an overlay along the bottom of the picture, with current and upcoming programming for each row. Channel 99 displays local weather. Playback starts from the live HLS playlist supplied by the bridge. SSDP discovery, playback, and live timing require validation on Roku hardware. ## Desktop simulator diff --git a/roku/components/Guide.brs b/roku/components/Guide.brs index efbb96f..3037776 100644 --- a/roku/components/Guide.brs +++ b/roku/components/Guide.brs @@ -1,7 +1,6 @@ sub showPanel(mode as string, title as string, status as string, titles as object) m.panelMode = mode - m.guideDetails.visible = false - m.menu.itemSize = [1150, 50] + m.guideOverlay.visible = false m.panelTitle.text = title m.panelStatus.text = status content = CreateObject("roSGNode", "ContentNode") @@ -22,6 +21,7 @@ end sub sub closePanel() m.panelMode = "" m.panel.visible = false + m.guideOverlay.visible = false m.remoteFocus.SetFocus(true) end sub @@ -56,18 +56,6 @@ sub onMenuSelect(event as object) else findServer("", false) end if - else if m.panelMode = "guide" - if index < 0 or index >= m.guideIds.Count() then return - id = m.guideIds[index] - for i = 0 to m.channels.Count() - 1 - if m.channels[i].id = id - closePanel() - if i <> m.channelIndex then tune(i) - exit for - end if - end for - else if m.panelMode = "guideError" - openGuide() end if end sub @@ -77,7 +65,13 @@ sub openGuide(offset = 0 as integer) m.guideRequest.control = "stop" end if m.guideOffset = offset - showPanel("guideLoading", "Program guide", "Loading the schedule…", []) + m.panelMode = "guideLoading" + m.panel.visible = false + m.banner.visible = false + m.guideOverlay.visible = true + m.guideRows.visible = false + m.guideStatus.text = "Loading the schedule…" + m.remoteFocus.SetFocus(true) m.guideRequest = startRequest({url: m.server.baseUrl + "/api/v1/guide?hours=3"}, "onGuide") end sub @@ -87,57 +81,81 @@ sub onGuide(event as object) if m.panelMode <> "guideLoading" then return data = event.GetData().data if data = invalid or GetInterface(data.channels, "ifArray") = invalid or data.channels.Count() = 0 - showPanel("guideError", "Program guide", "Could not load the schedule.", ["Retry"]) + m.panelMode = "guideError" + m.guideStatus.text = "Schedule unavailable · OK Retry" return end if syncClock(data.serverTime) - m.guideIds = [] m.guideChannels = data.channels - titles = [] selected = 0 - for each channel in m.guideChannels - if m.channelIndex >= 0 and channel.id = m.channels[m.channelIndex].id then selected = titles.Count() - titles.Push(channelLabel(channel)) - m.guideIds.Push(channel.id) + for i = 0 to m.guideChannels.Count() - 1 + if m.channelIndex >= 0 and m.guideChannels[i].id = m.channels[m.channelIndex].id then selected = i end for - selected = (selected + m.guideOffset + titles.Count()) mod titles.Count() - showPanel("guide", "Program guide", "Up / Down Browse OK Watch Star Options", titles) - m.menu.itemSize = [430, 50] - m.guideDetails.visible = true - m.menu.jumpToItem = selected - showGuideDetails(selected) + count = m.guideChannels.Count() + m.guideSelected = (selected + m.guideOffset + count) mod count + m.guideFirst = 0 + m.panelMode = "guide" + m.guideRows.visible = true + m.guideStatus.text = "PROGRAM GUIDE Up / Down Browse OK Watch Back Close" + renderGuide() end sub -sub onGuideFocus(event as object) - if m.panelMode = "guide" then showGuideDetails(event.GetData()) -end sub - -sub showGuideDetails(index as integer) - if index < 0 or index >= m.guideChannels.Count() then return - channel = m.guideChannels[index] - m.guideChannelTitle.text = channelLabel(channel) - m.guideNow.text = "" - m.guideNext.text = "" - m.guideLater.text = "" - if channel.type = "weather" - m.guideNow.text = "LOCAL WEATHER" - m.guideNext.text = "Current conditions, forecasts and alerts" - return - end if - +sub renderGuide() + if m.guideSelected < m.guideFirst then m.guideFirst = m.guideSelected + if m.guideSelected > m.guideFirst + 2 then m.guideFirst = m.guideSelected - 2 now = currentEpoch() - upcoming = [] - current = invalid - for each program in channel.programs - if parseUtc(program.start) > now - upcoming.Push(program) - else if parseUtc(program.stop) > now - current = program + for i = 0 to 2 + index = m.guideFirst + i + suffix = StrI(i).Trim() + row = m.top.FindNode("guideRow" + suffix) + row.visible = index < m.guideChannels.Count() + if row.visible + channel = m.guideChannels[index] + current = invalid + upcoming = invalid + for each program in channel.programs + if parseUtc(program.start) > now + upcoming = program + exit for + else if parseUtc(program.stop) > now + current = program + end if + end for + m.top.FindNode("guideFill" + suffix).color = "0x1B2B48FF" + if index = m.guideSelected then m.top.FindNode("guideFill" + suffix).color = "0x376C89FF" + m.top.FindNode("guideChannel" + suffix).text = channelLabel(channel) + m.top.FindNode("guideNow" + suffix).text = programTitle(current) + if channel.type = "weather" then m.top.FindNode("guideNow" + suffix).text = "Local weather" + m.top.FindNode("guideNext" + suffix).text = programTitle(upcoming) end if end for - m.guideNow.text = "NOW" + Chr(10) + programTitle(current) - nextProgram = invalid - if upcoming.Count() > 0 then nextProgram = upcoming[0] - m.guideNext.text = "NEXT" + Chr(10) + programTitle(nextProgram) - if upcoming.Count() > 1 then m.guideLater.text = "LATER" + Chr(10) + programTitle(upcoming[1]) end sub + +function handleGuideKey(key as string) as boolean + if key = "back" + if m.channelIndex < 0 then return false + closePanel() + else if key = "options" + showPanel("options", "retroLabs", m.server.name + " " + m.server.baseUrl, ["Program guide", "Refresh channels", "Change server"]) + else if key = "ok" and m.panelMode = "guideError" + openGuide() + else if m.panelMode = "guide" + if key = "up" or key = "down" + direction = 1 + if key = "up" then direction = -1 + count = m.guideChannels.Count() + m.guideSelected = (m.guideSelected + direction + count) mod count + renderGuide() + else if key = "ok" + id = m.guideChannels[m.guideSelected].id + for i = 0 to m.channels.Count() - 1 + if m.channels[i].id = id + closePanel() + if i <> m.channelIndex then tune(i) + exit for + end if + end for + end if + end if + return true +end function diff --git a/roku/components/RetroScene.brs b/roku/components/RetroScene.brs index f2b3783..c5ae9b9 100644 --- a/roku/components/RetroScene.brs +++ b/roku/components/RetroScene.brs @@ -1,5 +1,5 @@ sub init() - for each id in ["video", "weather", "banner", "channelTitle", "clock", "nowTitle", "nextTitle", "progressTrack", "progress", "playbackStatus", "panel", "panelTitle", "panelStatus", "menu", "bannerTimer", "clockTimer", "retryTimer", "guideDetails", "guideChannelTitle", "guideNow", "guideNext", "guideLater", "remoteFocus"] + for each id in ["video", "weather", "banner", "channelTitle", "clock", "nowTitle", "nextTitle", "progressTrack", "progress", "playbackStatus", "panel", "panelTitle", "panelStatus", "menu", "bannerTimer", "clockTimer", "retryTimer", "guideOverlay", "guideStatus", "guideRows", "remoteFocus"] m[id] = m.top.FindNode(id) end for m.channels = [] @@ -11,7 +11,6 @@ sub init() m.clockReference = CreateObject("roTimespan") m.menu.ObserveField("itemSelected", "onMenuSelect") - m.menu.ObserveField("itemFocused", "onGuideFocus") m.video.ObserveField("state", "onVideoState") initWeather() m.bannerTimer.ObserveField("fire", "hideBanner") @@ -220,6 +219,7 @@ sub onSchedule(event as object) end sub sub showBanner() + if m.guideOverlay.visible then return m.banner.visible = true m.bannerTimer.control = "stop" m.bannerTimer.control = "start" @@ -327,16 +327,14 @@ end sub function onKeyEvent(key as string, press as boolean) as boolean if not press then return false + key = LCase(key) + if m.guideOverlay.visible then return handleGuideKey(key) if key = "back" and m.panel.visible and m.channelIndex >= 0 closePanel() return true end if if key = "options" and (m.channelIndex >= 0 or m.panelMode = "guide" or m.panelMode = "options") - if m.panelMode = "guide" - showPanel("options", "retroLabs", m.server.name + " " + m.server.baseUrl, ["Program guide", "Refresh channels", "Change server"]) - else - openGuide() - end if + openGuide() return true end if if m.panel.visible or m.channelIndex < 0 then return false diff --git a/roku/components/RetroScene.xml b/roku/components/RetroScene.xml index db7b572..8bf3c9c 100644 --- a/roku/components/RetroScene.xml +++ b/roku/components/RetroScene.xml @@ -91,16 +91,33 @@ - - - + + + +