Forum Discussion

zcode7's avatar
zcode7
Visitor
13 years ago

Playlists

Just a quick issue - there is no example of how to make your content into playlists.

Specifically, if I want to make a list of on-screen MP3s play one after the other, is there a built-in functionality to do this?

I also want to integrate a "next" button, is this functionality built into the audio player? The documentation doesn't really say anything about that.

4 Replies

  • Playlists are built into the roAudioplayer component. Implementing a next button is the discretion of the developer.

    A quick playlist:

    sub main()
    audioplayer=createobject("roaudioplayer")
    playlist=[{url:"http://myserver.com/song1.mp3",streamformat:"mp3"}
    {url:"http://myserver.com/song2.mp3",streamformat:"mp3"}
    {url:"http://myserver.com/song3.m4a",streamformat:"mp4"}]

    audioplayer.setcontentlist(playlist)
    audioplayer.setnext(0)
    audioplayer.play()

    while true
    'loop forever for this example, in the real world you would be checking the message port and tracking current song etc.
    end while
    end sub


    To implement a next button, I'm assuming you are using an roSpringboardScreen, and you would add a button with the addbutton method, and implement an if-then to handle when that button is pressed, in which case you would use the setnext() property, and call play()

    - Joel
  • Hey Joel - thanks for the help there. I'm trying to just have a function that goes to the next content item - doesn't the app already know what content item I'm currently on? How do I retrieve this information and use it in setNext? When I use Play() does it play the current item or always play the item that is "set Next"?
  • You need to keep track of this in a separate variable, so when you create a playlist and initiate playback, lets say you start from the second item in the playlist because you don't like the first two songs, you would set your index variable to 1 since lists are arrays which are zero indexed where the first item in the list is list[0]. When you get an roAudioPlayerEvent that indicates the end of playback isrequestsucceeded() I think is the event, then you would increment your index, so you would know which song you are on.

    I believe it will use whatever you setnext()

    - Joel