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

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.
0 Kudos
4 REPLIES 4
RokuJoel
Binge Watcher

Re: Playlists

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
0 Kudos
zcode7
Visitor

Re: Playlists

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"?
0 Kudos
RokuJoel
Binge Watcher

Re: Playlists

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
0 Kudos
kasiris
Channel Surfer

Re: Playlists how to change data feed location?

How do I change the data feed from playlist=url:http://myserver

to my webhost url (example: http://www.myhost.com/a.json)?

0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.