HMS

Home Media Server for Roku Players
git clone https://www.brianlane.com/git/HMS
Log | Files | Refs | README | LICENSE

commit 913c0a45e12f453dd0747a3eb5d5a3e91e24c8bb
parent fb8149a7614cd5dca2025988590999cffd068b02
Author: Brian C. Lane <bcl@brianlane.com>
Date:   Tue, 15 Nov 2022 17:16:22 -0800

Add clock and details text at the top of the screen

Diffstat:
MHMS/components/MainScene.brs | 46+++++++++++++++++++++++++++++++++++++++++++---
MHMS/components/MainScene.xml | 5++++-
2 files changed, 47 insertions(+), 4 deletions(-)

diff --git a/HMS/components/MainScene.brs b/HMS/components/MainScene.brs @@ -5,6 +5,9 @@ sub Init() print "MainScene->Init()" m.top.ObserveField("serverurl", "RunContentTask") + m.details = m.top.FindNode("details") + + StartClock() url = RegRead("ServerURL") if url = invalid then @@ -17,6 +20,38 @@ sub Init() SetupVideoPlayer() end sub +sub StartClock() + m.clock = m.top.FindNode("clock") + m.clockTimer = m.top.FindNode("clockTimer") + m.clockTimer.ObserveField("fire", "UpdateClock") + m.clockTimer.control = "start" + UpdateClock() +end sub + +sub UpdateClock() + now = CreateObject("roDateTime") + now.ToLocalTime() + hour = now.GetHours() + use_ampm = true + if use_ampm then + if hour < 12 then + ampm = " AM" + else + ampm = " PM" + if hour > 12 then + hour = hour - 12 + end if + end if + end if + hour = tostr(hour) + minutes = now.GetMinutes() + if minutes < 10 then + minutes = "0"+tostr(minutes) + else + minutes = tostr(minutes) + end if + m.clock.text = now.GetWeekday()+" "+hour+":"+minutes+ampm +end sub sub RunContentTask() print "MainScene->RunContentTask()" @@ -56,6 +91,7 @@ sub OnCreateNextPanelIndex() print "MainScene->OnCreateNextPanelIndex()" print m.listPanel.createNextPanelIndex print m.categories[m.listPanel.createNextPanelIndex] + m.details.text = "" RunCategoryLoadTask(m.categories[m.listPanel.createNextPanelIndex]) end sub @@ -118,8 +154,11 @@ end sub sub OnPosterSelected() print "MainScene->OnPosterSelected()" print m.posterGrid.itemSelected + StartVideoPlayer(m.posterGrid.itemSelected) +end sub - item = m.metadata[m.posterGrid.itemSelected] +sub StartVideoPlayer(index as integer) + item = m.metadata[index] print item.ShortDescriptionLine1 content = CreateObject("roSGNode", "ContentNode") @@ -140,8 +179,7 @@ sub OnPosterFocused() print "MainScene->OnPosterFocused()" print m.posterGrid.itemFocused print m.metadata[m.posterGrid.itemFocused].ShortDescriptionLine1 - - ' TODO update something at the top with the full name of the video + m.details.text = m.categories[m.listPanel.createNextPanelIndex] + " | " + m.metadata[m.posterGrid.itemFocused].ShortDescriptionLine1 end sub sub OnLabelListSelected() @@ -233,6 +271,8 @@ function onKeyEvent(key as String, press as Boolean) as Boolean else return false end if + else if key = "play" + StartVideoPlayer(m.posterGrid.itemFocused) end if end if end Function diff --git a/HMS/components/MainScene.xml b/HMS/components/MainScene.xml @@ -9,7 +9,10 @@ <field id="categories" type="roArray" /> </interface> <children> - <PanelSet id="panels" translation="[0, 0]" /> + <Label id="details" height="88" width="1500" horizAlign="left" translation="[15, 15]" /> + <Label id="clock" height="88" width="300" horizAlign="right" translation="[1610, 15]" /> + <Timer id="clockTimer" repeat="true" duration="5" /> + <PanelSet id="panels" translation="[-20, 0]" /> <Video id="player" width="1920" height="1080" visible="false"/> </children> </component>