Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 8    Views: 61

mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
09/12/12 02:40 PM (12 years ago)

Quick question regarding mp3 sounds and the iphone sleeping

Hey all, Girlfriend is making an application that plays some .mp3's using custom URL. The problem is she needs to make it continue to play even when putting the iphone/ipod/ipad to sleep. I know I saw the solution around here somewhere, but need to head to class in 2 seconds - was hoping someone could do me a solid and find the solution for me? Cheers, David buzztouchmods.com
 
Paddy
Lost but trying
Profile
Posts: 240
Reg: Oct 08, 2011
Hands Up !
12,500
like
09/12/12 03:03 PM (12 years ago)
 
Rad Doc
Apple Fan
Profile
Posts: 653
Reg: Oct 08, 2010
USA, NYC
8,580
like
09/13/12 02:27 AM (12 years ago)
@David, Check out the linked thread. This should solve your problem, Although it is for 1.5, dunno what which platform you are using. It'll allow you to play music like pandora. http://www.buzztouch.com/forum/thread.php?tid=FE4DEC41BB3C34F3575D4A3
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
09/13/12 06:59 AM (12 years ago)
@MrDavid Those methods don't work in BT 2.0. I'm kicking around a audio plug-in that does this witht he BKG audio and a session. I Have it working in a generic app I made with the SDK, but still trying to figure this out for BT 2.0. Very much seeking this solution myself.... (but trying to finish up some other stuff first before I get back into it)
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
09/13/12 02:49 PM (12 years ago)
Thanks guys, glad to be able to depend on you all :-) I got it to work (@atrain it seems to work for 2.0!) This is what I did from other peoples posts: "Try adding this to your target info plist.You need to set-up the Background audio by adding a UIBackgroundModes to your app Custom IOS Target Properties. This is NOT the same as the Bt_info.plist. This is the Target properties 'info' screen where the Bundle Indentifier, Bundle Name and Icon File are stored. You add a row to this and call it UIBackgroundModes. Xcode will then magically change that row name and set-up an array with some dynamic fields and one is called APP Plays Audio." and I added this in the BT_Core/bt_audioplayer.m file (instead of audio.m in 1.5) //Adds ability for audio to play even in screen lock NSError *setCategoryErr = nil; NSError *activationErr = nil; [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryErr]; [[AVAudioSession sharedInstance] setActive: YES error: &activationErr]; right below the code: //box for controls UIView *box = [[UIView alloc] initWithFrame:CGRectMake(0, 0, boxWidth, 190)]; box.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin); [box setCenter:CGPointMake(center, top)]; [box setBackgroundColor:[UIColor blackColor]]; box = [BT_viewUtilities applyBorder:box:2:[UIColor lightGrayColor]]; box = [BT_viewUtilities applyRoundedCorners:box:10]; Works perfectly. Cheers, and thanks paddy/rad, those links were invaluable. David.
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
09/14/12 07:38 AM (12 years ago)
Awesome! That's killer news if it's working in 2.0 Does that work on the simulator too? It never seemed to work there or on my 3G test device. keep meaning to revisit the subject, but other stuff... Did you have to remove this code from the appDelgate? //setup audio session for background sounds. Allow iPod to continue if it's already playing. [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil]; [[AVAudioSession sharedInstance] setActive: YES error: nil] what are you playing, streaming URL? local audio file?
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
09/14/12 08:17 AM (12 years ago)
Hey @Atrain. I did not remove any code from appDelgate. I'm using the iPhone 4 3G, 5.1.1 - I'm streaming a .mp3 URL from the Custom URL plugin on the device (not simulator). Tell me if that helps? I only added that code into bt_audioplayer.m file and did UIBackgroundModes for that to work :-) Cheers, David buzztouchmods.com
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
09/14/12 09:37 AM (12 years ago)
Thanks for the follow up, will let you know in a couple of days. I was trying to make this work to play local audio I packaged in my app, but it wasn't working for streaming either. I tried with/without the mod to the appdelegate with no success. Lincoln made a vid on this and IIRC it was workign in the simulator too, so I expected to see it work too. But he was doing this for s for 1.5. and congrats on the SEARCH plug-in, just saw that on the market!
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
09/14/12 11:28 AM (12 years ago)
Thanks! And no problem. I'll do it on video for you if it doesnt work out, then just copy exactly what I did :) Edit: or a guide, heh, not the best speaker. Cheers, David buzztouchmods.com
 

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.