Titanium Community Questions & Answer Archive

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

App approved - thank you to Appcelerator!

Just wanted to give a big thanks to Appcelerator for making this product available.

My first app has been approved and is in the App Store now. It uses background audio, has lots of streaming video and a lot more.


A word of note - as someone else noted in the Q&A, be careful of how you set UIBackgroundModes in your Info.plist. I had mine set for Audio and Location. I incorrectly thought that because I was getting the user's location I had to set Location. This isn't true. I realized after that you only set this if you need the user's location when the app isn't active in the foreground. This may be obvious to some, but to me it wasn't at first.

My first submission was rejected because of this so I resubmitted, waited the 5 days to get into review and then another 1/2 day to get approved.

— asked September 5th 2010 by E Telford
  • audio
  • background
  • iphone
  • uibackgroundmodes
1 Comment
  • Very nice app! I was very surprised to see streaming audio in the background, or at least when the phone goes into sleep mode, as I haven't been able to figure this out for many weeks. I even signed up for pro support, and have not been able to figure out how to have streaming audio when:

    1) The phone is asleep
    2) The app is in the background

    Can you please share the settings you used to get the audio to stream when asleep?

    Thanks in advance,

    Peter Janett

    — commented September 8th 2010 by Peter janett

8 Answers

  • Peter - you need to set…

    Ti.Media.defaultAudioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAYBACK;

    Also, in your Info.plist make sure you add audio to the UIBackgroundModes section. There's plenty of info about in the Q&A and elsewhere on the web if you're unsure exactly how to do that.

    — answered September 8th 2010 by E Telford
    • Eric,
      Thanks so much for your willingness to help. I have honestly been told by Pro support that streaming audio in the background is not yet supported, so I'm very excited to see how you got it to work..

      In my testing so far, I've been able to get background audio, but only using Titanium.Media.Sound, which does not stream the audio, but instead downloads the entire audio file, then plays it.

      So, I would be SO grateful if you can simply share the basic syntax you used.

      Here's what I have tried after your suggestion, which is not working, even with the info.plist change:

      Ti.Media.defaultAudioSessionMode = Ti.Media.AUDIO_SESSION_MODE_PLAYBACK;
      var streamer = Ti.Media.createAudioPlayer({allowBackground:true, audioSessionMode:Titanium.Media.AUDIO_SESSION_MODE_PLAYBACK});
      streamer.url = 'PATH TO MY MP3';

      Of course, that is simplified, as the streamer.start is in a click event, the url is pulled from json, etc., but if you could share the basic syntax like this for what worked for you, I'd be SO grateful.


      Peter Janett

      — commented September 9th 2010 by Peter janett
    • Peter - are you trying this in the simulator or on an actual device that supports BG audio? BG audio won't work in the simulator. It will work on a device.

      Not sure why Appcelerator says they don't support it when it works fine - except for the part that you can't control the audio from the iPod controls. Maybe that's for the next release.

      — commented September 10th 2010 by E Telford
  • Great job :) From those screenshots, it looks like a great App :)

    — answered September 5th 2010 by Colton Arabsky
    1 Comment
    • Thank you, Colton.

      — commented September 5th 2010 by E Telford
  • Awesome job, looks pretty cool. I like how you used background streaming but the pause and play button don't work with the ipod control. Is this something for yourself or did you do this app for the singer?

    — answered September 5th 2010 by Sj Singh
    • I'm guessing he himself is Erik Telford since, well, his name is "E Telford" :P

      — commented September 5th 2010 by Colton Arabsky
    • haha missed that

      — commented September 5th 2010 by Sj Singh
    • That's right. It is I. It's to give me another way to promote my shows, music, etc. If I'm playing a gig, I can tell people in the audience who have an iPhone to go and just download the app and they immediately get a whole bunch of free content with the option to purchase if they want an offline copy.

      — commented September 5th 2010 by E Telford
  • Good job.. downloaded and I'm impressed. I'd love to have this app as a template to do my own but I know that would be asking for too much.. :)

    Interesting how Apple allowed you to have the Buy Direct feature to by-pass their in-app model. What happens after someone checks out through PayPal, how to do they get the audio to the phone?

    — answered September 5th 2010 by Z K
    • I'm guessing it just gets Emailed to them and they have to Download it and put it on their phone themselves?

      — commented September 5th 2010 by Colton Arabsky
    • ZK - Thank you. I'm glad you like it.

      Colton - You're exactly right. The Buy Direct option will let a user purchase a physical copy of the item directly from me. I plan on enhancing this in the future (maybe do in-app purchase or at least a cleaner gateway built right into the app), but I feel for now it'll suffice.

      — commented September 5th 2010 by E Telford
  • Sj Sing - I couldn't figure out how to get the Play/Pause button in the iPod controls to control the background audio. I even posted in the Q&A to see if others had a possible solution, but I didn't hear anything back.

    While the Titanium Mobile platform is amazing and pretty complete, I see a lot of work that's needed to be done on the Media API. I'm hoping SDK 1.5 will address some of these issues (maybe local notifications will help with this?), but like I said, TI is already incredibly powerful so I'm very pleased. For me, not being able to use the iPod controls ss kind of a bummer, but it isn't a deal breaker for me. I think I implemented the streaming audio as well as I could with the time I allowed myself.

    Here's some other information regarding the development process that may be useful to some.

    My overall idea was that I wanted as much of the content in the app as possible to be driven dynamically from my web server. This way I can add/update/delete content as I see necessary.

    Audio & Photos - stored on my web server in a private directory. I use basic authentication to pull them into the app. I use XML files to look at which content I have available.

    Video - pulled from my Vimeo profile using the Basic API.

    Calendar - parsed from a Google Calendar that I have for my gigs. I have the same parser on my website so it was easy to adapt for the app.

    News - this is just the RSS feed from my website - www.ejtmusic.com.

    Mailing List (in the Settings part of the app) - managed through the Campaign Monitor API.

    Push Notifications - handled through Urban Airship.

    There were other options I explored at length. One was having real playback controls in the app itself for streaming audio. I found, however, that when audio is streamed there are some bugs with how it detects the length of the audio file. And, there's currently no way to control the volume of streamed audio so playback controls became less important in my mind.

    I also toyed with the idea of allowing people to download tracks right to their device, but again I decided maybe that's for a future release.

    I'm happy to answer any other questions anyone might have.

    — answered September 5th 2010 by E Telford
    • wow, thanks for describing the process!

      I notice you have add notifications for the events. I'm implementing something like that for one of my apps and was wondering if I have it right. You register the device to Urban airship and then take the registered udid and make a request to your server to have it stored with the event info and device info. Then you have a cron running that does a push to urban airship if there is any device that's registered to any upcoming events … am I on the right track or did you use a different approach?

      — commented September 5th 2010 by Sj Singh
    • Any chance you figured out how to connect the iPod controls? I'd really really like to get them working.

      — commented October 26th 2011 by Nick Robillard
    • Check this out: https://marketplace.appcelerator.com/apps/1109

      — commented November 21st 2011 by manuele capp
  • Congrats! Keep up the great job!

    — answered September 6th 2010 by A F
  • Sj Sing - regarding push notifications…

    Not exactly. You register w/ Urban Airship like in the Kitchen Sink example or the example on the urban airship blog.

    After you have a device registered you can choose a couple of different methods for sending notifications to users. For my event notifications I let Urban Airship handle it by registering a delayed notification via their API. Check out the documentation on their site for more info.

    — answered September 6th 2010 by E Telford
  • Great trumpet playing too! Really like "Transitions"

    — answered September 9th 2010 by Kosso
    1 Comment
    • Thanks, Kosso. Much appreciated.

      — commented September 10th 2010 by E Telford
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.