Your Digital Media Has Never Looked So Good

 
leeladhar
Topic Author
Posts: 25
Joined: Wed Nov 10, 2010 9:13 pm

Having a playlist played from a list of media tags

Sun Oct 30, 2011 11:38 pm

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

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

Mon Oct 31, 2011 6:57 am

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!
 
leeladhar
Topic Author
Posts: 25
Joined: Wed Nov 10, 2010 9:13 pm

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

Mon Oct 31, 2011 9:37 am

Hi jbrave,

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

Thanks
Leeladharan

Who is online

Users browsing this forum: No registered users and 15 guests