Skip to content

Commit

Permalink
major changes including menu and today info
Browse files Browse the repository at this point in the history
  • Loading branch information
rorpage committed May 26, 2019
1 parent 7e89198 commit e04ba26
Show file tree
Hide file tree
Showing 19 changed files with 422 additions and 105 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
out
*.zip
45 changes: 45 additions & 0 deletions components/HomeScene.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
sub show(args as Object)
m.top.backgroundColor = "0x0960CCFF"
m.top.backgroundUri = ""

m.grid = CreateObject("roSGNode", "GridView")
m.grid.setFields({
style: "hero"
posterShape: "16x9"
})

content = CreateObject("roSGNode", "ContentNode")
content.addfields({
HandlerConfigGrid: {
name: "GridHandler"
}
})

m.grid.content = content

m.top.ComponentController.callFunc("show", {
view: m.grid
})

m.grid.ObserveField("rowItemSelected", "OnGridItemSelected")
end sub

sub OnGridItemSelected(event as Object)
grid = event.GetRoSGNode()
selectedIndex = event.getdata()
view = ShowView(selectedIndex[1])
end sub

function ShowView(selectedIndex as integer)
viewToShow = "NTunesScene"

if selectedIndex = 1 then viewToShow = "TodayScene"

view = CreateObject("roSGNode", viewToShow)

m.top.ComponentController.callFunc("show", {
view: view
})

return view
end function
4 changes: 4 additions & 0 deletions components/HomeScene.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="HomeScene" extends="BaseScene" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd">
<script type="text/brightscript" uri="pkg:/components/HomeScene.brs" />
</component>
36 changes: 12 additions & 24 deletions components/NTunesScene.brs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
sub show(args as Object)
m.top.setFocus(true)
sub Init()
m.top.ObserveField("wasShown", "OnWasShown")
end sub

sub OnWasShown()
m.is_playing = false

m.top.backgroundColor = "0x0960CCFF"
m.top.backgroundUri = ""

setUpLabels()

buildNTunesTask()
Expand All @@ -26,10 +25,7 @@ end function

function buildNTunesTask() as void
m.nTunesTask = CreateObject("roSGNode", "NTunesTask")
m.nTunesTask.ObserveField("current_track_title", "onCurrentTrackTitleChanged")
m.nTunesTask.ObserveField("current_track_artist_name", "onCurrentTrackArtistNameChanged")
m.nTunesTask.ObserveField("current_show_name", "onCurrentShowNameChanged")
m.nTunesTask.ObserveField("current_show_image_path", "onCurrentShowImagePathChanged")
m.nTunesTask.ObserveField("current_info", "onCurrentInfoChanged")
end function

function setUpRefreshTimer() as void
Expand Down Expand Up @@ -76,18 +72,10 @@ function onKeyEvent(key as String, press as Boolean) as Boolean
endif
end function

function onCurrentTrackTitleChanged() as void
m.current_track_title.text = m.nTunesTask.current_track_title
end function

function onCurrentTrackArtistNameChanged() as void
m.current_track_artist_name.text = m.nTunesTask.current_track_artist_name
end function

function onCurrentShowNameChanged() as void
m.current_show_name.text = m.nTunesTask.current_show_name
end function

