' ********** Copyright 2016 Roku Corp. All Rights Reserved. **********
' inits details screen
' sets all observers
' configures buttons for Details screen
Function Init()
? "[DetailsScreen] init"
m.top.observeField("visible", "onVisibleChange")
m.top.observeField("focusedChild", "OnFocusedChildChange")
m.buttons = m.top.findNode("Buttons")
m.poster = m.top.findNode("Poster")
m.description = m.top.findNode("Description")
m.background = m.top.findNode("Background")
' create buttons
result = []
for each button in ["Play", "Second button"]
result.push({title : button})
end for
m.buttons.content = ContentList2SimpleNode(result)
End Function
' set proper focus to buttons if Details opened and stops Video if Details closed
Sub onVisibleChange()
? "[DetailsScreen] onVisibleChange"
if m.top.visible = true then
m.buttons.jumpToItem = 0
m.buttons.setFocus(true)
else
m.Player.visible = false
m.Player.control = "stop"
m.poster.uri=""
m.background.uri=""
end if
End Sub
' set proper focus to Buttons in case if return from Video PLayer
Sub OnFocusedChildChange()
if m.top.isInFocusChain() and not m.buttons.hasFocus() and not m.Player.hasFocus() then
m.buttons.setFocus(true)
end if
End Sub
' set proper focus on buttons and stops video if return from Playback to details
Sub onVideoVisibleChange()
if m.Player.visible = false and m.top.visible = true
m.buttons.setFocus(true)
m.Player.control = "stop"
end if
End Sub
sub PlayerStateChanged()
print "EntryScene: PlayerStateChanged(), state = "; m.Player.state
if m.Player.state = "done" or m.Player.state = "stop"
m.Player.visible = false
m.list.setFocus(true) 'NB. the player took the focus away, so get it back
end if
end sub
' on Button press handler
Sub onItemSelected()
' compile into a VideoContent node
content = CreateObject("roSGNode", "VideoContent")
content.setFields(videoContent)
' first button is Play
if m.top.itemSelected = 0
if m.Player = invalid:
m.Player = m.top.CreateChild("Player")
m.Player.observeField("state", "PlayerStateChanged")
end if
'start the player
m.Player.content = content
m.Player.visible = true
m.Player.control = "play"
end if
End Sub
' Content change handler
Sub OnContentChange()
m.description.content = m.top.content
m.description.Description.width = "770"
m.Player.content = m.top.content
m.top.streamUrl = m.top.content.url
m.poster.uri = m.top.content.hdBackgroundImageUrl
m.background.uri = m.top.content.hdBackgroundImageUrl
End Sub
'///////////////////////////////////////////'
' Helper function convert AA to Node
Function ContentList2SimpleNode(contentList as Object, nodeType = "ContentNode" as String) as Object
result = createObject("roSGNode",nodeType)
if result <> invalid
for each itemAA in contentList
item = createObject("roSGNode", nodeType)
item.setFields(itemAA)
result.appendChild(item)
end for
end if
return result
End Function
' ********** Copyright 2016 Roku Corp. All Rights Reserved. **********
' inits details screen
' sets all observers
' configures buttons for Details screen
Function Init()
print "DetailsScreen.brs - [init]"
m.top.observeField("visible", "onVisibleChange")
m.top.observeField("focusedChild", "OnFocusedChildChange")
m.buttons = m.top.findNode("Buttons")
m.poster = m.top.findNode("Poster")
m.description = m.top.findNode("Description")
m.background = m.top.findNode("Background")
m.fadeIn = m.top.findNode("fadeinAnimation")
m.fadeOut = m.top.findNode("fadeoutAnimation")
' create buttons
result = []
for each button in ["Play", "Second button"]
result.push({title : button})
end for
m.buttons.content = ContentList2SimpleNode(result)
End Function
' set proper focus to buttons if Details opened and stops Video if Details closed
Sub onVisibleChange()
print "DetailsScreen.brs - [onVisibleChange]"
if m.top.visible
m.fadeIn.control="start"
m.buttons.jumpToItem = 0
m.buttons.setFocus(true)
else
m.fadeOut.control="start"
m.Player.visible = false
m.Player.control = "stop"
m.poster.url=""
m.background.url=""
end if
End Sub
sub PlayerStateChanged()
print "EntryScene: PlayerStateChanged(), state = "; m.Player.state
if m.Player.state = "done" or m.Player.state = "stop"
m.Player.visible = false
m.list.setFocus(true) 'NB. the player took the focus away, so get it back
end if
end sub
' set proper focus to Buttons in case if return from Video PLayer
Sub OnFocusedChildChange()
print "DetailsScreen.brs - [OnFocusedChildChange]"
if m.top.isInFocusChain() and not m.buttons.hasFocus() and not m.videoPlayer.hasFocus() then
m.buttons.setFocus(true)
end if
End Sub
' on Button press handler
Sub onItemSelected()
print "DetailsScreen.brs - [onItemSelected]"
content = CreateObject("roSGNode", "VideoContent")
content.setFields(videoContent)
if m.Player = invalid:
m.Player = m.top.CreateChild("Player")
m.Player.observeField("state", "PlayerStateChanged")
end if
' first button is Play
if m.top.itemSelected = 0
'start the player
m.Player.content = content
m.Player.visible = true
m.Player.control = "play"
end if
End Sub
' Content change handler
Sub OnContentChange()
print "DetailsScreen.brs - [OnContentChange]"
m.description.content = m.top.content
m.description.Description.width = "1120"
m.Player.content = m.top.content
m.top.streamUrl = m.top.content.url
m.poster.url = m.top.content.hdBackgroundImageUrl
m.background.url = m.top.content.hdBackgroundImageUrl
End Sub
'///////////////////////////////////////////'
' Helper function convert AA to Node
Function ContentList2SimpleNode(contentList as Object, nodeType = "ContentNode" as String) as Object
print "DetailsScreen.brs - [ContentList2SimpleNode]"
result = createObject("roSGNode", nodeType)
if result <> invalid
for each itemAA in contentList
item = createObject("roSGNode", nodeType)
item.setFields(itemAA)
result.appendChild(item)
end for
end if
return result
End Function
' ********** Copyright 2016 Roku Corp. All Rights Reserved. **********
' inits details screen
' sets all observers
' configures buttons for Details screen
Function Init()
print "DetailsScreen.brs - [init]"
m.top.observeField("focusedChild", "OnFocusedChildChange")
m.buttons = m.top.findNode("Buttons")
m.poster = m.top.findNode("Poster")
m.description = m.top.findNode("Description")
m.background = m.top.findNode("Background")
m.fadeIn = m.top.findNode("fadeinAnimation")
m.fadeOut = m.top.findNode("fadeoutAnimation")
' create buttons
result = []
for each button in ["Play", "Second button"]
result.push({title : button})
end for
m.buttons.content = ContentList2SimpleNode(result)
End Function
sub PlayerStateChanged()
print "EntryScene: PlayerStateChanged(), state = "; m.Player.state
if m.Player.state = "done" or m.Player.state = "stop"
m.Player.visible = false
m.list.setFocus(true) 'NB. the player took the focus away, so get it back
end if
end sub
' set proper focus to Buttons in case if return from Video PLayer
Sub OnFocusedChildChange()
print "DetailsScreen.brs - [OnFocusedChildChange]"
if m.top.isInFocusChain() and not m.buttons.hasFocus() and not m.videoPlayer.hasFocus() then
m.buttons.setFocus(true)
end if
End Sub
' on Button press handler
Sub onItemSelected()
print "DetailsScreen.brs - [onItemSelected]"
content = CreateObject("roSGNode", "VideoContent")
content.setFields(videoContent)
if m.Player = invalid:
m.Player = m.top.CreateChild("Player")
m.Player.observeField("state", "PlayerStateChanged")
end if
' first button is Play
if m.top.itemSelected = 0
'start the player
m.Player.content = content
m.Player.visible = true
m.Player.control = "play"
end if
End Sub
' Content change handler
Sub OnContentChange()
print "DetailsScreen.brs - [OnContentChange]"
m.description.content = m.top.content
m.description.Description.width = "1120"
m.Player.content = m.top.content
m.top.streamUrl = m.top.content.url
m.poster.url = m.top.content.hdBackgroundImageUrl
m.background.url = m.top.content.hdBackgroundImageUrl
End Sub
'///////////////////////////////////////////'
' Helper function convert AA to Node
Function ContentList2SimpleNode(contentList as Object, nodeType = "ContentNode" as String) as Object
print "DetailsScreen.brs - [ContentList2SimpleNode]"
result = createObject("roSGNode", nodeType)
if result <> invalid
for each itemAA in contentList
item = createObject("roSGNode", nodeType)
item.setFields(itemAA)
result.appendChild(item)
end for
end if
return result
End Function
m.Player = m.top.CreateChild("Player")
' on Button press handler
Sub onItemSelected()
print "DetailsScreen.brs - [onItemSelected]"
content = CreateObject("roSGNode", "VideoContent")
content.setFields(videoContent)
if m.Player = invalid:
m.Player = m.top.CreateChild("Player")
m.Player.observeField("state", "PlayerStateChanged")
else
m.Player = m.top.CreateChild("Player")
end if
' first button is Play
if m.top.itemSelected = 0
'start the player
m.Player.content = content
m.Player.visible = true
m.Player.control = "play"
end if
End Sub
m.Player = m.top.CreateChild("Video")