本文介绍了AVSpeechSynthesizer在后台模式下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我的iOS应用处于后台模式时,我无法使iOS 7 AVSpeechSynthesizer
正常工作。我已将 App播放音频键添加到应用程序支持的后台模式,但我仍无法使其正常工作。
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 在后台吗?
推荐答案
- 您必须在后台模式中设置Audio and AirPlay 。
- 您必须配置音频会话:
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在后台模式下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!