I need audio running in the background for my application. In versions before iOS 6 this worked perfectly by adding the
UIBackgroundModes
audio
code to the appropriate .plist file, however this no longer works when deploying my phonegap project to iOS 6. How can I fix this in iOS 6?
UIBackgroundModes
audio
code to the appropriate .plist file, however this no longer works when deploying my phonegap project to iOS 6. How can I fix this in iOS 6?
- 7 Posts
- 0 Reply Likes
- frustrated
Posted 8 years ago
- 7 Posts
- 0 Reply Likes
I fixed this changing the top of the MainController.m file to the following:
#import "MainViewController.h"
#import < AVFoundation/AVFoundation.h > // delete te spaces between < and >
@implementation MainViewController
- (id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
NSError *setCategoryError = nil;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryError];
}
return self;
}
#import "MainViewController.h"
#import < AVFoundation/AVFoundation.h > // delete te spaces between < and >
@implementation MainViewController
- (id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
NSError *setCategoryError = nil;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryError];
}
return self;
}
- 2 Posts
- 0 Reply Likes
I am getting the same error, and I am new to iOS. I tried your solution, but getting an error "Use of undeclared identifier 'AVAudioSession'". Could you please let me know how you solved yours?
- 7 Posts
- 0 Reply Likes
You probably didn't import the "< AVFoundation/AVFoundation.h >" library. I've updated the code sample as it didn't properly show on the forum here, it probably thinks it's an HTML tag :)
- 1 Post
- 0 Reply Likes
Thankyou Jill, this worked for me and I am using an MPMoviePlayerController object.
Although I did not think I would have to call AVAudiosession after reading this:
https://developer.apple.com/library/i...
(but perhaps I misunderstood, I'm new to iPhone dev)
Nevertheless.....thanks ! : )
Although I did not think I would have to call AVAudiosession after reading this:
https://developer.apple.com/library/i...
(but perhaps I misunderstood, I'm new to iPhone dev)
Nevertheless.....thanks ! : )
- 2 Posts
- 0 Reply Likes
Hi Jill, Is the solution working in your simulator? I read several posts in web where it says that the background audio will not work in simulator, but will work in phone. Just wanted to see if yours in working in simulator. I tried it; it is not working in mine.
- 2 Posts
- 0 Reply Likes
Hi
Very cool - this has been bothering me for ages - thank you so much
Is there an easy way to setup a preference pane in the IOS desktop settings app to turn background audio on and off?
Very cool - this has been bothering me for ages - thank you so much
Is there an easy way to setup a preference pane in the IOS desktop settings app to turn background audio on and off?
- 3 Posts
- 0 Reply Likes
Hello
I have several apps with large audio files that I am updating. I am using a project set up from Dreamweaver and don't seem to have an MainController.m file. Would I have to start the project in Xcode in order to get this? If anyone has an example for playing an audio file I would be extremely grateful.
Thanks :-)
I have several apps with large audio files that I am updating. I am using a project set up from Dreamweaver and don't seem to have an MainController.m file. Would I have to start the project in Xcode in order to get this? If anyone has an example for playing an audio file I would be extremely grateful.
Thanks :-)
- 2 Posts
- 0 Reply Likes
Hi Andrew
I'm no expert but I'm sure that Xcode / Phonegap creates that file on project creation
I'm no expert but I'm sure that Xcode / Phonegap creates that file on project creation
- 68 Posts
- 7 Reply Likes
I'm also experiencing this issue in iOS 6. I'm streaming audio but when you push the button to go to the home screen, the audio stops playing. I'm guessing the PG Build team would need to make changes to have this work properly. I'm wondering if this is a possibility?
Thanks
John
Thanks
John
- 11 Posts
- 0 Reply Likes
hmmm...does this sollution work with html5 audio tag in phonegap 2.3.0?? tried it but when I exit the app audio does not stay in background.
- 1 Post
- 0 Reply Likes
For me this solution works for the HTML5 audio tag, but not for the phonegap Audio() player.
BTW, I put the code in the AppDelegate.m init() method
BTW, I put the code in the AppDelegate.m init() method
- 3500 Posts
- 40 Reply Likes
Assuming the question has been answered, this issue is now closed.
Create a new issue if you have any other problem with PhoneGap Build.
Thanks
Create a new issue if you have any other problem with PhoneGap Build.
Thanks
This conversation is no longer open for comments or replies.
This conversation is no longer open for comments or replies.
Related Categories
-
PhoneGap Build
- 15111 Conversations
- 275 Followers



