Your Digital Media Has Never Looked So Good

 
rsromeo
Topic Author
Posts: 110
Joined: Wed Jun 02, 2010 4:25 pm

SIMULATING A PLAYLIST

Mon Sep 27, 2010 12:01 am

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"
}])
 
User avatar
RokuChris
Posts: 1166
Joined: Mon Aug 30, 2010 1:45 pm

Re: SIMULATING A PLAYLIST

Mon Sep 27, 2010 9:16 am

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
 
rsromeo
Topic Author
Posts: 110
Joined: Wed Jun 02, 2010 4:25 pm

Re: SIMULATING A PLAYLIST

Sun Oct 03, 2010 8:54 am

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.
 
User avatar
RokuChris
Posts: 1166
Joined: Mon Aug 30, 2010 1:45 pm

Re: SIMULATING A PLAYLIST

Sun Oct 03, 2010 10:32 am

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.
 
jbrave
Posts: 716
Joined: Mon Mar 22, 2010 3:00 pm
Location: Ben Lomond, CA
Contact:

Re: SIMULATING A PLAYLIST

Sun Oct 03, 2010 1:01 pm

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!
 
User avatar
TheEndless
** Valued Community Member **
Posts: 9231
Joined: Mon Oct 04, 2004 10:15 am
Location: US
Contact:

Re: SIMULATING A PLAYLIST

Sun Oct 03, 2010 1:03 pm

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)
 
jbrave
Posts: 716
Joined: Mon Mar 22, 2010 3:00 pm
Location: Ben Lomond, CA
Contact:

Re: SIMULATING A PLAYLIST

Sun Oct 03, 2010 1:06 pm

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!
 
rsromeo
Topic Author
Posts: 110
Joined: Wed Jun 02, 2010 4:25 pm

Re: SIMULATING A PLAYLIST

Tue Oct 05, 2010 10:52 pm

thanks for all your help guys! It worked!! :)
 
rsromeo
Topic Author
Posts: 110
Joined: Wed Jun 02, 2010 4:25 pm

Re: SIMULATING A PLAYLIST

Fri Oct 08, 2010 3:04 pm

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()
 
pin2gtoes
Posts: 68
Joined: Sun Dec 26, 2010 8:58 am

Re: SIMULATING A PLAYLIST

Sun Jan 30, 2011 8:16 am

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)
 
destruk
Posts: 2720
Joined: Sat Dec 18, 2010 4:58 pm

Re: SIMULATING A PLAYLIST

Sun Jan 30, 2011 12:01 pm

Interesting. :) Thanks!
 
User avatar
TheEndless
** Valued Community Member **
Posts: 9231
Joined: Mon Oct 04, 2004 10:15 am
Location: US
Contact:

Re: SIMULATING A PLAYLIST

Sun Jan 30, 2011 1:11 pm

pin2gtoes wrote:
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.

IsFullResult() is an event, not a status. You should check for the IsPartialResult() event to determine if the entire video was played or not. You should also check for errors via the IsRequestFailed() event.
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)

Who is online

Users browsing this forum: No registered users and 6 guests