Forum Discussion

jbrave's avatar
jbrave
Channel Surfer
15 years ago

Trouble enqueing audio

Rather than try to decipher the whole complex audioapp application, I thought I would try using the example code for roAudioPlayer found on page 77 of the Component Reference PDF to test with. It appears to enque or at least try to enque, but I don't hear anything. Can anyone tell me what I might be doing wrong:

xfer.setURL(api+resource+user+uresource+ckey+limit+offset)
print resource+user+uresource+ckey+limit+offset
xferResult= xfer.GetToString()
print "transfer-result"+xferResult
if xmlFilelist.Parse(xferResult)
filearray=xmlFilelist.GetNamedElements("stream-url")
'now we have a list of the first up to 10 files
print "parse is true blue"
counter=0
print "counter="+counter.ToStr()

For Each file in xmlFileList.file
FileTitle=xmlFileList.file.GetNamedElements("title").[counter].GetText()
FileURL = xmlFileList.file.GetNamedElements("file-url").[counter].GetText()
FileDescription = xmlFileList.file.GetNamedElements("description").[counter].GetText()
print FileTitle+", "+FileURL
counter=counter+1
print "counter="+counter.ToStr()
song.url = FileURL+ckey
audioplayer.addcontent(song)

Next
End If


audioPlayer.SetMessagePort(port)
audioplayer.addcontent(song)
audioplayer.setloop(false)
audioPlayer.play()
while true
msg = wait(0, port)
if type(msg) = "roAudioPlayerEvent"
if msg.isStatusMessage() then
print "roAudioPlayerEvent: "; msg.getmessage()
if msg.getmessage() = "end of playlist" return
endif
endif
end while

When I run this, I get:

roAudioPlayerEvent: startup progress
roAudioPlayerEvent: startup progress
roAudioPlayerEvent: startup progress
roAudioPlayerEvent: startup progress
roAudioPlayerEvent: startup progress
...
roAudioPlayerEvent: end of playlist

and no sound.

2 Replies

  • First of all.. something to be aware of... the roAudioPlayer will always buffer up to 13% before failing, so it's likely you'll always see "startup progress" events whether you're doing it right or not. It's a good idea to capture the IsRequestFailed() event and review the msg.GetMessage() for details on why it failed.

    As for your code, I don't see anywhere where you setting anything more on the content metadata than the URL. You should set the URL and the StreamFormat at a minimum, otherwise you stand a chance of hard crashing the audio player, which will require a reboot. I also don't see where you're initializing "song", but I'll assume you just left that line out of your copy and paste. So, assuming your streams are MP3 streams (the only streaming audio format currently supported on the DVP), you'd want to add the following to your code immediately following the line that sets the URL:

    song.StreamFormat = "mp3"

    Try that, and see if you get any further...