Add a live weather inset and local soundtrack support
This commit is contained in:
@@ -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