Rate this page:

VIAudioManager

Interface that may be used to manage audio devices on iOS device.

Limitations:

  • It is not possible to select an VIAudioDeviceTypeReceiver while wired headset is connected.
  • Wired headsets without a microphone may be recognized and selected as VIAudioDeviceTypeReceiver.
  • iOS 12 and AirPods: during an active call, VIAudioDeviceTypeReceiver or VIAudioDeviceTypeSpeaker selection may fail if AirPods are used as current active device.

Methods

availableAudioDevices

Copy URL
- (

NSSet<VIAudioDevice *> *

)availableAudioDevices

Returns the list of available audio devices.

Returns

callKitConfigureAudioSession:

Copy URL
- (

void

)callKitConfigureAudioSession:(

NSError * _Nullable *

)error

Required for the correct CallKit integration only. Otherwise don't use this method.

Initializes AVAudioSession for use with CallKit integration.

Should be called before [CXProviderDelegate provider:performStartCallAction:] and before [CXProviderDelegate provider:performAnswerCallAction:].

Parameters

  • error:

    NSError * _Nullable *

    Error during configuration steps.

Returns

  • type:

    void

callKitReleaseAudioSession

Copy URL
- (

void

)callKitReleaseAudioSession

Required for the correct CallKit integration only. Otherwise don't use this method.

Restores default AVAudioSession initialization routines, MUST be called after the call has ended, i.e. [CXProvider reportCallWithUUID:endedAtDate:reason:] was called.

Returns

  • type:

    void

callKitStartAudio

Copy URL
- (

void

)callKitStartAudio

Required for the correct CallKit integration only. Otherwise don't use this method.

Starts AVAudioSession.

Should be called in [CXProviderDelegate provider:didActivateAudioSession:].

Returns

  • type:

    void

callKitStopAudio

Copy URL
- (

void

)callKitStopAudio

Required for the correct CallKit integration only. Otherwise don't use this method.

Stops AVAudioSession.

Should be called in [CXProviderDelegate provider:didDeactivateAudioSession:].

Returns

  • type:

    void

currentAudioDevice

Copy URL
- (

VIAudioDevice *

)currentAudioDevice

Returns active audio device during the call or audio device that will be used for a call if there is no calls at this moment.

Please note that active audio device can be later changed if new device is connected. In this case [VIAudioManagerDelegate audioDeviceChanged:] will be triggered to notify about new active device.

Returns

selectAudioDevice:

Copy URL
- (

void

)selectAudioDevice:(

VIAudioDevice *

)audioDevice

Changes selection of the current active audio device.

There are two cases:

  1. Before a call. The method doesn't activate an audio device, it just selects (i.e. points to) the audio device that will be activated.

  2. During a call. If the selected audio device is available, the method activates this audio device.

Please note that active audio device can be later changed if new device is connected. In this case [VIAudioManagerDelegate audioDeviceChanged:] will be triggered to notify about new active device.

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

  • If Bluetooth headset is connected, audio routing depends on where a call is answered (from bluetooth headset or from phone screen). Bluetooth headset will be activated only if a call is answered via Bluetooth headset controls. In other case the audio will be played via Receiver.

  • Audio is always routed to Bluetooth headset only if user selects "Bluetooth headset" as Call Audio Routing in the phone preferences.

  • If audio device is selected before CallKit activates the audio session, it is required to reselect this audio device after [CXProviderDelegate provider:didActivateAudioSession:] is called. Otherwise audio routing may be reset to default.

Known issues:

  • It is not possible to select Receiver while a call is on hold and it is reported to CallKit.
  • It is not possible to select Receiver before a call is connected, if a Blutooth audio device is connected.

Parameters

Returns

  • type:

    void

sharedAudioManager

Copy URL
+ (

instancetype

)sharedAudioManager

Obtain audio manager instance.

Returns

  • type:

    instancetype

Props

delegate

Copy URL
@property (weak, nullable, nonatomic) 

id<VIAudioManagerDelegate>

delegate

A delegate to monitor audio session route changes.

Returns