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.