I use AVSpeechSynthesizer
to play text books via audio.
private lazy var synthesizer: AVSpeechSynthesizer = {
let synthesizer = AVSpeechSynthesizer()
synthesizer.delegate = self
return synthesizer
}()
let utterance = AVSpeechUtterance(string: text)
utterance.voice = AVSpeechSynthesisVoice(
language: languageIdentifier(from: language)
)
synthesizer.speak(utterance)
I want to update information in iPhone's default player view (probably naming is wrong 🙏):
How can I accomplish this?
I really don't think you want to hack your way through this.. But if you really do I would:
UIApplication.sharedApplication().beginReceivingRemoteControlEvents()
, see Apple Sample ProjectMPNowPlayingInfoCenter
: MPNowPlayingInfoCenter.default().nowPlayingInfo[MPMediaItemPropertyTitle] = "Title"
AVSpeechSynthesizerDelegate
and try to map the delegate functions to playback states and estimate the playback progress using speechSynthesizer(_:willSpeakRangeOfSpeechString:utterance:)
(idk if possible)usesApplicationAudioSession
property of AVSpeechSynthesizer
to have more control over the audio session (set categories etc.)