Skip to content

Commit

Permalink
Only require background audio when using speech synthesis
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkirk committed Jun 20, 2024
1 parent 8fb6359 commit 7c02808
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions MapboxNavigation/RouteVoiceController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ open class RouteVoiceController: NSObject, AVSpeechSynthesizerDelegate {
override public init() {
super.init()

self.verifyBackgroundAudio()

self.speechSynth.delegate = self

self.resumeNotifications()
Expand Down Expand Up @@ -193,6 +191,9 @@ open class RouteVoiceController: NSObject, AVSpeechSynthesizerDelegate {
- parameter ignoreProgress: A `Bool` that indicates if the routeProgress is added to the instruction.
*/
open func speak(_ instruction: SpokenInstruction, with locale: Locale?, ignoreProgress: Bool = false) {
// Don't require background audio unless the implementer is actually using speech APIs
self.verifyBackgroundAudio()

if self.speechSynth.isSpeaking, let lastSpokenInstruction {
self.voiceControllerDelegate?.voiceController?(self, didInterrupt: lastSpokenInstruction, with: instruction)
}
Expand Down

0 comments on commit 7c02808

Please sign in to comment.