Browse channels before tuning and contain Tunarr memory usage
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user