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: 
jbrave
Channel Surfer

how to pick file to play from Poster screen?

I have an array of url's which I've added to audioplayer with audioplayer.getcontent(song). As I'm adding url's to the audio player, in the same ForEach loop, I'm adding title and description to an array called PosterList. What I wind up with is a poster screen with 10 tracks listed in it, and an audioplayer with 10 urls loaded.
When a user selects an audio track to play from the PosterScreen, what do I do to call audioplayer to play that track?

Thanks,

Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
5 REPLIES 5
renojim
Community Streaming Expert

Re: how to pick file to play from Poster screen?

I'm guessing you mean AddContent(song), not getcontent(song). I hope you're also setting song.StreamFormat. You would want to capture the isListItemSelected() poster screen event and then call audioPlayer.SetNext(msg.GetIndex()). Then call audioPlayer.Play() to start the song. You'd have to capture audio player events to stop it at the end of the song or it will play all the songs you've added.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
jbrave
Channel Surfer

Re: how to pick file to play from Poster screen?

Yeah, addcontent(song), and yes I did set the stream format and yes, it plays through all 10 songs unless I tell it to stop based on the "stream ended" message.

isListItemSelected() gives me a boolean... how do I know which item is selected, and then how do I pass that information to the audioplayer? I'm not sure how GetIndex of the audio file list is linked to the poster screen, or how to link them.
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
renojim
Community Streaming Expert

Re: how to pick file to play from Poster screen?

isListItemSelected() just tells you that the user pressed the select button on one of the posters. Getindex() tells you which poster the user selected. Your code should look something like this:

while true
msg = wait(0, port)
if type(msg) = "roPosterScreenEvent" then
if msg.isListItemSelected() then
idx = msg.GetIndex() ' <-- gives the index of the selected poster
audioPlayer.SetNext(idx) ' <-- sets the song to play to the same index as the poster
audioPlayer.Play() ' <-- start the song
end if
else if type(msg) = "roAudioPlayerEvent" then
' put the code to stop at the end of the song here
end if
end while

If you added the posters and the songs in the same order then the index returned by msg.GetIndex() should match the index of the appropriate song loaded in the audio player.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
jbrave
Channel Surfer

Re: how to pick file to play from Poster screen?

so the index is a number, code or pointer of some kind?

- J
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
TheEndless
Channel Surfer

Re: how to pick file to play from Poster screen?

"jbrave" wrote:
so the index is a number, code or pointer of some kind?

- J

msg.GetIndex() returns an integer. It's meaning is different depending on what the msg is. In the case of IsListItemSelected(), it's the index of the current content item selected in the ContentList you provided to the roPosterScreen.
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)
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.