Run the retroLabs backend and add the Roku tuner
This commit is contained in:
132
roku/components/BridgeTask.brs
Normal file
132
roku/components/BridgeTask.brs
Normal file
@@ -0,0 +1,132 @@
|
||||
sub init()
|
||||
m.top.functionName = "runRequest"
|
||||
end sub
|
||||
|
||||
sub runRequest()
|
||||
request = m.top.request
|
||||
if request.kind = "discover"
|
||||
registry = CreateObject("roRegistrySection", "server")
|
||||
baseUrl = request.baseUrl
|
||||
serverId = request.serverId
|
||||
if request.useSaved
|
||||
baseUrl = registry.Read("url")
|
||||
serverId = registry.Read("id")
|
||||
end if
|
||||
servers = []
|
||||
if baseUrl <> ""
|
||||
saved = readServer(baseUrl)
|
||||
if saved <> invalid and (serverId = "" or saved.id = serverId)
|
||||
servers.Push(saved)
|
||||
end if
|
||||
end if
|
||||
|
||||
if servers.Count() = 0 and request.manual = false
|
||||
for each baseUrl in discoverUrls()
|
||||
server = readServer(baseUrl)
|
||||
if server <> invalid
|
||||
if server.id = serverId
|
||||
servers = [server]
|
||||
exit for
|
||||
end if
|
||||
duplicate = false
|
||||
for each existing in servers
|
||||
if existing.id = server.id then duplicate = true
|
||||
end for
|
||||
if not duplicate then servers.Push(server)
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
m.top.result = {servers: servers}
|
||||
else if request.kind = "connect"
|
||||
registry = CreateObject("roRegistrySection", "server")
|
||||
registry.Write("url", request.server.baseUrl)
|
||||
registry.Write("id", request.server.id)
|
||||
registry.Flush()
|
||||
m.top.result = {data: readJson(request.server.baseUrl + "/api/v1/channels")}
|
||||
else
|
||||
m.top.result = {data: readJson(request.url)}
|
||||
end if
|
||||
end sub
|
||||
|
||||
function readServer(baseUrl as string) as dynamic
|
||||
data = readJson(baseUrl + "/api/v1/server")
|
||||
if data = invalid or GetInterface(data.id, "ifString") = invalid or data.id = "" then return invalid
|
||||
if GetInterface(data.name, "ifString") = invalid then return invalid
|
||||
return {id: data.id, name: data.name, baseUrl: baseUrl}
|
||||
end function
|
||||
|
||||
function readJson(url as string) as dynamic
|
||||
port = CreateObject("roMessagePort")
|
||||
transfer = CreateObject("roUrlTransfer")
|
||||
transfer.SetMessagePort(port)
|
||||
transfer.SetUrl(url)
|
||||
transfer.AddHeader("Accept", "application/json")
|
||||
if not transfer.AsyncGetToString() then return invalid
|
||||
event = Wait(3500, port)
|
||||
if Type(event) = "roUrlEvent" and event.GetResponseCode() = 200
|
||||
data = ParseJson(event.GetString())
|
||||
if GetInterface(data, "ifAssociativeArray") <> invalid then return data
|
||||
end if
|
||||
transfer.AsyncCancel()
|
||||
return invalid
|
||||
end function
|
||||
|
||||
function discoverUrls() as object
|
||||
urls = []
|
||||
socket = CreateObject("roDatagramSocket")
|
||||
port = CreateObject("roMessagePort")
|
||||
socket.SetMessagePort(port)
|
||||
localAddress = CreateObject("roSocketAddress")
|
||||
if not localAddress.SetAddress("0.0.0.0:0") then return urls
|
||||
if not socket.SetAddress(localAddress) then return urls
|
||||
|
||||
multicast = CreateObject("roSocketAddress")
|
||||
if not multicast.SetAddress("239.255.255.250:1900") then return urls
|
||||
if not socket.SetSendToAddress(multicast) then return urls
|
||||
socket.NotifyReadable(true)
|
||||
|
||||
serviceType = "urn:retrolabs:service:retrotv:1"
|
||||
newline = Chr(13) + Chr(10)
|
||||
request = "M-SEARCH * HTTP/1.1" + newline
|
||||
request += "HOST: 239.255.255.250:1900" + newline
|
||||
request += "MAN: " + Chr(34) + "ssdp:discover" + Chr(34) + newline
|
||||
request += "MX: 1" + newline
|
||||
request += "ST: " + serviceType + newline + newline
|
||||
socket.SendStr(request)
|
||||
|
||||
timer = CreateObject("roTimespan")
|
||||
timer.Mark()
|
||||
while timer.TotalMilliseconds() < 1800 and urls.Count() < 5
|
||||
event = Wait(1800 - timer.TotalMilliseconds() + 1, port)
|
||||
if Type(event) = "roSocketEvent" and socket.IsReadable()
|
||||
baseUrl = responseUrl(socket.ReceiveStr(2048), serviceType)
|
||||
if baseUrl <> ""
|
||||
duplicate = false
|
||||
for each existing in urls
|
||||
if existing = baseUrl then duplicate = true
|
||||
end for
|
||||
if not duplicate then urls.Push(baseUrl)
|
||||
end if
|
||||
end if
|
||||
end while
|
||||
socket.Close()
|
||||
return urls
|
||||
end function
|
||||
|
||||
function responseUrl(response as string, serviceType as string) as string
|
||||
lines = response.Split(Chr(10))
|
||||
if lines.Count() = 0 or Left(lines[0], 12) <> "HTTP/1.1 200" then return ""
|
||||
headers = {}
|
||||
for each line in lines
|
||||
separator = Instr(1, line, ":")
|
||||
if separator > 1
|
||||
key = LCase(Left(line, separator - 1).Trim())
|
||||
headers[key] = Mid(line, separator + 1).Replace(Chr(13), "").Trim()
|
||||
end if
|
||||
end for
|
||||
if headers.st <> serviceType or headers.location = invalid then return ""
|
||||
pattern = CreateObject("roRegex", "^(http://[A-Za-z0-9.-]+:[0-9]{1,5})/api/v1/device[.]xml$", "i")
|
||||
match = pattern.Match(headers.location)
|
||||
if match.Count() = 2 then return match[1]
|
||||
return ""
|
||||
end function
|
||||
8
roku/components/BridgeTask.xml
Normal file
8
roku/components/BridgeTask.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<component name="BridgeTask" extends="Task">
|
||||
<interface>
|
||||
<field id="request" type="assocarray" />
|
||||
<field id="result" type="assocarray" />
|
||||
</interface>
|
||||
<script type="text/brightscript" uri="pkg:/components/BridgeTask.brs" />
|
||||
</component>
|
||||
105
roku/components/Guide.brs
Normal file
105
roku/components/Guide.brs
Normal file
@@ -0,0 +1,105 @@
|
||||
sub showPanel(mode as string, title as string, status as string, titles as object)
|
||||
m.panelMode = mode
|
||||
m.panelTitle.text = title
|
||||
m.panelStatus.text = status
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
for each labelText in titles
|
||||
item = content.CreateChild("ContentNode")
|
||||
item.title = labelText
|
||||
end for
|
||||
m.menu.content = content
|
||||
m.menu.jumpToItem = 0
|
||||
m.panel.visible = true
|
||||
if titles.Count() = 0
|
||||
m.top.SetFocus(true)
|
||||
else
|
||||
m.menu.SetFocus(true)
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub closePanel()
|
||||
m.panelMode = ""
|
||||
m.panel.visible = false
|
||||
m.top.SetFocus(true)
|
||||
end sub
|
||||
|
||||
sub onMenuSelect(event as object)
|
||||
index = event.GetData()
|
||||
if m.panelMode = "servers"
|
||||
if index < m.servers.Count()
|
||||
connectServer(m.servers[index])
|
||||
else if index = m.servers.Count()
|
||||
openAddressDialog()
|
||||
else
|
||||
findServer("", false)
|
||||
end if
|
||||
else if m.panelMode = "lineup"
|
||||
if index = 0
|
||||
loadLineup()
|
||||
else
|
||||
findServer("", false)
|
||||
end if
|
||||
else if m.panelMode = "options"
|
||||
if index = 0
|
||||
openGuide()
|
||||
else if index = 1
|
||||
m.channelIndex = -1
|
||||
m.video.control = "stop"
|
||||
m.retryTimer.control = "stop"
|
||||
loadLineup()
|
||||
else
|
||||
findServer("", false)
|
||||
end if
|
||||
else if m.panelMode = "guide"
|
||||
id = m.guideIds[index]
|
||||
for i = 0 to m.channels.Count() - 1
|
||||
if m.channels[i].id = id
|
||||
closePanel()
|
||||
tune(i)
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
else if m.panelMode = "guideError"
|
||||
openGuide()
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub openGuide()
|
||||
if m.guideRequest <> invalid
|
||||
m.guideRequest.UnobserveFieldScoped("result")
|
||||
m.guideRequest.control = "stop"
|
||||
end if
|
||||
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)
|
||||
m.guideRequest = invalid
|
||||
if m.panelMode <> "guideLoading" then return
|
||||
data = event.GetData().data
|
||||
if data = invalid or GetInterface(data.channels, "ifArray") = invalid
|
||||
showPanel("guideError", "Program guide", "Could not load the schedule.", ["Retry"])
|
||||
return
|
||||
end if
|
||||
syncClock(data.serverTime)
|
||||
now = currentEpoch()
|
||||
m.guideIds = []
|
||||
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))
|
||||
m.guideIds.Push(channel.id)
|
||||
end for
|
||||
showPanel("guide", "Program guide", "CHANNEL | NOW / NEXT", titles)
|
||||
end sub
|
||||
330
roku/components/RetroScene.brs
Normal file
330
roku/components/RetroScene.brs
Normal file
@@ -0,0 +1,330 @@
|
||||
sub init()
|
||||
for each id in ["video", "weather", "banner", "channelTitle", "clock", "nowTitle", "nextTitle", "progressTrack", "progress", "playbackStatus", "panel", "panelTitle", "panelStatus", "menu", "bannerTimer", "clockTimer", "retryTimer"]
|
||||
m[id] = m.top.FindNode(id)
|
||||
end for
|
||||
m.channels = []
|
||||
m.channelIndex = -1
|
||||
m.previousIndex = -1
|
||||
m.retryCount = 0
|
||||
m.serverRequest = invalid
|
||||
m.schedule = invalid
|
||||
m.clockReference = CreateObject("roTimespan")
|
||||
|
||||
m.menu.ObserveField("itemSelected", "onMenuSelect")
|
||||
m.video.ObserveField("state", "onVideoState")
|
||||
m.bannerTimer.ObserveField("fire", "hideBanner")
|
||||
m.clockTimer.ObserveField("fire", "refreshClock")
|
||||
m.retryTimer.ObserveField("fire", "retryPlayback")
|
||||
m.clockTimer.control = "start"
|
||||
findServer("", true)
|
||||
end sub
|
||||
|
||||
sub findServer(baseUrl as string, useSaved as boolean)
|
||||
if m.serverRequest <> invalid then return
|
||||
m.banner.visible = false
|
||||
m.weather.visible = false
|
||||
m.video.control = "stop"
|
||||
m.video.visible = false
|
||||
m.playbackStatus.visible = false
|
||||
m.retryTimer.control = "stop"
|
||||
m.channelIndex = -1
|
||||
showPanel("servers", "Connect to retroLabs", "Looking for the bridge…", [])
|
||||
m.serverRequest = startRequest({
|
||||
kind: "discover"
|
||||
baseUrl: baseUrl
|
||||
serverId: ""
|
||||
manual: baseUrl <> ""
|
||||
useSaved: useSaved
|
||||
}, "onServers")
|
||||
end sub
|
||||
|
||||
sub onServers(event as object)
|
||||
m.serverRequest = invalid
|
||||
m.servers = event.GetData().servers
|
||||
if m.servers.Count() = 1
|
||||
connectServer(m.servers[0])
|
||||
return
|
||||
end if
|
||||
|
||||
titles = []
|
||||
for each server in m.servers
|
||||
titles.Push(server.name + " " + server.baseUrl)
|
||||
end for
|
||||
titles.Push("Enter server address")
|
||||
titles.Push("Search again")
|
||||
status = "Select a bridge on your network."
|
||||
if m.servers.Count() = 0 then status = "No bridge found. Check the server or enter its address."
|
||||
showPanel("servers", "Connect to retroLabs", status, titles)
|
||||
end sub
|
||||
|
||||
sub connectServer(server as object)
|
||||
m.server = server
|
||||
loadLineup()
|
||||
end sub
|
||||
|
||||
sub loadLineup()
|
||||
if m.serverRequest <> invalid then return
|
||||
showPanel("lineup", m.server.name, "Loading channels…", [])
|
||||
m.serverRequest = startRequest({kind: "connect", server: m.server}, "onChannels")
|
||||
end sub
|
||||
|
||||
sub onChannels(event as object)
|
||||
m.serverRequest = invalid
|
||||
data = event.GetData().data
|
||||
if data = invalid or GetInterface(data.channels, "ifArray") = invalid
|
||||
showPanel("lineup", m.server.name, "Could not load channels.", ["Retry", "Find another server"])
|
||||
return
|
||||
end if
|
||||
m.channels = data.channels
|
||||
if m.channels.Count() = 0
|
||||
showPanel("lineup", m.server.name, "Set up a channel in Tunarr, then refresh the lineup.", ["Refresh", "Find another server"])
|
||||
return
|
||||
end if
|
||||
|
||||
closePanel()
|
||||
m.previousIndex = -1
|
||||
tune(0)
|
||||
end sub
|
||||
|
||||
function startRequest(request as object, callback as string) as object
|
||||
worker = CreateObject("roSGNode", "BridgeTask")
|
||||
worker.request = request
|
||||
worker.ObserveFieldScoped("result", callback)
|
||||
worker.control = "run"
|
||||
return worker
|
||||
end function
|
||||
|
||||
sub openAddressDialog()
|
||||
dialog = CreateObject("roSGNode", "KeyboardDialog")
|
||||
dialog.title = "Enter server IP or IP:port"
|
||||
dialog.buttons = ["Connect", "Cancel"]
|
||||
if m.server <> invalid then dialog.text = Mid(m.server.baseUrl, 8)
|
||||
dialog.ObserveField("buttonSelected", "onAddressSelected")
|
||||
m.top.dialog = dialog
|
||||
end sub
|
||||
|
||||
sub onAddressSelected(event as object)
|
||||
dialog = m.top.dialog
|
||||
if event.GetData() <> 0
|
||||
dialog.close = true
|
||||
return
|
||||
end if
|
||||
|
||||
address = dialog.text.Trim()
|
||||
if LCase(Left(address, 7)) = "http://" then address = Mid(address, 8)
|
||||
if Right(address, 1) = "/" then address = Left(address, Len(address) - 1)
|
||||
if Instr(1, address, ":") = 0 then address += ":4242"
|
||||
pattern = CreateObject("roRegex", "^([A-Za-z0-9.-]+):([0-9]{1,5})$", "")
|
||||
match = pattern.Match(address)
|
||||
if match.Count() = 0
|
||||
dialog.title = "Enter an IP address or hostname"
|
||||
return
|
||||
end if
|
||||
port = match[2]
|
||||
if Val(port) < 1 or Val(port) > 65535
|
||||
dialog.title = "Enter a port from 1 to 65535"
|
||||
return
|
||||
end if
|
||||
dialog.close = true
|
||||
findServer("http://" + match[1] + ":" + port, false)
|
||||
end sub
|
||||
|
||||
sub tune(index as integer)
|
||||
if index < 0 or index >= m.channels.Count() then return
|
||||
if m.channelIndex <> index
|
||||
m.previousIndex = m.channelIndex
|
||||
m.channelIndex = index
|
||||
end if
|
||||
m.retryTimer.control = "stop"
|
||||
m.retryCount = 0
|
||||
channel = m.channels[index]
|
||||
m.schedule = invalid
|
||||
m.channelTitle.text = channelLabel(channel)
|
||||
m.nowTitle.text = "NOW —"
|
||||
m.nextTitle.text = "NEXT —"
|
||||
m.progressTrack.visible = false
|
||||
m.progress.width = 0
|
||||
startPlayback()
|
||||
showBanner()
|
||||
refreshSchedule()
|
||||
end sub
|
||||
|
||||
sub startPlayback()
|
||||
if m.channelIndex < 0 then return
|
||||
channel = m.channels[m.channelIndex]
|
||||
m.video.control = "stop"
|
||||
m.weather.visible = channel.type = "weather"
|
||||
m.video.visible = not m.weather.visible
|
||||
m.playbackStatus.visible = false
|
||||
if m.weather.visible then return
|
||||
|
||||
streamUrl = channel.streamUrl
|
||||
if GetInterface(streamUrl, "ifString") = invalid or streamUrl = ""
|
||||
setPlaybackStatus("This channel has no stream.")
|
||||
return
|
||||
end if
|
||||
if Left(streamUrl, 1) = "/" then streamUrl = m.server.baseUrl + streamUrl
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
content.url = streamUrl
|
||||
content.streamFormat = "hls"
|
||||
content.live = true
|
||||
content.title = channel.name
|
||||
m.video.content = content
|
||||
setPlaybackStatus("Tuning…")
|
||||
m.video.control = "play"
|
||||
end sub
|
||||
|
||||
sub refreshSchedule()
|
||||
if m.channelIndex < 0 then return
|
||||
if m.scheduleRequest <> invalid
|
||||
m.scheduleRequest.UnobserveFieldScoped("result")
|
||||
m.scheduleRequest.control = "stop"
|
||||
end if
|
||||
channel = m.channels[m.channelIndex]
|
||||
m.scheduleRequestedAt = CreateObject("roTimespan")
|
||||
m.scheduleRequestedAt.Mark()
|
||||
m.scheduleRequest = startRequest({
|
||||
url: m.server.baseUrl + "/api/v1/channels/" + channel.id + "/now"
|
||||
}, "onSchedule")
|
||||
end sub
|
||||
|
||||
sub onSchedule(event as object)
|
||||
if m.scheduleRequest = invalid or not m.scheduleRequest.IsSameNode(event.GetRoSGNode()) then return
|
||||
m.scheduleRequest = invalid
|
||||
if m.channelIndex < 0 then return
|
||||
data = event.GetData().data
|
||||
if data = invalid then return
|
||||
m.schedule = data
|
||||
syncClock(data.serverTime)
|
||||
m.nowTitle.text = "NOW " + programTitle(data.now)
|
||||
m.nextTitle.text = "NEXT " + programTitle(data.next)
|
||||
refreshClock()
|
||||
end sub
|
||||
|
||||
sub showBanner()
|
||||
m.banner.visible = true
|
||||
m.bannerTimer.control = "stop"
|
||||
m.bannerTimer.control = "start"
|
||||
refreshClock()
|
||||
end sub
|
||||
|
||||
sub hideBanner()
|
||||
m.banner.visible = false
|
||||
end sub
|
||||
|
||||
sub syncClock(serverTime as dynamic)
|
||||
epoch = parseUtc(serverTime)
|
||||
if epoch = 0 then return
|
||||
m.serverEpoch = epoch
|
||||
m.clockReference.Mark()
|
||||
end sub
|
||||
|
||||
function parseUtc(value as dynamic) as longinteger
|
||||
if GetInterface(value, "ifString") = invalid or Len(value) < 19 then return 0
|
||||
timestamp = CreateObject("roDateTime")
|
||||
timestamp.FromISO8601String(Left(value, 19))
|
||||
return timestamp.AsSeconds()
|
||||
end function
|
||||
|
||||
function currentEpoch() as longinteger
|
||||
if m.serverEpoch <> invalid then return m.serverEpoch + Int(m.clockReference.TotalMilliseconds() / 1000)
|
||||
return CreateObject("roDateTime").AsSeconds()
|
||||
end function
|
||||
|
||||
sub refreshClock()
|
||||
if not m.banner.visible then return
|
||||
now = currentEpoch()
|
||||
clock = CreateObject("roDateTime")
|
||||
clock.FromSeconds(now)
|
||||
clock.ToLocalTime()
|
||||
hour = clock.GetHours() MOD 12
|
||||
if hour = 0 then hour = 12
|
||||
meridiem = " AM"
|
||||
if clock.GetHours() >= 12 then meridiem = " PM"
|
||||
m.clock.text = hour.ToStr() + ":" + Right("0" + clock.GetMinutes().ToStr(), 2) + meridiem
|
||||
|
||||
if m.schedule = invalid or m.schedule.now = invalid then return
|
||||
starts = parseUtc(m.schedule.now.start)
|
||||
stops = parseUtc(m.schedule.now.stop)
|
||||
if starts = 0 or stops <= starts then return
|
||||
elapsed = now - starts
|
||||
if elapsed < 0 then elapsed = 0
|
||||
if now >= stops
|
||||
elapsed = stops - starts
|
||||
if m.scheduleRequestedAt.TotalMilliseconds() >= 10000 and m.scheduleRequest = invalid then refreshSchedule()
|
||||
end if
|
||||
m.progressTrack.visible = true
|
||||
m.progress.width = 1124.0 * elapsed / (stops - starts)
|
||||
end sub
|
||||
|
||||
function programTitle(program as dynamic) as string
|
||||
if program = invalid or GetInterface(program.title, "ifString") = invalid then return "—"
|
||||
return program.title
|
||||
end function
|
||||
|
||||
function channelLabel(channel as object) as string
|
||||
return channel.number.ToStr() + " " + channel.name
|
||||
end function
|
||||
|
||||
sub setPlaybackStatus(message as string)
|
||||
m.playbackStatus.text = message
|
||||
m.playbackStatus.visible = true
|
||||
end sub
|
||||
|
||||
sub onVideoState()
|
||||
if m.channelIndex < 0 or m.weather.visible then return
|
||||
if m.video.state = "playing"
|
||||
m.playbackStatus.visible = false
|
||||
m.retryCount = 0
|
||||
else if m.video.state = "buffering"
|
||||
setPlaybackStatus("Tuning…")
|
||||
else if m.video.state = "error" or m.video.state = "finished"
|
||||
if m.retryCount < 3
|
||||
m.retryCount++
|
||||
setPlaybackStatus("Reconnecting…")
|
||||
m.retryTimer.control = "start"
|
||||
else
|
||||
setPlaybackStatus("Channel unavailable. Press OK to retry.")
|
||||
end if
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub retryPlayback()
|
||||
startPlayback()
|
||||
end sub
|
||||
|
||||
function onKeyEvent(key as string, press as boolean) as boolean
|
||||
if not press then return false
|
||||
if key = "back" and m.panel.visible and m.channelIndex >= 0
|
||||
closePanel()
|
||||
return true
|
||||
end if
|
||||
if key = "options" and m.channelIndex >= 0
|
||||
if m.panel.visible
|
||||
closePanel()
|
||||
else
|
||||
showPanel("options", "retroLabs", m.server.name + " " + m.server.baseUrl, ["Program guide", "Refresh channels", "Change server"])
|
||||
end if
|
||||
return true
|
||||
end if
|
||||
if m.panel.visible or m.channelIndex < 0 then return false
|
||||
|
||||
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())
|
||||
return true
|
||||
else if key = "left" or key = "replay"
|
||||
if m.previousIndex >= 0 then tune(m.previousIndex)
|
||||
return true
|
||||
else if LCase(key) = "ok"
|
||||
if m.video.state = "error" or m.video.state = "finished"
|
||||
tune(m.channelIndex)
|
||||
else
|
||||
showBanner()
|
||||
refreshSchedule()
|
||||
end if
|
||||
return true
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
46
roku/components/RetroScene.xml
Normal file
46
roku/components/RetroScene.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<component name="RetroScene" extends="Scene">
|
||||
<script type="text/brightscript" uri="pkg:/components/RetroScene.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/Guide.brs" />
|
||||
<children>
|
||||
<Video id="video" width="1280" height="720" enableUI="false" />
|
||||
<Group id="weather" visible="false">
|
||||
<Rectangle width="1280" height="720" color="0x122D62FF" />
|
||||
<Rectangle translation="[70,120]" width="1140" height="5" color="0x78E5EBFF" />
|
||||
<Label translation="[70,55]" width="900" height="55" text="retroLabs Weather"
|
||||
font="font:LargeBoldSystemFont" color="0xF8F7EFFF" />
|
||||
<Label translation="[70,195]" width="1100" height="50" text="Live local weather is coming soon."
|
||||
font="font:MediumSystemFont" color="0xF8F7EFFF" />
|
||||
</Group>
|
||||
<Group id="banner" translation="[50,525]" visible="false">
|
||||
<Rectangle width="1180" height="145" color="0x101A32EF" />
|
||||
<Rectangle width="6" height="145" color="0x78E5EBFF" />
|
||||
<Label id="channelTitle" translation="[28,9]" width="950" height="44"
|
||||
font="font:MediumBoldSystemFont" color="0x78E5EBFF" />
|
||||
<Label id="clock" translation="[980,9]" width="170" height="44"
|
||||
horizAlign="right" font="font:MediumSystemFont" />
|
||||
<Label id="nowTitle" translation="[28,57]" width="550" height="44"
|
||||
font="font:SmallSystemFont" />
|
||||
<Label id="nextTitle" translation="[602,57]" width="550" height="44"
|
||||
font="font:SmallSystemFont" />
|
||||
<Rectangle id="progressTrack" translation="[28,120]" width="1124" height="4" color="0x344465FF" />
|
||||
<Rectangle id="progress" translation="[28,120]" width="0" height="4" color="0x78E5EBFF" />
|
||||
</Group>
|
||||
<Label id="playbackStatus" translation="[0,322]" width="1280" height="70"
|
||||
horizAlign="center" font="font:MediumBoldSystemFont" visible="false" />
|
||||
<Group id="panel" visible="false">
|
||||
<Rectangle width="1280" height="720" color="0x101A32FF" />
|
||||
<Rectangle translation="[65,125]" width="1150" height="4" color="0x78E5EBFF" />
|
||||
<Label id="panelTitle" translation="[65,50]" width="1140" height="60"
|
||||
font="font:LargeBoldSystemFont" color="0x78E5EBFF" />
|
||||
<Label id="panelStatus" translation="[65,143]" width="1150" height="54"
|
||||
font="font:SmallSystemFont" />
|
||||
<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>
|
||||
<Timer id="bannerTimer" duration="5" />
|
||||
<Timer id="clockTimer" duration="1" repeat="true" />
|
||||
<Timer id="retryTimer" duration="3" />
|
||||
</children>
|
||||
</component>
|
||||
Reference in New Issue
Block a user