I’m trying to make a playlist as referenced here: https://sdkdocs.roku.com/display/sdkdoc/Playing+Videos#PlayingVideos-MediaPlaylists
I’m using the hero-grid template, but I’m stuck with how to make this work.
Here’s the code that creates the row
function createRow(list as object, num as Integer)
print "Parser.brs - [createRow]"
Parent = createObject("RoSGNode", "ContentNode")
row = createObject("RoSGNode", "ContentNode")
row.Title = list[num].Title
for each itemAA in list[num].ContentList
item = createObject("RoSGNode","ContentNode")
AddAndSetFields(item, itemAA)
row.appendChild(item)
end for
Parent.appendChild(row)
return Parent
end function
And I’m assuming the current “item” ContentNode just needs to be updated to have a “content” field that has an array of other ContentNodes? Maybe after “AddAndSetFields” have another loop that creates another array of ContetnNodes, then “item.content = {array of ContentNode}” ? The things I’ve been trying don’t seem to work.
Any help would much appreciated.
Trying this, and it doesn’t do anything
function createRow(list as object, num as Integer)
print "Parser.brs - [createRow]"
Parent = createObject("RoSGNode", "ContentNode")
row = createObject("RoSGNode", "ContentNode")
row.Title = list[num].Title
fullRow = []
for each itemAA2 in list[num].ContentList
item2 = createObject("RoSGNode","ContentNode")
AddAndSetFields(item2, itemAA2)
fullRow.push(item2)
end for
for each itemAA in list[num].ContentList
item = createObject("RoSGNode","ContentNode")
AddAndSetFields(item, itemAA)
for each childRow in fullRow
item.appendChild(childRow)
end for
row.appendChild(item)
end for
Parent.appendChild(row)
return Parent
end function
and then in the details screen:
<Video
id="VideoPlayer"
visible="false"
translation="[0, 0]"
width="1920"
height="1080"
contentIsPlaylist="true"
/>
and the play button doesn’t work. it throws an error saying “No streams were provided for playback”, but i’m sure a video uri is being passed in.
The docs aren’t as clear as they could be - so you’ll need to try a few things.
I would suggest it works like populating the new rowlist screen - so try setting
Parent.contentIsPlaylist=“true”
After you create the parent, but before you do the for each append for the children to it.
As far as the streams go - each content item you are sending over needs to have at least one valid http or https url.
So I was able to get this to work
function createRow(list as object, num as Integer)
print "Parser.brs - [createRow]"
Parent = createObject("RoSGNode", "ContentNode")
row = createObject("RoSGNode", "ContentNode")
row.Title = list[num].Title
fullContentList = list[num].ContentList
for each itemAA in fullContentList
Playlist = createObject("RoSGNode", "ContentNode")
Playlist.title = itemAA.title
Playlist.description = itemAA.description
Playlist.hdposterurl = itemAA.hdposterurl
Playlist.sdposterurl = itemAA.sdposterurl
Playlist.hdBackgroundImageUrl = itemAA.hdBackgroundImageUrl
for each itemAA2 in fullContentList
item2 = createObject("RoSGNode","ContentNode")
AddAndSetFields(item2, itemAA2)
Playlist.appendChild(item2)
end for
row.appendChild(Playlist)
end for
Parent.appendChild(row)
return Parent
end function
The only problem now is each row only has one icon in it. Ideally, if there are 5 videos in a row, I’d like to show each of them… and when you click “play” is plays the list using the one you clicked as the first in the playlist.
Also, I’m not seeing any events being fired between each playlist video. Am I missing something?
It’s great you got something to work, but I’m not exactly sure how to do what you want. Could you not just recreate the playlist with 5 different start points if you created the 5 thumbnails?
Thanks @destruk .
Honestly, I thought the way I was doing it would work. I’m looping through the list and creating a node… then inside THAT loop, looping to create the playlist. I assumed it would take each video and create a separate playlist for each one, but I guess not. My initial thought is that there’s a variable being passed-by-reference some where? Or maybe putting the “contentIsPlaylist” parameter on the Video node is affecting something?
I know I’m mostly talking to myself here, but here’s the solution I came up with 
'Create a row of content '
function createRow(list as object, num as Integer)
print "Parser.brs - [createRow]"
Parent = createObject("RoSGNode", "ContentNode")
row = createObject("RoSGNode", "ContentNode")
row.Title = list[num].Title
fullContentList = list[num].ContentList
' Clone the content list '
copyContentList = []
for each thingToClone in fullContentList
copyContentList.push(thingToClone)
end for
' Loop through the content list to create a single video node '
for each itemAA in fullContentList
Playlist = createObject("RoSGNode", "ContentNode")
Playlist.title = itemAA.title
Playlist.description = itemAA.description
Playlist.hdposterurl = itemAA.hdposterurl
Playlist.sdposterurl = itemAA.sdposterurl
Playlist.hdBackgroundImageUrl = itemAA.hdBackgroundImageUrl
' Loop through the cloned content list, to create the playlist of other vids in the category '
for each itemAA2 in copyContentList
item2 = createObject("RoSGNode","ContentNode")
item2.url = itemAA2.url
Playlist.appendChild(item2)
end for
' Remove the first item in the list and put it at the end. '
' This makes the 1st video in the playlist the one thats showing its title '
shiftedItem = copyContentList.shift()
copyContentList.push(shiftedItem)
row.appendChild(Playlist)
end for
Parent.appendChild(row)
return Parent
end function
The issue I had was the objects are passed by reference, as I suspected. So I cloned the object (is there a built-in function that does that?) and did a shift() and push() to reorder the playlist. This seems pretty clunky to me, so if anyone runs across this and has a better idea, please let me know!
Hiii , i am trying to create a playlist , will this solution work if i implement on the channel in which i am working .I am first creating a homepage having rowlist , clicking on a row item will lead the user to videoplayer , after which the video will play in a loop .
The documentation on the Video node was recently updated (https://sdkdocs.roku.com/display/sdkdoc/Video). Hopefully, this more clear:
Video.content:
The ContentNode node with the Content Meta-Data for the video, or a video playlist (a sequence of videos) to be played.
If a video playlist is to be played, the children of this ContentNode node comprise the playlist, and each ContentNode child must have all attributes required to play that video. For example, if the videos “A” and “B” are to be played, three ContentNode nodes must be created: the parent ContentNode (which is largely ignored), one ContentNode child for “A,” and one ContentNode child for “B.” The parent node is set into this content field, and when video playback is started, all of its children will be played in sequence. Any changes made to the playlist after playback has started are ignored. See the contentIsPlaylist and contentIndex fields, for more information on playlists.