Add a live weather inset and local soundtrack support
This commit is contained in:
@@ -46,6 +46,10 @@ sub onMenuSelect(event as object)
|
||||
openGuide()
|
||||
else if index = 1
|
||||
m.channelIndex = -1
|
||||
m.weather.visible = false
|
||||
stopWeather()
|
||||
m.videoChannelId = invalid
|
||||
m.video.visible = false
|
||||
m.video.control = "stop"
|
||||
m.retryTimer.control = "stop"
|
||||
loadLineup()
|
||||
|
||||
@@ -27,6 +27,7 @@ sub findServer(baseUrl as string, useSaved as boolean)
|
||||
m.weather.visible = false
|
||||
stopWeather()
|
||||
m.video.control = "stop"
|
||||
m.videoChannelId = invalid
|
||||
m.video.visible = false
|
||||
m.playbackStatus.visible = false
|
||||
m.retryTimer.control = "stop"
|
||||
@@ -154,16 +155,26 @@ 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
|
||||
startWeather()
|
||||
return
|
||||
end if
|
||||
stopWeather()
|
||||
m.video.visible = true
|
||||
m.video.translation = [0, 0]
|
||||
m.video.width = 1280
|
||||
m.video.height = 720
|
||||
m.video.mute = false
|
||||
if m.videoChannelId = channel.id and m.video.state = "playing" then return
|
||||
setPlaybackStatus("Tuning…")
|
||||
playLinear(channel)
|
||||
end sub
|
||||
|
||||
sub playLinear(channel as object)
|
||||
m.video.control = "stop"
|
||||
m.videoChannelId = invalid
|
||||
streamUrl = channel.streamUrl
|
||||
if GetInterface(streamUrl, "ifString") = invalid or streamUrl = ""
|
||||
setPlaybackStatus("This channel has no stream.")
|
||||
@@ -176,7 +187,7 @@ sub startPlayback()
|
||||
content.live = true
|
||||
content.title = channel.name
|
||||
m.video.content = content
|
||||
setPlaybackStatus("Tuning…")
|
||||
m.videoChannelId = channel.id
|
||||
m.video.control = "play"
|
||||
end sub
|
||||
|
||||
@@ -278,7 +289,11 @@ sub setPlaybackStatus(message as string)
|
||||
end sub
|
||||
|
||||
sub onVideoState()
|
||||
if m.channelIndex < 0 or m.weather.visible then return
|
||||
if m.weather.visible
|
||||
if m.video.state = "error" or m.video.state = "finished" then hideWeatherPreview()
|
||||
return
|
||||
end if
|
||||
if m.channelIndex < 0 then return
|
||||
if m.video.state = "playing"
|
||||
m.playbackStatus.visible = false
|
||||
m.retryCount = 0
|
||||
@@ -324,7 +339,7 @@ function onKeyEvent(key as string, press as boolean) as boolean
|
||||
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"
|
||||
if not m.weather.visible and (m.video.state = "error" or m.video.state = "finished")
|
||||
tune(m.channelIndex)
|
||||
else
|
||||
showBanner()
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<script type="text/brightscript" uri="pkg:/components/Guide.brs" />
|
||||
<script type="text/brightscript" uri="pkg:/components/Weather.brs" />
|
||||
<children>
|
||||
<Video id="video" width="1280" height="720" enableUI="false" />
|
||||
<Audio id="weatherAudio" loop="true" />
|
||||
<Group id="weather" visible="false">
|
||||
<Rectangle width="1280" height="720" color="0x122D62FF" />
|
||||
<Rectangle translation="[70,120]" width="1140" height="5" color="0x78E5EBFF" />
|
||||
@@ -14,13 +14,18 @@
|
||||
font="font:MediumBoldSystemFont" color="0x78E5EBFF" />
|
||||
<Label id="weatherHeading" translation="[70,198]" width="1140" height="42"
|
||||
font="font:MediumBoldSystemFont" />
|
||||
<Label id="weatherBody" translation="[70,252]" width="1140" height="285"
|
||||
font="font:MediumSystemFont" wrap="true" numLines="7" />
|
||||
<Label id="weatherBody" translation="[70,252]" width="700" height="285"
|
||||
font="font:SmallSystemFont" wrap="true" numLines="8" />
|
||||
<Rectangle id="weatherPreviewFrame" translation="[800,208]" width="416" height="238"
|
||||
color="0x78E5EBFF" visible="false" />
|
||||
<Label id="weatherPreviewLabel" translation="[802,454]" width="412" height="70"
|
||||
font="font:SmallBoldSystemFont" wrap="true" numLines="2" />
|
||||
<Label id="weatherAlerts" translation="[70,553]" width="1140" height="74"
|
||||
font="font:SmallBoldSystemFont" color="0xFFD57AFF" wrap="true" numLines="2" />
|
||||
<Label id="weatherSource" translation="[70,646]" width="1140" height="32"
|
||||
font="font:SmallSystemFont" color="0xB7D4E9FF" />
|
||||
</Group>
|
||||
<Video id="video" width="1280" height="720" enableUI="false" />
|
||||
<Group id="banner" translation="[50,525]" visible="false">
|
||||
<Rectangle width="1180" height="145" color="0x101A32EF" />
|
||||
<Rectangle width="6" height="145" color="0x78E5EBFF" />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
sub initWeather()
|
||||
for each id in ["weatherLocation", "weatherHeading", "weatherBody", "weatherAlerts", "weatherSource", "weatherRotation", "weatherRefresh"]
|
||||
for each id in ["weatherLocation", "weatherHeading", "weatherBody", "weatherAlerts", "weatherSource", "weatherRotation", "weatherRefresh", "weatherAudio", "weatherPreviewFrame", "weatherPreviewLabel"]
|
||||
m[id] = m.top.FindNode(id)
|
||||
end for
|
||||
m.weatherRotation.ObserveField("fire", "rotateWeather")
|
||||
@@ -14,11 +14,51 @@ sub startWeather()
|
||||
m.weatherBody.text = ""
|
||||
m.weatherAlerts.text = ""
|
||||
m.weatherSource.text = ""
|
||||
startWeatherPreview()
|
||||
refreshWeather()
|
||||
m.weatherRefresh.control = "start"
|
||||
end sub
|
||||
|
||||
sub startWeatherPreview()
|
||||
preview = invalid
|
||||
if m.previousIndex >= 0 and m.previousIndex < m.channels.Count()
|
||||
candidate = m.channels[m.previousIndex]
|
||||
if candidate.type = "linear" then preview = candidate
|
||||
end if
|
||||
if preview = invalid
|
||||
for each candidate in m.channels
|
||||
if candidate.type = "linear"
|
||||
preview = candidate
|
||||
exit for
|
||||
end if
|
||||
end for
|
||||
end if
|
||||
if preview = invalid
|
||||
hideWeatherPreview()
|
||||
return
|
||||
end if
|
||||
|
||||
m.video.translation = [804, 212]
|
||||
m.video.width = 408
|
||||
m.video.height = 230
|
||||
m.video.mute = true
|
||||
m.video.visible = true
|
||||
m.weatherPreviewFrame.visible = true
|
||||
m.weatherPreviewLabel.text = "LIVE " + channelLabel(preview)
|
||||
if m.videoChannelId <> preview.id or m.video.state <> "playing" then playLinear(preview)
|
||||
end sub
|
||||
|
||||
sub hideWeatherPreview()
|
||||
m.video.visible = false
|
||||
m.video.control = "stop"
|
||||
m.videoChannelId = invalid
|
||||
m.weatherPreviewFrame.visible = false
|
||||
m.weatherPreviewLabel.text = ""
|
||||
end sub
|
||||
|
||||
sub stopWeather()
|
||||
m.weatherAudio.control = "stop"
|
||||
m.weatherMusicUrl = invalid
|
||||
m.weatherRotation.control = "stop"
|
||||
m.weatherRefresh.control = "stop"
|
||||
if m.weatherWorker <> invalid
|
||||
@@ -38,6 +78,7 @@ sub onWeather(event as object)
|
||||
if not m.weather.visible then return
|
||||
firstResult = m.weatherData = invalid
|
||||
m.weatherData = event.GetData().data
|
||||
if m.weatherData <> invalid then updateWeatherMusic(m.weatherData.musicUrl)
|
||||
renderWeather()
|
||||
if firstResult then m.weatherRotation.control = "start"
|
||||
end sub
|
||||
@@ -109,3 +150,15 @@ function tempLabel(value as dynamic) as string
|
||||
if value = invalid then return "—"
|
||||
return StrI(value).Trim() + "°F"
|
||||
end function
|
||||
|
||||
sub updateWeatherMusic(path as dynamic)
|
||||
if path = m.weatherMusicUrl then return
|
||||
m.weatherAudio.control = "stop"
|
||||
m.weatherMusicUrl = path
|
||||
if GetInterface(path, "ifString") = invalid or path = "" then return
|
||||
track = CreateObject("roSGNode", "ContentNode")
|
||||
track.url = m.server.baseUrl + path
|
||||
track.streamFormat = "mp3"
|
||||
m.weatherAudio.content = track
|
||||
m.weatherAudio.control = "play"
|
||||
end sub
|
||||
|
||||
Reference in New Issue
Block a user