在我的应用程序中,我使用AVSpeechSynthesizer对象来使用TTS。我想在控制中心的信息框中更新一些关于我正在与合成器对话的内容的信息,但这些信息不会显示在控制中心中。首先,我将AVAudioSession设置为在后台使用
do {
try AVAudioSession.sharedInstance().setCategory(.playback, options: .duckOthers)
try AVAudioSession.sharedInstance().setMode(.default)
try AVAudioSession.sharedInstance().setActive(true)
} catch {
print(error)
}然后我设置MPNowPlayingInfoCenter的nowPlayingInfo,设置一些MPMediaItemProperty键,但在控制中心有音乐应用程序,而不是我的信息。
发布于 2019-10-18 17:25:51
解决方案是使用AVAudioSession.sharedInstance().setCategory(.playback)方法,无需传递任何选项参数,即可在控制中心显示在MPNowPlayingInfoCenter中设置的信息。
https://stackoverflow.com/questions/58446958
复制相似问题