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

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