SIGN UP

VIAudioManager

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

Methods

- (NSSet<VIAudioDevice *> *)availableAudioDevices

Returns the list of available audio devices.

Returns

  • Return:

    NSSet<VIAudioDevice *> *

    List of currently available audio devices.

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

Initializes AudioSession for use with CallKit integration.

Only needed for correct CallKit integration.

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

Parameters

  • error:

    NSError **

    Occurred error on configuration steps.

- (void)callKitReleaseAudioSession

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

- (void)callKitStartAudio

Starts AudioSession.

Only needed for correct CallKit integration.

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

- (void)callKitStopAudio

Stops AudioSession.

Only needed for correct CallKit integration.

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

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

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

+ (instancetype)sharedAudioManager

Obtain audio manager instance.

Returns

  • Return:

    instancetype

    Audio manager instance.

Properties

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

Delegate to monitor audio session route changes.

useLoudSpeaker

Deprecated
@property (nonatomic, assign) BOOL useLoudSpeaker

Enable or disable loudspeaker.