Browse channels before tuning and contain Tunarr memory usage

This commit is contained in:
Josh
2026-11-13 12:47:48 -05:00
parent 737c0f0c0c
commit f84c943438
7 changed files with 82 additions and 33 deletions

View File

@@ -17,12 +17,11 @@ On first launch, the app searches for the bridge. If multicast discovery is
unavailable, select **Enter server address** and enter the bridge host's LAN
IP or hostname. Use `IP:port` if the bridge uses a port other than `4242`.
- **Up / Down** tunes the previous or next channel.
- **OK** shows the banner or retries a failed channel.
- **Up / Down** opens the guide on the adjacent channel. In the guide, it moves the highlight without tuning.
- **OK** tunes the highlighted channel in the guide. During playback it shows the banner or retries a failed channel.
- **Left / Replay** returns to the last channel.
- **Star** opens the program guide, channel refresh, and server selection.
- **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 guide shows current and upcoming titles. The weather channel is a native
placeholder. Playback starts from the live HLS playlist supplied by the bridge.
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.
SSDP discovery, playback, and live timing require validation on Roku hardware.

View File

@@ -1,5 +1,7 @@
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.panelTitle.text = title
m.panelStatus.text = status
content = CreateObject("roSGNode", "ContentNode")
@@ -51,11 +53,12 @@ sub onMenuSelect(event as object)
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()
tune(i)
if i <> m.channelIndex then tune(i)
exit for
end if
end for
@@ -64,42 +67,73 @@ sub onMenuSelect(event as object)
end if
end sub
sub openGuide()
sub openGuide(offset = 0 as integer)
if m.guideRequest <> invalid
m.guideRequest.UnobserveFieldScoped("result")
m.guideRequest.control = "stop"
end if
m.guideOffset = offset
showPanel("guideLoading", "Program guide", "Loading the schedule…", [])
m.guideRequest = startRequest({url: m.server.baseUrl + "/api/v1/guide?hours=3"}, "onGuide")
end sub
sub onGuide(event as object)
if m.guideRequest = invalid or not m.guideRequest.IsSameNode(event.GetRoSGNode()) then return
m.guideRequest = invalid
if m.panelMode <> "guideLoading" then return
data = event.GetData().data
if data = invalid or GetInterface(data.channels, "ifArray") = invalid
if data = invalid or GetInterface(data.channels, "ifArray") = invalid or data.channels.Count() = 0
showPanel("guideError", "Program guide", "Could not load the schedule.", ["Retry"])
return
end if
syncClock(data.serverTime)
now = currentEpoch()
m.guideIds = []
m.guideChannels = data.channels
titles = []
for each channel in data.channels
current = invalid
upcoming = invalid
if GetInterface(channel.programs, "ifArray") <> 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
end if
titles.Push(channelLabel(channel) + " | " + programTitle(current) + " / " + programTitle(upcoming))
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)
end for
showPanel("guide", "Program guide", "CHANNEL | NOW / NEXT", titles)
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)
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
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
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

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"]
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"]
m[id] = m.top.FindNode(id)
end for
m.channels = []
@@ -11,6 +11,7 @@ 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")
@@ -83,9 +84,8 @@ sub onChannels(event as object)
return
end if
closePanel()
m.previousIndex = -1
tune(0)
openGuide()
end sub
function startRequest(request as object, callback as string) as object
@@ -305,11 +305,11 @@ function onKeyEvent(key as string, press as boolean) as boolean
closePanel()
return true
end if
if key = "options" and m.channelIndex >= 0
if m.panel.visible
closePanel()
else
if key = "options" and m.channels.Count() > 0
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
@@ -318,7 +318,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
if key = "up" or key = "down"
direction = 1
if key = "up" then direction = -1
tune((m.channelIndex + direction + m.channels.Count()) MOD m.channels.Count())
openGuide(direction)
return true
else if key = "left" or key = "replay"
if m.previousIndex >= 0 then tune(m.previousIndex)

View File

@@ -47,6 +47,17 @@
<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>
<Timer id="bannerTimer" duration="5" />
<Timer id="clockTimer" duration="1" repeat="true" />