SIGN UP

VIAudioManager

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

Methods

availableAudioDevices

- (NSSet<VIAudioDevice *> *)availableAudioDevices

Returns the list of available audio devices.

Returns

  • Return:

    NSSet<VIAudioDevice *> *

    List of currently available audio devices.

callKitConfigureAudioSession:

- (void)callKitConfigureAudioSession:(NSError **)error

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

Initializes AVAudioSession for use with CallKit integration.

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

Parameters

  • error:

    NSError **

    Error during configuration steps.

callKitReleaseAudioSession

- (void)callKitReleaseAudioSession

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

Restores default AVAudioSession initialization routines, MUST be called if CallKit becomes disabled.

callKitStartAudio

- (void)callKitStartAudio

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

Starts AVAudioSession.

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

callKitStopAudio

- (void)callKitStopAudio

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

Stops AVAudioSession.

Should be called in [CXProviderDelegate provider:performEndCallAction:] and [CXProviderDelegate provider:performSetHeldCallAction:].

currentAudioDevice

- (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:

- (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:

  • In case 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 in case 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 in case if user selects "Bluetooth headset" as Call Audio Routing in the phone preferences.

  • In case 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.

Parameters

sharedAudioManager

+ (instancetype)sharedAudioManager

Obtain audio manager instance.

Returns

  • Return:

    instancetype

    Audio manager instance.

Properties

delegate

@property (nonatomic, weak) id<VIAudioManagerDelegate> delegate

Delegate to monitor audio session route changes.

useLoudSpeaker

Deprecated
@property (nonatomic, assign) BOOL useLoudSpeaker

Enable or disable loudspeaker.