Hi all..have a question regarding playing audio (mp3) content back to back.
I first create a blank image canvas (going to use it for something else later) and want to play an array of audio content over it.
The audio plays fine and loads each track in the array. The problem is I can't get out of it. I'm stuck in the inner while loop (for the audio) and when I have a "image canvas" event like pressing up remote key to exit, it doesn't respond until the playlist is finished. Any help would be appreciated. Been a while since I've coded with BS.
Function showPlaylistImageCanvas(category As Object, showList As Object, showIndex as Integer) as void
canvas = CreateObject("roImageCanvas")
port = CreateObject("roMessagePort")
canvas.SetMessagePort(port)
canvas.Show()
'start with second item in list - first item is only a placeholder
showIndex = getNextShow(showList, showIndex)
show = showList[showIndex]
audio2 = CreateObject("roAudioPlayer")
port2 = CreateObject("roMessagePort")
audio2.SetMessagePort(port2)
item = CreateObject("roAssociativeArray")
item.isPlayState = 0
item.Url = show.StreamUrls[0]
item.StreamFormat = "mp3"
audio2.AddContent(item)
audio2.SetLoop(false)
audio2.Play()
while true
msg2 = wait(0, port2)
if type(msg2) = "roAudioPlayerEvent"
if msg2.isStatusMessage() then
print "roAudioPlayerEvent: "; msg2.getmessage()
if msg2.getmessage() = "end of stream" then
print "end of stream"
showIndex = getNextShow(showList, showIndex)
show = showList[showIndex]
item = CreateObject("roAssociativeArray")
item.isPlayState = 0
item.Url = show.StreamUrls[0]
item.StreamFormat = "mp3"
audio2.AddContent(item)
audio2.SetLoop(false)
audio2.Play()
elseif msg2.getmessage() = "end of playlist" then
audio2.Stop()
shouldPlaylistExit = true
endif
endif
endif
if shouldPlaylistExit
exit while
end if
end while
'while loop for image canvas
while(true)
msg = wait(0,port)
if type(msg) = "roImageCanvasEvent" then
if (msg.isRemoteKeyPressed()) then
i = msg.GetIndex()
print "Key Pressed - " ; msg.GetIndex()
if (i = 2) then
' Up - Close the screen.
canvas.close()
end if
else if (msg.isScreenClosed()) then
print "Closed"
return
end if
end if
end while
End function