---
title: "setDisconnectedFromSystemAudio(_:completionHandler:)"
framework: avfoundation
role: symbol
role_heading: Instance Method
path: "avfoundation/avplayer/setdisconnectedfromsystemaudio(_:completionhandler:)"
---

# setDisconnectedFromSystemAudio(_:completionHandler:)

Changes whether the player is disconnected from system audio. This method allows you to dynamically change the player’s system audio connection. The operation is asynchronous. Each call to this method will invoke its own completion handler when the operation completes. When changing from false to true, you should typically call this method first, then deactivate the AVAudioSession to allow other audio to resume.

## Declaration

```swift
nonisolated func setDisconnectedFromSystemAudio(_ disconnected: Bool, completionHandler: (@Sendable () -> Void)? = nil)
```

## Parameters

- `disconnected`: true to disconnect from system audio, false to connect to it.
- `completionHandler`: A block that is called when the connection state change is complete. This block is called on an arbitrary queue. Defaults to nil.

## Using the completion handler

Using the completion handler In a scenario where changing the value from false to true should also allow other system audio to resume, you should only deactivate the audio session once the player has disconnected from system audio. // Disconnect from system audio and let other audio resume player.setDisconnectedFromSystemAudio(true) { 	try AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation) }
