Type Property


Posted when the primary audio from other applications starts and stops.


class let silenceSecondaryAudioHintNotification: NSNotification.Name


Subscribe to this notification to ensure that your app is notified when optional secondary audio muting should begin or end. This notification is sent only to registered listeners that are currently in the foreground and have an active audio session.

This notification's userInfo dictionary contains a AVAudioSession.SilenceSecondaryAudioHintType value for the AVAudioSessionSilenceSecondaryAudioHintTypeKey. Use the audio hint type to determine if your secondary audio muting should begin or end.

Listing 1

Responding to Secondary Audio Hint Notifications

func handleSecondaryAudio(notification: Notification) {
    // Determine hint type
    guard let userInfo = notification.userInfo,
        let typeValue = userInfo[AVAudioSessionSilenceSecondaryAudioHintTypeKey] as? UInt,
        let type = AVAudioSessionSilenceSecondaryAudioHintType(rawValue: typeValue) else {
    if type == .begin {
        // Other app audio started playing - mute secondary audio
    } else {
        // Other app audio stopped playing - restart secondary audio

This notification is posted on the main thread.


User Info Keys

let AVAudioSessionSilenceSecondaryAudioHintTypeKey: String

User info key to retrieve the silence secondary audio hint type.

User Info Values

enum AVAudioSession.SilenceSecondaryAudioHintType

These constants are returned by AVAudioSession.SilenceSecondaryAudioHintType to indicate whether optional secondary audio muting should begin or end

See Also

Responding to Audio Session Notifications

Responding to Audio Session Interruptions

Directly observe audio session notifications to ensure that your app responds to interruptions.

Responding to Audio Session Route Changes

Directly observe audio session notifications to ensure that your app responds to interruptions.

class let interruptionNotification: NSNotification.Name

Posted when an audio interruption occurs.

class let routeChangeNotification: NSNotification.Name

Posted when the system’s audio route changes.

class let mediaServicesWereLostNotification: NSNotification.Name

Posted when the media server is terminated.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software