Skip to navigation

VIAudioManager

VoximplantCore · iOS SDK v3

View as Markdown

Interface that provides API to manage audio devices on iOS.

@objc final class VIAudioManager

Limitations:

Properties

currentDevice

@objc var currentDevice: VIAudioDevice? { get }

Active audio device during a call or conference. If none is in progress, the device selected for the next one.

Connecting a new device can change the active device. When a new device connects, the SDK triggers audioManager(_:didAddDevice:).

delegate

@objc weak var delegate: VIAudioManagerDelegate?

Delegate that receives audio device list and audio session error events.

deviceList

@objc lazy var deviceList: [VIAudioDevice] { get set }

Available audio devices.

Consider the following known issues and limitations for Bluetooth devices. They apply to calls and conferences:

  • Before a call or conference: if AirPods are connected but not worn, AirPods appear in the list when the call or conference starts and they are worn.
  • Before a call or conference: some Bluetooth devices are not detected until the call or conference starts.
  • During a call or conference: if a Bluetooth device is placed in its case after another device is selected by setActiveDevice(_:completion:), the list is not updated until the next device selection.
  • During a call or conference: if the active device is switched from Bluetooth to another device by setActiveDevice(_:completion:), the Bluetooth device remains in the list after Bluetooth is turned off on the phone until the next device selection.

USB audio devices are VIAudioDevice.VIDeviceType.unsupported. They are not added to the list. audioManager(_:didReceiveError:) is triggered when the current audio route includes a USB output.

shared

@objc static let shared: VIAudioManager

Shared audio manager instance.

Methods

callKitProviderDidActivateAudioSession()

@objc func callKitProviderDidActivateAudioSession()

Notifies the SDK that the CallKit framework has activated the audio session.

This is the counterpart to callKitProviderDidDeactivateAudioSession(). Both methods should be called for proper CallKit integration.

  • Call this method inside provider(_:didActivate:).
  • Use this method alongside VICallSettings.callKitSupport set to true.

callKitProviderDidDeactivateAudioSession()

@objc func callKitProviderDidDeactivateAudioSession()

Notifies the SDK that the CallKit framework has deactivated the audio session.

This is the counterpart to callKitProviderDidActivateAudioSession(). Both methods should be called for proper CallKit integration.

setActiveDevice(_:completion:)

@objc func setActiveDevice(
    _ device: VIAudioDevice,
    completion: @escaping (VIAudioDeviceError?) -> Void
)

Sets the specified audio device as active.

Parameters

device VIAudioDevice

Preferred audio device to use

completion @escaping (VIAudioDeviceError?) -> Void

Completion handler invoked when the operation finishes. This handler is executed on the SDK delegate queue. Passes a VIAudioDeviceError if the operation has failed; nil if it has succeeded.

There are two cases:

  • Before a call or conference. The method does not activate an audio device, it just selects (i.e. points to) the audio device to be activated.
  • During a call or conference. If the selected audio device is available, the method activates this audio device.

The active device may change when a new device is connected. audioManager(_:didAddDevice:) is triggered for the connected device.

If the application uses CallKit, you should take into consideration:

  • If a Bluetooth headset is connected, audio routing depends on where a call is answered (from a Bluetooth headset or the phone screen). A Bluetooth headset is activated only if a call is answered via the Bluetooth headset controls. Otherwise audio is played via VIAudioDevice.VIDeviceType.receiver.
  • Audio is always routed to a Bluetooth headset only if a user selects “Bluetooth headset” as Call Audio Routing in the phone preferences.

Relationships

Inherits From: NSObject

Conforms To: ObjectiveC.NSObjectProtocol, Swift.CVarArg, Swift.CustomDebugStringConvertible, Swift.CustomStringConvertible, Swift.Equatable, Swift.Hashable