Iphone 在后台使用AVSpeechSynthesizer

Iphone 在后台使用AVSpeechSynthesizer,iphone,ios,ios7,xcode5,Iphone,Ios,Ios7,Xcode5,当应用程序在后台时,我也会尝试使用它,尝试在功能->后台->播放音频中添加它。还检查了plist是否有这条线 但这不起作用。我错过了什么?我只能播放常规音频吗 添加目标信息。p将“所需背景模式”键输入“应用程序使用AirPlay播放音频或流式播放音频/视频” 在AppDelegate中配置音频会话: NSError *error = NULL; AVAudioSession *session = [AVAudioSession sharedInstance]; [session setCateg

当应用程序在后台时,我也会尝试使用它,尝试在功能->后台->播放音频中添加它。还检查了plist是否有这条线

但这不起作用。我错过了什么?我只能播放常规音频吗

  • 添加目标信息。p将“所需背景模式”键输入“应用程序使用AirPlay播放音频或流式播放音频/视频”
  • 在AppDelegate中配置音频会话:

    NSError *error = NULL;
    AVAudioSession *session = [AVAudioSession sharedInstance];
    [session setCategory:AVAudioSessionCategoryPlayback error:&error];
    if(error) {
        // Do some error handling
    }
    [session setActive:YES error:&error];
    if (error) {
        // Do some error handling
    }
    
    别忘了导入AVFoundation.h


  • @nicu的功劳

    我也有同样的问题,请查看Imahaly对我的问题的回答:@nicu将此作为回答,谢谢!