Overlay a three-row scrolling guide on live playback

This commit is contained in:
Josh
2026-11-13 15:21:31 -05:00
parent 147d5fb925
commit 131ebf5057
4 changed files with 108 additions and 75 deletions

View File

@@ -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

View File

@@ -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 = []
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.Push(program)
upcoming = program
exit for
else if parseUtc(program.stop) > now
current = program
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])
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
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

View File

@@ -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
return true
end if
if m.panel.visible or m.channelIndex < 0 then return false

View File

@@ -91,16 +91,33 @@
<LabelList id="menu" translation="[65,202]" itemSize="[1150,50]" itemSpacing="[0,4]"
numRows="8" color="0xF8F7EFFF" focusedColor="0x101A32FF" font="font:SmallSystemFont"
focusedFont="font:SmallBoldSystemFont" focusBitmapBlendColor="0x78E5EBFF" />
<Group id="guideDetails" translation="[520,202]" visible="false">
<Rectangle width="690" height="432" color="0x1B2B48FF" />
<Label id="guideChannelTitle" translation="[24,14]" width="640" height="45"
font="font:MediumBoldSystemFont" color="0x78E5EBFF" />
<Label id="guideNow" translation="[24,78]" width="640" height="100"
font="font:SmallSystemFont" wrap="true" numLines="3" />
<Label id="guideNext" translation="[24,192]" width="640" height="100"
font="font:SmallSystemFont" wrap="true" numLines="3" />
<Label id="guideLater" translation="[24,306]" width="640" height="100"
font="font:SmallSystemFont" wrap="true" numLines="3" />
</Group>
<Group id="guideOverlay" translation="[50,446]" visible="false">
<Rectangle width="1180" height="224" color="0x101A32F2" />
<Rectangle width="1180" height="3" color="0x78E5EBFF" />
<Label id="guideStatus" translation="[18,9]" width="1144" height="36" font="font:SmallSystemFont" />
<Group id="guideRows" translation="[12,46]">
<Label translation="[12,0]" width="230" height="30" text="CHANNEL" color="0x78E5EBFF" font="font:SmallBoldSystemFont" />
<Label translation="[250,0]" width="440" height="30" text="NOW" color="0x78E5EBFF" font="font:SmallBoldSystemFont" />
<Label translation="[704,0]" width="440" height="30" text="NEXT" color="0x78E5EBFF" font="font:SmallBoldSystemFont" />
<Group id="guideRow0" translation="[0,30]">
<Rectangle id="guideFill0" width="1156" height="44" color="0x1B2B48FF" />
<Label id="guideChannel0" translation="[12,0]" width="225" height="44" font="font:SmallBoldSystemFont" />
<Label id="guideNow0" translation="[250,0]" width="440" height="44" font="font:SmallSystemFont" />
<Label id="guideNext0" translation="[704,0]" width="440" height="44" font="font:SmallSystemFont" />
</Group>
<Group id="guideRow1" translation="[0,76]">
<Rectangle id="guideFill1" width="1156" height="44" color="0x1B2B48FF" />
<Label id="guideChannel1" translation="[12,0]" width="225" height="44" font="font:SmallBoldSystemFont" />
<Label id="guideNow1" translation="[250,0]" width="440" height="44" font="font:SmallSystemFont" />
<Label id="guideNext1" translation="[704,0]" width="440" height="44" font="font:SmallSystemFont" />
</Group>
<Group id="guideRow2" translation="[0,122]">
<Rectangle id="guideFill2" width="1156" height="44" color="0x1B2B48FF" />
<Label id="guideChannel2" translation="[12,0]" width="225" height="44" font="font:SmallBoldSystemFont" />
<Label id="guideNow2" translation="[250,0]" width="440" height="44" font="font:SmallSystemFont" />
<Label id="guideNext2" translation="[704,0]" width="440" height="44" font="font:SmallSystemFont" />
</Group>
</Group>
</Group>
<Timer id="bannerTimer" duration="5" />