function onCurrentShowImagePathChanged() as void
m.current_show_image_path.uri = m.nTunesTask.current_show_image_path
end function
sub onCurrentInfoChanged()
current_info = m.nTunesTask.current_info["ntunes"]
m.current_track_title.text = current_info.current_track_title
m.current_track_artist_name.text = current_info.current_track_artist_name
m.current_show_name.text = current_info.current_show_name
m.current_show_image_path.uri = current_info.current_show_image_path
end sub
44 changes: 23 additions & 21 deletions components/NTunesScene.xml
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="NTunesScene" extends="BaseScene" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd" initialFocus="audio_control_button">
<component name="NTunesScene" extends="SGDEXComponent" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd" initialFocus="audio_control_button">
<script type="text/brightscript" uri="pkg:/components/NTunesScene.brs" />
<children>
<Group id="artwork">
<Poster
id="current_show_image_path"
width="500"
height="500"
translation="[100, 100]" />
<Group id="ntunesGroup">
<Group id="artwork">
<Poster
id="current_show_image_path"
width="500"
height="500"
translation="[100, 100]" />
</Group>
<Group id="song_info" translation="[700, 100]">
<Label id="title" text="Now Playing" font="font:LargeBoldSystemFont" translation="[0, 0]" />
<Label id="current_track_title" font="font:MediumBoldSystemFont" text="Loading..." translation="[0, 60]" />
<Label id="current_track_artist_name" translation="[0, 120]" />
<Label id="current_show_name" translation="[0, 180]" />
</Group>
<Group>
<Button
id="audio_control_button"
translation="[100, 700]"
text="Play" />
</Group>
<Audio id="audio_player" />
<Timer id="refresh_timer" repeat="true" duration="10" />
</Group>
<Group id="song_info" translation="[700, 100]">
<Label id="title" text="Now Playing" font="font:LargeBoldSystemFont" translation="[0, 0]" />
<Label id="current_track_title" font="font:MediumBoldSystemFont" text="Loading..." translation="[0, 60]" />
<Label id="current_track_artist_name" translation="[0, 120]" />
<Label id="current_show_name" translation="[0, 180]" />
</Group>
<Group>
<Button
id="audio_control_button"
translation="[100, 700]"
text="Play" />
</Group>
<Audio id="audio_player" />
<Timer id="refresh_timer" repeat="true" duration="10" />
</children>
</component>
36 changes: 0 additions & 36 deletions components/NTunesTask.xml

This file was deleted.

92 changes: 92 additions & 0 deletions components/TodayScene.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
sub Init()
m.top.ObserveField("wasShown", "OnWasShown")
end sub

sub OnWasShown()
m.top.setFocus(true)

m.audio_track_index = 1

m.parks = []
m.park_id_index = 0
m.park_ids = [ "mk", "ep", "hs", "ak", "ds", "tl", "bb" ]

setUpTodaySceneLabels()

buildTodaySceneTasks()

setUpTodaySceneRefreshTimer()

setUpTodaySceneAudio()

refreshTodaySceneData()
end sub

sub setUpTodaySceneLabels()
m.park_image = m.top.findNode("park_image")
m.name = m.top.findNode("name")
m.todaysHours = m.top.findNode("todaysHours")
m.tomorrowsHours = m.top.findNode("tomorrowsHours")
end sub

sub buildTodaySceneTasks()
m.TodayParkHoursTask = CreateObject("roSGNode", "TodayParkHoursTask")
m.TodayParkHoursTask.ObserveField("parks", "onTodaySceneParksChanged")
end sub

sub setUpTodaySceneRefreshTimer()
m.refresh_timer = m.top.findNode("refresh_timer")
m.refresh_timer.control = "start"
m.refresh_timer.ObserveField("fire", "changeTodayScenePark")
end sub

sub setUpTodaySceneAudio()
m.audio = m.top.findNode("audio_player")
m.audio.observeField("state", "todaySceneAudioPlayerStateChanged")

changeTodaySceneAudioTrack()
end sub

sub refreshTodaySceneData()
m.TodayParkHoursTask.control = "RUN"
end sub

sub changeTodayScenePark()
m.park_id_index++

if (m.park_id_index > 6) then m.park_id_index = 0

updateTodayScenePark()
end sub

sub updateTodayScenePark()
current_park_id = m.park_ids[m.park_id_index]
m.current_park = m.parks[current_park_id]
m.park_image.uri = m.current_park.imageUrl
m.name.text = m.current_park.name
m.todaysHours.text = m.current_park.todaysHours
m.tomorrowsHours.text = m.current_park.tomorrowsHours
end sub

sub onTodaySceneParksChanged()
m.parks = m.TodayParkHoursTask.parks
updateTodayScenePark()
end sub

sub todaySceneAudioPlayerStateChanged()
if (m.audio.state = "finished") then
m.audio_track_index++

if (m.audio_track_index > 16) then m.audio_track_index = 1

changeTodaySceneAudioTrack()
end if
end sub

sub changeTodaySceneAudioTrack()
audiocontent = createObject("RoSGNode", "ContentNode")
audiocontent.url = "https://wdwntnow.oseast-us-1.phoenixnap.com/music/today_at_wdw/" + m.audio_track_index.ToStr() + ".mp3"

