在MainController.h文件更改如下:
#import "MainViewController.h"
#import <AVFoundation/AVFoundation.h>
@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;
}
我不知道,如果下面是必要的,但我打扫我的项目(CMD + ALT + K),重新编译的PhoneGap /科尔多瓦库(改变目标,并让它运行到模拟器)和(再次改变目标后)再次编译到应用程序,现在它的工作!
当心:它只能在设备,而不是在模拟器上
这样得出AVAudioSession一个错误,如果你不确保添加#进口 –
2015-02-07 12:37:51
遗憾的是还没有在最新版本的phonegap – 2015-02-07 13:04:56
上工作,这是行不通的 – 2017-06-14 18:58:21