Catch Error: Audio queue creation failed
Hi,
on iOS I'm using
Ti.Media.createAudioPlayer(
{preload:true,allowBackground:true,
url:'http://radio.musicvictim.com:8012'});
to create an AudioPlayer.
Randomly I obtain an "Audio queue creation failed" when I start() this player.
How can I catch this error and re-try to start() the player?
Is there any best method to listen shoutcast streaming audio?
Thank you very much.
5 Answers
-
Accepted Answer
The short answer is you can't listen to most streams in Titanium because of a bug in the AudioStreamer and Titanium. The problem is they treat the path to the stream as a file and expect an extension so they know the type of stream that it is.
So this will not play:
http://someserver.com/musicstream
But this will:
http://someserver.com/musicstream.mp3
But this won't because the extension of the file is aspx and the other thing is just a parameter.
http://someserver.com/musicstream.aspx?file=somefile.mp3
So you most likely will not be able to play a shoutcast stream.
BUT…. If you look at my 4.2 SDK post and try my version of the mobile SDK you will see that it probably will play shoutcast. The difference is I have modified several of the sound objects to accept a parameter called mediaType. So I can stream like this:
var streamer = Ti.Media.createAudioPlayer({mediaType: 'aac'}); streamer.url = "http://scfire-ntc-aa02.stream.aol.com:80/stream/1049"; streamer.start();
My site lists the stream types I support IF you set the mediaType to the right type like mp3 or aac.
-
You can't try/catch that type of error unfortunately because it is being emitted by the Objective-C itself.
The culprit, BTW, is usually AudioStreamer.m. If you look in that file you will see that when a stream fails AudioStreamer will create a UIAlertView instead of just returning a status code. If you are adventurous you can comment the alerts out.
-
Use a try-catch block…
try { var player = Ti.Media.createAudioPlayer({ preload : true, allowBackground : true, url : 'http://radio.musicvictim.com:8012' }); player.start(); } catch (err) { Ti.API.log('error ' + err); // clean up and retry here.. }
-
Wow… I understand there's no other way to listen a shoutcast streaming server. Correct?
About the try/catch… I understand that this is a bug.
-
In Titanium Studio 1.0.7 / SDK Version 1.0.8.1 the error message appears 4 times in AudioStreamerBC.m AND 3 times in AudioStreamerCUR.m
Can somebody with Objective-C expirience modify those files in order to return the error so we can 'catch it' and create our own error message?
Thanks in advance!