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

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

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.

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

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

  • J

“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.