<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2016 Roku Corp. All Rights Reserved. -->
<component name="HeroScreen" extends="Group" initialFocus="RowListB">
<children>
<Video
id="videoPoster"
translation="[355,10]"
enableUI = "false"
width = "1200"
height="670" >
<Poster
id="videoPosterImage"
uri="$$removed$$Long-IslandB.png"
width="1200"
height="670" />
</Video>
<RowList
id="RowList"
itemComponentName="customItem"
focusXOffset="[167]"
itemSize="[2050,220]"
numRows="2"
rowFocusAnimationStyle="floatingFocus"
rowHeights="[415,415,415]"
rowItemSize="[[400,295],[400,295],[400,295]]"
rowItemSpacing="[[30,0]]"
rowLabelOffset="[[165,8]]"
showRowLabel="[true,true]"
showRowCounter="[true,true,true]"
translation="[-100,685]"/>
</children>
<interface>
<!-- Grid Content Node -->
<field id="content" type="node" alias="RowList.content" />
<!-- Row item selection handler -->
<field id="rowItemSelected" type="intarray" alias="RowList.rowItemSelected" alwaysnotify="true"/>
<!-- Row item focused handler - sets background image uri and focusedContent field -->
<field id="itemFocused" type="intarray" alias="RowList.rowItemFocused" onChange="OnItemFocused"/>
<!-- Interface to focused item (Content Node) -->
<field id="focusedContent" type="node"/>
<!-- # of requests that have bad/no content (not a 200 response) -->
<field id="numBadRequests" type="integer"/>
</interface>
<script type="text/brightscript" uri="pkg:/components/HeroScreen/HeroScreen.brs" />
</component>
' ********** Copyright 2016 Roku Corp. All Rights Reserved. **********
' Called when the HeroScreen component is initialized
sub Init()
'Uncomment the print statements to see where and when the functions are called
'print "HeroScreen.brs - [init]"
'Get references to child nodes
m.RowList = m.top.findNode("RowList")
m.UriHandler = CreateObject("roSGNode", "UriHandler")
m.UriHandler.observeField("content", "onContentChanged")
m.global.addFields( {red: &hff0000ff, green: &h00ff00ff, blue: &h0000ffff} )
m.global.id = 0
'Make a request for each "row" in the UI (in the order that you want content filled)
URLs = [
' Uncomment this line to simulate a bad request and make the dialog box appear
' "bad request",
"live.rss",
"local.rss",
"crime.rss",
"tar.rss"
]
makeRequest(URLs,"Parser")
'Create observer events for when content is loaded
m.top.observeField("visible", "onVisibleChange")
m.top.observeField("focusedChild", "OnFocusedChildChange")
end sub
' Issues a URL request to the UriHandler component
sub makeRequest(URLs as object, ParserComponent as String)
'print "HeroScreen.brs - [makeRequest]"
for i = 0 to URLs.count() - 1
context = createObject("roSGNode", "Node")
uri = { uri: URLs[i] }
if type(uri) = "roAssociativeArray"
context.addFields({
parameters: uri,
num: i,
response: {}
})
m.UriHandler.request = {
context: context
parser: ParserComponent
}
end if
end for
end sub
' observer function to handle when content loads
sub onContentChanged()
'print "HeroScreen.brs - [onContentChanged]"
m.top.numBadRequests = m.UriHandler.numBadRequests
m.top.content = m.UriHandler.content
end sub
' handler of focused item in RowList
sub OnItemFocused()
print "HeroScreen.brs - [onItemFocused]"
itemFocused = m.top.itemFocused
focusedContent = m.top.content.getChild(itemFocused[0]).getChild(itemFocused[1])
Poster = m.top.findNode("Poster1")
print Poster
'm.videoElm = m.Poster.createChild("Video")
'm.videoElm.width = "400"
'm.VideoElm.height = "280"
'print m.top.rowItemSelected
if itemFocused.Count() = 2 then
focusedContent = m.top.content.getChild(itemFocused[0]).getChild(itemFocused[1])
if focusedContent <> invalid then
m.top.focusedContent = focusedContent
end if
end if
end sub
sub OnItemFocusedNode()
print "HeroScreen.brs - [onItemFocusedNode]"
'itemFocused = m.top.itemFocused
m.posterElm = m.top.findNode("posterElm")
end sub
' sets proper focus to RowList in case channel returns from Details Screen
sub onVisibleChange()
print "HeroScreen.brs - [onVisibleChange]"
if m.top.visible then m.RowList.setFocus(true)
end sub
' set proper focus to RowList in case if return from Details Screen
Sub onFocusedChildChange()
print "HeroScreen.brs - [onFocusedChildChange]"
if m.top.isInFocusChain() and not m.rowList.hasFocus() then m.rowList.setFocus(true)
End Sub
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2016 Roku Corp. All Rights Reserved. -->
<component name="customItem" extends="Group">
<interface>
<field id="width" type="float" onChange="updateLayout"/>
<field id="height" type="float" onChange="updateLayout"/>
<field id="itemContent" type="node" onChange="itemContentChanged" />
</interface>
<script type="text/brightscript">
<![CDATA[
sub Init()
m.Poster = m.top.createChild("Poster")
id = m.global.id
idInt = id.ToInt()
idInt++
m.global.id = idInt
m.Poster.id = "Poster"+m.global.id+""
m.Poster.width = "400"
m.Poster.height = "280"
m.Poster.loadDisplayMode = "scaleToZoom"
'm.Poster.observeField("focusedChild", "OnFocusedChildChange")
'm.Label = m.top.findNode("label")
end sub
sub itemContentChanged()
m.Poster.uri = m.top.itemContent.HDPOSTERURL
end sub
]]>
</script>
<children></children>
</component>
Poster = m.top.findNode("Poster1")
print Posterreturns invalid...