Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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.

— asked November 10th 2010 by Eric Sala
  • audio
  • createaudioplayer
  • ios
  • iphone
  • queue
  • streaming
0 Comments

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.

    — answered November 10th 2010 by John McKnight
    permalink
    1 Comment
    • I was able to successfully listen to the stream included in the questions so I am confused?? Does it work or not?

      — commented November 11th 2010 by Aaron Saunders
  • 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.

    — answered November 10th 2010 by John McKnight
    permalink
    2 Comments
    • 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.

      — commented November 10th 2010 by Eric Sala
    • 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!

      — commented January 28th 2012 by Cesar Estrada
  • 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..
    }
    
    — answered November 10th 2010 by Aaron Saunders
    permalink
    1 Comment
    • I have tried this

          var player = Ti.Media.createAudioPlayer({
              preload : true,
              allowBackground : true,
              url : 'http://radio.musicvictim.com:8012'
          });
      try { 
          player.start();
      } catch (err) {
          Ti.API.log('error ' + err);
      }
      

      but the error still visible. The "try" doesn't "catch" the error.
      Any suggestions?
      Thank you very much.

      — commented November 10th 2010 by Eric Sala
  • 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.

    — answered November 10th 2010 by Eric Sala
    permalink
    0 Comments
  • 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!

    — answered January 28th 2012 by Cesar Estrada
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.