Search code examples
iosswiftavfoundationaccessibilityvoiceover

Sound overlaps with voiceover and AVFoundation player


In my iOS app, I have a button which can play sound after clicking on it, however this button has a voiceover function at the same time. When I click on the button, both of the two sounds overlap.


Solution

  • Swift 4.2 iOS 12.x

    You can use GCD to delay one of the processes.

    DispatchQueue.main.asyncAfter(deadline: .now() + 10.0, execute: {
        self.functionToCall()
    })
    

    This will play your second sound 10 seconds later.