m.audio.content = audiocontent
m.audio.control = "play"
end sub
24 changes: 24 additions & 0 deletions components/TodayScene.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8" ?>
<component name="TodayScene" extends="SGDEXComponent" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd">
<script type="text/brightscript" uri="pkg:/components/TodayScene.brs" />
<children>
<Group id="todayGroup">
<Group id="artwork">
<Poster
id="park_image"
height="1080"
width="1920"
translation="[0, 0]" />
</Group>
<Group id="park_info" translation="[100, 100]">
<Label id="name" font="font:LargeBoldSystemFont" translation="[0, 0]" />
<Label id="todaysHoursLabel" font="font:MediumBoldSystemFont" translation="[0, 60]" text="Today's hours:" />
<Label id="todaysHours" font="font:MediumBoldSystemFont" translation="[270, 60]" />
<Label id="tomorrowsHoursLabel" font="font:MediumBoldSystemFont" translation="[0, 120]" text="Tomorrow's hours:" />
<Label id="tomorrowsHours" font="font:MediumBoldSystemFont" translation="[345, 120]" />
</Group>
<Audio id="audio_player" />
<Timer id="refresh_timer" repeat="true" duration="10" />
</Group>
</children>
</component>
44 changes: 44 additions & 0 deletions components/content/GridHandler.brs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
sub GetContent()
' feed = ReadAsciiFile("pkg:/config/menu.json")
' json = ParseJson(feed)
json = ParseJson("{""WDWNT"":[{""id"":0,""title"":""WDWNTunes"",""shortDescription"":""Broadcasting Magic, Music, and Mayhem"",""thumbnail"":""https://wdwnt.com/wp-content/uploads/2017/11/WDWNTunes_v3_600.png""}, {""id"":1,""title"":""Today at WDW"",""shortDescription"":""View today's and tomorrow's park hours as you would on resort TV!"",""thumbnail"":""https://wdwntnow.oseast-us-1.phoenixnap.com/images/theme-park/80007944/01.jpg""}]}")
rootNodeArray = ParseJsonToNodeArray(json)
m.top.content.AppendChildren(rootNodeArray)
end sub

function ParseJsonToNodeArray(jsonAA as Object) as Object
if jsonAA = invalid then return []
resultNodeArray = []

for each fieldInJsonAA in jsonAA
mediaItemsArray = jsonAA[fieldInJsonAA]
itemsNodeArray = []
for each mediaItem in mediaItemsArray
itemNode = ParseMediaItemToNode(mediaItem, fieldInJsonAA)
itemsNodeArray.Push(itemNode)
end for
rowNode = Utils_AAToContentNode({
title: fieldInJsonAA
})
rowNode.AppendChildren(itemsNodeArray)

resultNodeArray.Push(rowNode)
end for

return resultNodeArray
end function

function ParseMediaItemToNode(mediaItem as Object, mediaType as String) as Object
itemNode = Utils_AAToContentNode({
"id" : mediaItem.id
"title" : mediaItem.title
"hdPosterUrl" : mediaItem.thumbnail
"Description" : mediaItem.shortDescription
})

if mediaItem = invalid then
return itemNode
end if

return itemNode
end function
5 changes: 5 additions & 0 deletions components/content/GridHandler.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<component name="GridHandler" extends="ContentHandler" xsi:noNamespaceSchemaLocation="https://devtools.web.roku.com/schema/RokuSceneGraph.xsd">
<script type="text/brightscript" uri="pkg:/components/content/GridHandler.brs" />
<script type="text/brightscript" uri="pkg:/source/rsg_utils.brs" />
</component>
12 changes: 12 additions & 0 deletions components/nodes/NTunesNode.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>

<component name="NTunesNode" extends="ContentNode">
<interface>
<field id="current_track_title" type="string" />
<field id="current_track_artist_name" type="string" />
<field id="current_show_name" type="string" />
<field id="current_show_image_path" type="string" />
<field id="next_track_title" type="string" />
<field id="next_track_artist_name" type="string" />
</interface>
</component>
10 changes: 10 additions & 0 deletions components/nodes/ParkNode.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>

<component name="ParkNode" extends="ContentNode">
<interface>
<field id="name" type="string" />
<field id="imageUrl" type="string" />
<field id="todaysHours" type="string" />
<field id="tomorrowsHours" type="string" />
</interface>
</component>
Loading

0 comments on commit e04ba26

Please sign in to comment.