bmu*_*ler 7 ios avspeechsynthesizer ios8
我正在使用AVSpeechSynthesizer单身人士.在iOS 8中,当应用程序被搁置一段时间后,当它恢复时,AVSpeechSynthesizer单身人士将不再说话.iOS 7上不会发生此问题.
当应用程序变为后台时,我的日志中会显示以下消息:
AVSpeechSynthesizer Audio interruption notification: {
AVAudioSessionInterruptionTypeKey = 1;
}
Run Code Online (Sandbox Code Playgroud)
我AVSpeechSynthesizer用singleton的init方法初始化了这个:
self.speechSynthesizer = [[AVSpeechSynthesizer alloc] init];
self.speechSynthesizer.delegate = self;
Run Code Online (Sandbox Code Playgroud)
我说的utterance是这样的:
AVSpeechUtterance *utt = [[AVSpeechUtterance alloc] initWithString:dialogue];
utt.voice = [AVSpeechSynthesisVoice voiceWithLanguage:voice];
utt.pitchMultiplier = pitch;
utt.rate = rate;
utt.preUtteranceDelay = preDelay;
utt.postUtteranceDelay = postDelay;
utt.volume = volumeSetting;
[self.speechSynthesizer speakUtterance:utt];
Run Code Online (Sandbox Code Playgroud)
iOS 8上有没有人见过这样的东西?
Ale*_*cić 13
我整天都在追逐这种疯狂,我想我找到了解决方案.我的问题是,AVSpeechSynthesizer在前台和后台工作正常,同时将其他音频保留到电话呼叫的那一刻.
那一刻,说话会停止工作,没有任何错误.所有对象仍然存在,但委托调用不会被调用,无论是开始还是完成.
我注意到通过电话,我的应用程序会收到通知AudioRouteChanged.因此,当发生这种情况时,我会重新创建语音设置:基本上销毁现有AVSpeechSynthesizer并重新创建它.从那时起,演讲将继续奏效.它甚至可以在通话期间工作:)
| 归档时间: |
|
| 查看次数: |
4995 次 |
| 最近记录: |