后台模式下的 AVSpeechSynthesizer [英] AVSpeechSynthesizer in background mode

查看:27
本文介绍了后台模式下的 AVSpeechSynthesizer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的 iOS 应用程序处于后台模式时,我无法让 iOS 7 AVSpeechSynthesizer 工作.我在应用支持的后台模式中添加了应用播放音频"键,但我仍然无法让它工作.

I can't get the iOS 7 AVSpeechSynthesizer to work when my iOS app is in background mode. I have added the "App plays audio" key to the app's supported background modes, but I still can't get it to work.

我还研究了使用 AVSpeechSynthesizer 语句创建 AVMutableCompositionTrack 的可能性,然后以某种方式与能够在后台运行的播放器一起播放- 但没有运气.

I have also investigated the possibility of creating an AVMutableCompositionTrack, with an AVSpeechSynthesizer utterance, and then somehow play it with a player that would be able to run in the background - but with no luck.

在后台使用 AVSpeechSynthesizer 时,有没有人比我运气好?

Did anyone have better luck than me in using AVSpeechSynthesizer in the background?

推荐答案

  1. 您必须在后台模式中设置音频和 AirPlay".
  2. 您必须配置音频会话:

    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
    }

这篇关于后台模式下的 AVSpeechSynthesizer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