Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
rsromeo
Level 7

SIMULATING A PLAYLIST

Trying to figure out how to play multiple mp4 files in succession. I know without using HLS, there will be rebuffering in between each clip but I can live with that. Just trying to make it work. Does anyone know if the following will work?

this.player.SetContentList([{
Stream: { url:"http://test.com/video1.mp4" }
StreamFormat: "mp4"
},
Stream: { url:"http://test.com/video2.mp4" }
StreamFormat: "mp4"
}])
0 Kudos
11 REPLIES 11\
RokuChris
Roku Employee
Roku Employee

Re: SIMULATING A PLAYLIST

My guess would be no, that won't work. roVideoScreen doesn't have a SetContentList() method. The easiest way I've found to play a series of videos is to just feed them one at a time to a roVideoScreen. Given an array of content-meta-data objects, you could do something like this:

for each video in videoArray
videoScreen = CreateObject("roVideoScreen")
videoScreen.SetMessagePort(CreateObject("roMessagePort"))
videoScreen.SetContent(video)
videoScreen.Show()

while true
msg = wait(0, videoScreen.GetMessagePort())

if msg.isScreenClosed()
exit while
end if
end while
next
0 Kudos
rsromeo
Level 7

Re: SIMULATING A PLAYLIST

how do you create an array of associated arrays? I'm guessing thats what I need to pass into the for-next loop. I tried this with an roList and it didn't work. It only played first video and then jumped out of channel when done.
0 Kudos
RokuChris
Roku Employee
Roku Employee

Re: SIMULATING A PLAYLIST

"rsromeo" wrote:
how do you create an array of associated arrays? I'm guessing thats what I need to pass into the for-next loop. I tried this with an roList and it didn't work. It only played first video and then jumped out of channel when done.


Were there any other screens open under your roVideoScreen at the time? A Roku channel will exit when the bottom screen is closed, so you will need some other screen open before entering your loop to keep that from happening. A blank roImageCanvas or an empty roParagraphScreen will do the job.
0 Kudos
jbrave
Level 8

Re: SIMULATING A PLAYLIST

"rsromeo" wrote:
how do you create an array of associated arrays? I'm guessing thats what I need to pass into the for-next loop. I tried this with an roList and it didn't work. It only played first video and then jumped out of channel when done.


assarray=CreateObject("RoArray",1,true)
assarray=[{key1:"dog",key2:"cat"},{key1:"apple",key2:"pear",key3:"banana"},{key1:"audi",key2:"mercedes",key3:"jaguar"}]

so now assarray is an array of associative arrays where

BrightScript Debugger> ?assarray
<ROT:roAssociativeArray>
<ROT:roAssociativeArray>
<ROT:roAssociativeArray>

BrightScript Debugger> ?assarray[0]
key2: cat
key1: dog

BrightScript Debugger> ?assarray[1]
key3: banana
key2: pear
key1: apple

BrightScript Debugger> ?assarray[2]
key3: jaguar
key2: mercedes
key1: audi

BrightScript Debugger> ?assarray[2].key2
mercedes
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
TheEndless
Level 9

Re: SIMULATING A PLAYLIST

No need for the CreateObject line in that snippet, jbrave. The square brackets in the next line take care of that for you.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
jbrave
Level 8

Re: SIMULATING A PLAYLIST

cool! I wasn't completely sure about that so I guess that is one more redunancy I can eliminate from my project!

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
rsromeo
Level 7

Re: SIMULATING A PLAYLIST

thanks for all your help guys! It worked!! Smiley Happy
0 Kudos
rsromeo
Level 7

Re: SIMULATING A PLAYLIST

ok my playlist works but I have another issue now. After each video plays, it advances to the next video in the array. that works great. My problem is the close screen event which occurs after each video is played. How can this be controlled so that when a user presses the UP key on remote, it exits the playlist? Right now, the UP key closes the current video screen and then it loops to the next video giving the user no way to exit other than using the Home key or advancing through all the videos in the array. Here's a sample snipet of code I am using:

For each clip in array

print "Displaying video: "
p = CreateObject("roMessagePort")
video = CreateObject("roVideoScreen")
video.setMessagePort(p)

video.SetContent(clip)
video.show()

while true
msg = wait(0, video.GetMessagePort())

if msg.isRemoteKeyPressed()
i = msg.GetIndex()
print "Key Pressed - " ; msg.GetIndex()
if (i = 2) then
print "Up pressed"
goto closecanvas
end if
else if msg.isScreenClosed()
print "Screen closed"
exit while
end if
end while
end for
closecanvas:
canvas.close()
0 Kudos
pin2gtoes
Level 7

Re: SIMULATING A PLAYLIST

My problem is the close screen event which occurs after each video is played. How can this be controlled so that when a user presses the UP key on remote, it exits the playlist? Right now, the UP key closes the current video screen and then it loops to the next video giving the user no way to exit other than using the Home key or advancing through all the videos in the array.


In case you are still looking for an answer, here's what I have been doing.

Check msg.isFullResult() inside while loop before continuing to the next video. isFullResult() returns True if the entire video was played. When user interrupts playback, isFullResult() will return False.
Nuod Tayo - Filipino Channel for Roku - (http://blog.nuodtayo.tv)
0 Kudos