Discussion Forums  >  Audio, Video, Playing, Recording

Replies: 7    Views: 152

AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
10/25/12 07:03 AM (13 years ago)

Can you play audio while phone hibernates?

I am building a BT 2.0 app (Andriod and IOS) that plays one single audio clip. I was using html5 as the audio player, but I found when my iPhone hibernates, the audio stops!. Now I'm stuck! I read a method for allowing background audio in this post http://www.buzztouch.com/forum/thread.php?tid=FE4DEC41BB3C34F3575D4A3. I thought I would start in Xcode by setting the Required Background mode for audio, but I fell at the first hurdle, it seems IOS 6 and Xcode 4.5 has introduced some changes and that setting has disappeared. So I am back to square 1 - can anyone suggest a way of getting a single audio file to play? My basic requirement for the app is :- - User navigates to a page from a menu button. - Page has an explanatory message and a play button. - Media plays without navigating away from the app (ie you can go 'back' into the app). - User can see progress and adjust audio controls if needed. - Media stops playing if the user navigates away from page. - Media plays even if device hibernates. - Media is loaded locally (it is an offline app)
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
10/25/12 08:53 AM (13 years ago)
This is how I managed to get the radio to continue streaming on 1.5 iOS. http://www.buzztouch.com/forum/thread.php?tid=7A474A813F3BB85E439589B&command=isSearching&currentPage=1&topicTitle=&createdBy=Alex@TM&repliedBy=&minViews=-1&maxViews=-1&minReplies=-1&maxReplies=-1&forumCategory= However, if you take a look at the final image on the app linked below, I created a radio stream using MPMoviePlayerController. It has a play and a stop button. This was not made on Buzztouch and I plan to create a plugin. What you need to do is create an audio session. To add say an .mp3 and play it locally you just need to add it to the project resources and call it in the code rather than link it to the url. Hope this helps.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
10/25/12 01:15 PM (13 years ago)
I looked, I think this looks a couple of levels too hard for me. The plugin sounds great though!
 
Alex@TM
Apple Fan
Profile
Posts: 956
Reg: Dec 20, 2011
London, UK
10,560
like
10/25/12 01:47 PM (13 years ago)
Happy to talk you through it. The only thing about doing it like this is that you get the apple quicktime logo. Maybe wait for the plugin if that suits. I will be on it early next week hopefully.
 
LeonG
Apple Fan
Profile
Posts: 694
Reg: Nov 08, 2011
Hamburg
17,740
like
10/26/12 01:52 AM (13 years ago)
Only way you can do this now is with background music. It will start as soon as the screen is chosen, controls are selectable.
 
amysus
Lost but trying
Profile
Posts: 90
Reg: Oct 28, 2011
traveling the w...
3,650
like
10/28/12 10:37 AM (13 years ago)
Hmm - I am in a similar situation. I am using background audio with an html page (custom html) and xCode 4.2 and it seems to be working fine. I have not yet downloaded 4.5 - are saying that background audio no longer works in 4.5? My requirements are the same as Alan's, except that I would like the music to auto play.
 
LeonG
Apple Fan
Profile
Posts: 694
Reg: Nov 08, 2011
Hamburg
17,740
like
10/28/12 12:41 PM (13 years ago)
Works with 4.5 so no worries
 
amysus
Lost but trying
Profile
Posts: 90
Reg: Oct 28, 2011
traveling the w...
3,650
like
10/28/12 12:44 PM (13 years ago)
Just downloaded and installed - it works! Thank you Leon.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.