Okay, I am building out this Roku package “Simple Grid with Details and Video” but I am stuck. I need 5 rows and have all 5 show up on the dev instead of the 2 that it comes with, but all 5 show the exact same feed. How do I get each row to display it’s own content? I would prefer to use a separate feed for each row…or have the feed pull from 5 different XML files. What do you need from me to help answer my question? :?
The issue (if there is one) is with the feed parsing. - It loads the feed all into a single array and then assigns that same array to both rows.
You could do some tricky manipulation of the feed parsing routine to put every even number item into the first array, and every odd numbered item into the second array - but ideally you would want to edit the feed to have multiple categories instead of a single depth of content.
The code below won’t do 5 rows, just the original 2. But you can see the concept in action and it works for splitting it into 2 rows.
' ********** Copyright 2015 Roku Corp. All Rights Reserved. **********
Sub RunUserInterface()
screen=CreateObject("roSGScreen")
scene=screen.CreateScene("HomeScene")
port=CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.Show()
url=CreateObject("roUrlTransfer")
url.SetUrl("http://api.delvenetworks.com/rest/organizations/59021fabe3b645968e382ac726cd6c7b/channels/1cfd09ab38e54f48be8498e0249f5c83/media.rss")
rsp=url.GetToString()
responseXML=ParseXML(rsp)
responseXML=responseXML.GetChildElements()
responseArray=responseXML.GetChildElements()
oneRow=[]
twoRow=[]
c=0
For Each xmlItem In responseArray
If xmlItem.getName()="item"
itemAA=xmlItem.GetChildElements()
If itemAA<>invalid
item={}
For Each xmlItem In itemAA
item[xmlItem.getName()]=xmlItem.getText()
If xmlItem.getName()="media:content"
item.url=xmlItem.getAttributes().url
item.streamFormat="mp4"
mediaContent=xmlItem.GetChildElements()
For Each mediaContentItem In mediaContent
If mediaContentItem.getName()="media:thumbnail"
item.HDPosterUrl=mediaContentItem.getattributes().url
item.hdBackgroundImageUrl=mediaContentItem.getattributes().url
End If
Next
End If
Next
If (c/2)=Int(c/2)
oneRow.Push(item)
Else
twoRow.Push(item)
End If
c=c+1
End If
End If
Next
list=[
{
TITLE : "First row"
ContentList : oneRow
}
{
TITLE : "Second row"
ContentList : twoRow
}
]
RowItems=createObject("RoSGNode","ContentNode")
For x=0 To list.Count()-1
row=createObject("RoSGNode","ContentNode")
row.Title=list[x].Title
For Each itemAA In list[x].ContentList
item=createObject("RoSGNode","ContentNode")
item.Title=itemAA.Title
item.description=itemAA.description
item.url=itemAA.url
item.streamFormat="mp4"
item.releasedate=itemAA.pubDate
item.HDPosterURL=itemaa.HDPosterURL
item.hdbackgroundimageurl=itemaa.hdbackgroundimageurl
row.AppendChild(item)
End For
RowItems.AppendChild(row)
Next
scene.gridContent=RowItems
While TRUE
msg=Wait(0,port)
print"------------------"
Print"msg=";msg
End While
If screen<>invalid
screen.Close()
screen=invalid
End If
End Sub
Function ParseXML(str As String) As Dynamic
If str=invalid Return invalid
xml=CreateObject("roXMLElement")
If Not xml.Parse(str) Return invalid
Return xml
End Function
This looks like the main.brs
Install Failure: Compilation Failed when I replaced it with your example.
I’m not sure how to use your example. Do you have a clean zip that will display 2 rows of individual videos that I can work off of?
I am doing virtual tours of real estate, so my categories would be Springfield, Branson, Lake of the Ozarks, Commercial etc. with tours of properties in their respective category.
Sorry… so how would I fix the feed to display by category. ![]()
Actually a second attempt did install and I see the 2 rows of separate content. So I guess my follow up, is how can I get the feed parsed to display items by categories?
Here is what I did and now it will not load the Dev…
' ********** Copyright 2015 Roku Corp. All Rights Reserved. **********
Sub RunUserInterface()
screen=CreateObject("roSGScreen")
scene=screen.CreateScene("HomeScene")
port=CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.Show()
url=CreateObject("roUrlTransfer")
url.SetUrl("http://api.delvenetworks.com/rest/organizations/59021fabe3b645968e382ac726cd6c7b/channels/1cfd09ab38e54f48be8498e0249f5c83/media.rss")
rsp=url.GetToString()
responseXML=ParseXML(rsp)
responseXML=responseXML.GetChildElements()
responseArray=responseXML.GetChildElements()
oneRow=[]
twoRow=[]
threeRow=[]
fourRow=[]
fiveRow=[]
c=0
For Each xmlItem In responseArray
If xmlItem.getName()="item"
itemAA=xmlItem.GetChildElements()
If itemAA<>invalid
item={}
For Each xmlItem In itemAA
item[xmlItem.getName()]=xmlItem.getText()
If xmlItem.getName()="media:content"
item.url=xmlItem.getAttributes().url
item.streamFormat="mp4"
mediaContent=xmlItem.GetChildElements()
For Each mediaContentItem In mediaContent
If mediaContentItem.getName()="media:thumbnail"
item.HDPosterUrl=mediaContentItem.getattributes().url
item.hdBackgroundImageUrl=mediaContentItem.getattributes().url
End If
Next
End If
Next
If (c/5)=Int(c/5)
oneRow.Push(item)
Else
twoRow.Push(item)
Else
threeRow.Push(item)
Else
fourRow.Push(item)
Else
fiveRow.Push(item)
End If
c=c+1
End If
End If
Next
list=[
{
TITLE : "Springfield"
ContentList : oneRow
}
{
TITLE : "Lake of the Ozarks"
ContentList : twoRow
}
{
TITLE : "Branson"
ContentList : threeRow
}
{
TITLE : "Commercial"
ContentList : fourRow
}
{
TITLE : "Other"
ContentList : fiveRow
}
]
RowItems=createObject("RoSGNode","ContentNode")
For x=0 To list.Count()-1
row=createObject("RoSGNode","ContentNode")
row.Title=list[x].Title
For Each itemAA In list[x].ContentList
item=createObject("RoSGNode","ContentNode")
item.Title=itemAA.Title
item.description=itemAA.description
item.url=itemAA.url
item.streamFormat="mp4"
item.releasedate=itemAA.pubDate
item.HDPosterURL=itemaa.HDPosterURL
item.hdbackgroundimageurl=itemaa.hdbackgroundimageurl
row.AppendChild(item)
End For
RowItems.AppendChild(row)
Next
scene.gridContent=RowItems
While TRUE
msg=Wait(0,port)
print"------------------"
Print"msg=";msg
End While
If screen<>invalid
screen.Close()
screen=invalid
End If
End Sub
Function ParseXML(str As String) As Dynamic
If str=invalid Return invalid
xml=CreateObject("roXMLElement")
If Not xml.Parse(str) Return invalid
Return xml
End Function
You can only have one “else” in an if/then statement unless it’s an “else if” - but for now keep it as simple as we can - since there are 15 items in the feed this should be ok.
For 5 rows something like this should work -
If c=0
oneRow.Push(item)
End If
If c=1
twoRow.Push(item)
End If
If c=2
threeRow.Push(item)
End If
If c=3
fourRow.Push(item)
End If
If c=4
fiveRow.Push(item)
c=-1 'reset to -1
End If
c=c+1 'increment value by 1
still failed install. Can you post whole example for me to use as it was probably my error…
I don’t think the forum can take zip file attachments? Maybe I’m wrong - but here is the full main.brs with the changes.
I’d really rather not use links to zips offsite because the last time I did that, something like 5 years later people were asking me where the linked files went.
Another note - when it ‘fails install’ as you say, in the telnet debugger it will give a reason for the failure. I tested the code below and it works with 3 videos per category, shifting in round robin order with the feed.
' ********** Copyright 2015 Roku Corp. All Rights Reserved. **********
Sub RunUserInterface()
screen=CreateObject("roSGScreen")
scene=screen.CreateScene("HomeScene")
port=CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.Show()
url=CreateObject("roUrlTransfer")
url.SetUrl("http://api.delvenetworks.com/rest/organizations/59021fabe3b645968e382ac726cd6c7b/channels/1cfd09ab38e54f48be8498e0249f5c83/media.rss")
rsp=url.GetToString()
responseXML=ParseXML(rsp)
responseXML=responseXML.GetChildElements()
responseArray=responseXML.GetChildElements()
oneRow=[]
twoRow=[]
threeRow=[]
fourRow=[]
fiveRow=[]
c=0
For Each xmlItem In responseArray
If xmlItem.getName()="item"
itemAA=xmlItem.GetChildElements()
If itemAA<>invalid
item={}
For Each xmlItem In itemAA
item[xmlItem.getName()]=xmlItem.getText()
If xmlItem.getName()="media:content"
item.url=xmlItem.getAttributes().url
item.streamFormat="mp4"
mediaContent=xmlItem.GetChildElements()
For Each mediaContentItem In mediaContent
If mediaContentItem.getName()="media:thumbnail"
item.HDPosterUrl=mediaContentItem.getattributes().url
item.hdBackgroundImageUrl=mediaContentItem.getattributes().url
End If
Next
End If
Next
If c=0
oneRow.Push(item)
End If
If c=1
twoRow.Push(item)
End If
If c=2
threeRow.Push(item)
End If
If c=3
fourRow.Push(item)
End If
If c=4
fiveRow.Push(item)
c=-1 'reset to -1
End If
c=c+1 'increment value by 1
End If
End If
Next
list=[
{
TITLE : "Springfield"
ContentList : oneRow
}
{
TITLE : "Lake of the Ozarks"
ContentList : twoRow
}
{
TITLE : "Branson"
ContentList : threeRow
}
{
TITLE : "Commercial"
ContentList : fourRow
}
{
TITLE : "Other"
ContentList : fiveRow
}
]
RowItems=createObject("RoSGNode","ContentNode")
For x=0 To list.Count()-1
row=createObject("RoSGNode","ContentNode")
row.Title=list[x].Title
For Each itemAA In list[x].ContentList
item=createObject("RoSGNode","ContentNode")
item.Title=itemAA.Title
item.description=itemAA.description
item.url=itemAA.url
item.streamFormat="mp4"
item.releasedate=itemAA.pubDate
item.HDPosterURL=itemaa.HDPosterURL
item.hdbackgroundimageurl=itemaa.hdbackgroundimageurl
row.AppendChild(item)
End For
RowItems.AppendChild(row)
Next
scene.gridContent=RowItems
While TRUE
msg=Wait(0,port)
print"------------------"
Print"msg=";msg
End While
If screen<>invalid
screen.Close()
screen=invalid
End If
End Sub
Function ParseXML(str As String) As Dynamic
If str=invalid Return invalid
xml=CreateObject("roXMLElement")
If Not xml.Parse(str) Return invalid
Return xml
End Function
You’ll need to figure that out. Your code needs to make sense of the feed you’re using, or the feed needs to be modified to match what the code is looking for.
Thanks, but this is a Roku example that duplicates a feed on several lines…Like saying here is a channel you can build if you can figure out the rest. =( I have seen several others ask the same question and are never given the final piece. It seems that this is a club that you really want to keep all your own. I posted “Roku’s” feed which is lacking the answer needed to build out “their” example channel. So no one will help with this example build?
“ozarksvt” wrote:
Okay, I am building out this Roku package “Simple Grid with Details and Video” but I am stuck. I need 5 rows and have all 5 show up on the dev instead of the 2 that it comes with, but all 5 show the exact same feed. How do I get each row to display it’s own content? I would prefer to use a separate feed for each row…or have the feed pull from 5 different XML files. What do you need from me to help answer my question? :?
If you want the channel to do what you say you want it to do (have the feed pull from 5 different XML files), then it’s a trivial change, no need to change the feed parsing code.
Add the url string as a parameter to GetApiArray(), and call GetApiArray() with the url string for each of your separate XML feeds. Do that as many times as you want. Add the results from each call to GetApiArray() to ‘list’, just like for the first two rows in the example.
“ozarksvt” wrote:
It seems that this is a club that you really want to keep all your own
And I would strongly recommend you refrain from insulting other developers on this forum, especially those who have devoted hundreds or thousands of hours of their time over several years learning the skills they need to develop for this platform, and in turn passing their knowledge back to the community in the form of thousands of forum posts coming to the assistance of those less knowledgeable than themselves. This is not a “club that you really want to keep all your own”. I could go on for hours about why that is but a) I’m really not in the mood; and b) I really don’t think you’d get it.
How will you learn if anything asked for is handed to you premade? The SDK is free. If you want it all done for you then there are people you can pay to do that. The forum is more of a ‘guide’ to get you the basics, explain some key tips about how it works, to get you on your way. Expecting more is being unreasonable.
You are both correct. I have found several threads that have asked my question and all the answers back to those questions I am sure are correct without showing too much.They just did not reveal to a NOOB like myself the answer that I would need to finish. Thank you for the thousands of hours of tireless and thankless work. I really assumed I could get the help I needed here at Roku’s forum. I have to now admit that that was stupid. I started this project weeks ago and am always “this” close. =(
If the purpose of Roku’s forum is different than I thought, then forgive me. I know you are busy and I totally respect your giving people assistance. So if you will post your Fiver page links here I can get this all wrapped up.
Were you able to implement deeplinking with the Simple Grid template?
