Skip to main content
Logo Appt Light

Audio control on iOS

Users should be able to control audio whenever it plays automatically. This includes being able to reduce the volume to zero. It's difficult to hear speech output of the screen reader users when other audio is playing at the same time.

In iOS apps you should always provide a pause or stop button for media. When using AVPlayer, you should use play and pause methods.

You should also make sure that audio is played through the correct channel. Use AVAudioSession in combination with AVAudioSessionCategory to achieve this.

The following channels are available:

// Set audio channel
try AVAudioSession.sharedInstance().setCategory(
    .playback, 
    mode: .default, 
    options: []
)

// Provide media controls
@objc private func click(_ sender: UIButton) {
    if player.timeControlStatus == .playing {
        player.pause()
    } else {
        player.play()
    }
}

Feedback?

Let us know!