Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
railfan
Channel Surfer

How do I split this into to separate lists.

Hello,

I am trying to figure out how to have two RSS's one for each row. Based on the code it looks like I need to have a second. "oneRow = GetApiArray()" but not sure how to call it "twoRow = GetApiArray()" Just not sure how to rename the "GetApiArray()" part of the code.

Thanks for the help,

Mike




Sub RunUserInterface()
screen = CreateObject("roSGScreen")
scene = screen.CreateScene("HomeScene")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.Show()

oneRow = GetApiArray()
list = [
{
TITLE : "Live Cameras"
ContentList : oneRow
}
{
TITLE : "Video Library"
ContentList : oneRow
}
]
scene.gridContent = ParseXMLContent(list)

while true
msg = wait(0, port)
print "------------------"
print "msg = "; msg
end while

if screen <> invalid then
screen.Close()
screen = invalid
end if
End Sub
0 Kudos
3 REPLIES 3
joetesta
Roku Guru

Re: How do I split this into to separate lists.

To me it's not clear what you're asking. You have a function GetApiArray() and you want to create a parallel function, or you want to split your 'list' into multiple lists?
aspiring
0 Kudos
railfan
Channel Surfer

Re: How do I split this into to separate lists.

To different lists driven by a rss list. What do I need to change to support a each row driven by there own RSS file.

Sub RunUserInterface()
screen = CreateObject("roSGScreen")
scene = screen.CreateScene("HomeScene")
port = CreateObject("roMessagePort")
screen.SetMessagePort(port)
screen.Show()

oneRow = GetApiArray()
list = [
{
TITLE : "Live Cameras"
ContentList : oneRow
}
{
TITLE : "Video Library"
ContentList : oneRow
}
]
scene.gridContent = ParseXMLContent(list)

while true
msg = wait(0, port)
print "------------------"
print "msg = "; msg
end while

if screen <> invalid then
screen.Close()
screen = invalid
end if
End Sub


Function ParseXMLContent(list As Object)
RowItems = createObject("RoSGNode","ContentNode")

for each rowAA in list
'for index = 0 to 1
row = createObject("RoSGNode","ContentNode")
row.Title = rowAA.Title

for each itemAA in rowAA.ContentList
item = createObject("RoSGNode","ContentNode")
' We don't use item.setFields(itemAA) as doesn't cast streamFormat to proper value
for each key in itemAA
item[key] = itemAA[key]
end for
row.appendChild(item)
end for
RowItems.appendChild(row)
end for

return RowItems
End Function


Function GetApiArray()
url = CreateObject("roUrlTransfer")
url.SetUrl("http://www.railstream.net/*************/media.rss")
rsp = url.GetToString()

responseXML = ParseXML(rsp)
responseXML = responseXML.GetChildElements()
responseArray = responseXML.GetChildElements()

result = []

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.stream = {url : xmlItem.url}
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
end for
end if
end for
result.push(item)
end if
end if
end for

return result
End Function


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
0 Kudos
joetesta
Roku Guru

Re: How do I split this into to separate lists.

Sorry I don't have the answer to your question but I strongly suggest you use the "Code" tag (at the top of the comment box) to make the code in your comments more readable.
aspiring
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.