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: 
leeladhar
Visitor

Having a playlist played from a list of media tags

Hi ,

I want to have a playlist played on DetailScreen (the screen which has playbutton). With controls such that i should be able to skip to next video on pressing right arrow key and to go back to previous video on left key, and pressing up arrow should stop Playing video and should go to appDetailScreen.

Suppose I have an item node data as below

<item sdImg="http://rokudev.roku.com/rokudev/examples/videoplayer/images/BenjaminZander.jpg" hdImg="http://rokudev.roku.com/rokudev/examples/videoplayer/images/BenjaminZander.jpg">
<title>Benjamin Zander on music and passion</title>
<contentId>10041</contentId>
<contentType>Talk</contentType>
<contentQuality>SD</contentQuality>
<media>
<streamFormat>mp4</streamFormat>
<streamQuality>SD</streamQuality>
<streamBitrate>1500</streamBitrate>
<streamUrl>http://video.ted.com/talks/podcast/BenjaminZander_2008_480.mp4</streamUrl>
</media>
<media>
<streamFormat>mp4</streamFormat>
<streamQuality>SD</streamQuality>
<streamBitrate>1500</streamBitrate>
<streamUrl>http://video.ted.com/talks/podcast/CynthiaSchneider_2009G_480.mp4</streamUrl>
</media>
<media>
<streamFormat>mp4</streamFormat>
<streamQuality>SD</streamQuality>
<streamBitrate>1500</streamBitrate>
<streamUrl>http://video.ted.com/talks/podcast/JulianTreasure_2009G_480.mp4</streamUrl>
</media>
<synopsis>Benjamin Zander has two infectious passions: classical music, and helping us all realize our untapped love for it -- and by extension, our untapped love for all new possibilities, new experiences, new connections.</synopsis>
<genres>Inspiration</genres>
<runtime>0</runtime>
</item>


In the Detailscreen when i press PlayAll button (the button index value is 5) , It should play all the media nodes video one after the other. With the below code change I am able to play the media one after the other, but not able to properly manage the navigation keys, when the video moves from one video to another video the player shows for a sec or two the appDetailScreen, which shouldn't happen, I have pasted my code below, Is this the rightway to do for my requirement or can it be done in different way ??


Function showDetailScreen(screen As Object, showList As Object, showIndex as Integer) As Integer

if validateParam(screen, "roSpringboardScreen", "showDetailScreen") = false return -1
if validateParam(showList, "roArray", "showDetailScreen") = false return -1

refreshShowDetail(screen, showList, showIndex)

'remote key id's for left/right navigation
remoteKeyLeft = 4
remoteKeyRight = 5

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

if type(msg) = "roSpringboardScreenEvent" then
if msg.isScreenClosed()
print "Screen closed"
exit while
else if msg.isRemoteKeyPressed()
print "Remote key pressed"
if msg.GetIndex() = remoteKeyLeft then
showIndex = getPrevShow(showList, showIndex)
if showIndex <> -1
refreshShowDetail(screen, showList, showIndex)
end if
else if msg.GetIndex() = remoteKeyRight
showIndex = getNextShow(showList, showIndex)
if showIndex <> -1
refreshShowDetail(screen, showList, showIndex)
end if
endif
else if msg.isButtonPressed()
print "ButtonPressed"
if msg.GetIndex() = 1
PlayStart = RegRead(showList[showIndex].ContentId)
if PlayStart <> invalid then
showList[showIndex].PlayStart = PlayStart.ToInt()
endif
showVideoScreen(showList[showIndex])
endif
if msg.GetIndex() = 2
showList[showIndex].PlayStart = 0
showVideoScreen(showList[showIndex])
endif
if msg.GetIndex() = 3 OR msg.GetIndex() = 4
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
showSubscriptionDetails()
endif
if msg.GetIndex() = 5
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
print showList[showIndex].StreamUrls.Count()

for k=0 to showList[showIndex].StreamUrls.Count()
currFeedItem = init_show_feed_item()
currFeedItem.ContentId = showList[showIndex].ContentId
currFeedItem.MatchId = showList[showIndex].MatchId
currFeedItem.Title = showList[showIndex].Title
currFeedItem.ContentType = showList[showIndex].ContentType
currFeedItem.ContentQuality = showList[showIndex].ContentQuality
currFeedItem.Synopsis = showList[showIndex].Synopsis
currFeedItem.Genre = showList[showIndex].Genre
currFeedItem.Runtime = showList[showIndex].Runtime
currFeedItem.authParams = showList[showIndex].authParams
currFeedItem.StreamQualities = CreateObject("roArray", 1, true)
currFeedItem.StreamBitrates = CreateObject("roArray", 1, true)
currFeedItem.StreamUrls = CreateObject("roArray", 1, true)
currFeedItem.StreamQualities.Push(validstr(showList[showIndex].StreamQualities[k]))
currFeedItem.StreamBitrates.Push(validstr(showList[showIndex].StreamBitrates[k]))
currFeedItem.StreamUrls.Push(validstr(showList[showIndex].StreamUrls[k]))
PlayStart = RegRead(currFeedItem.ContentId)
if PlayStart <> invalid then
currFeedItem.PlayStart = PlayStart.ToInt()
endif
showVideoScreen(currFeedItem)
end for

endif
end if
else
print "Unexpected message class: "; type(msg)
end if
end while

return showIndex

End Function


Thanks
Leeladharan
0 Kudos
2 REPLIES 2
jbrave
Channel Surfer

Re: Having a playlist played from a list of media tags

I think you will want to throw up an image canvas and draw a black background before your "play all" loop executes. When the playback reaches the end of your video list, close the image canvas. You will want to call a function to show the image canvas and have that function run the loop that calls the video player, and only return from
the 'showcanvas"' function if the playlist reaches the end or the user interrupts the video.

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

Re: Having a playlist played from a list of media tags

Hi jbrave,

Thanks for the quick reply, I will try it today with changes as mentioned by your inputs.

Thanks
Leeladharan
0 Kudos