AudioFocusClientTurboModule
Extends
KeplerTurboModule
Properties
createAudioFocusSessionAsync()
createAudioFocusSessionAsync: () =>
Promise
<number
>
Creates a new AudioFocusSession that can be used to manage audio focus requests.
Returns
Promise
<number
>
A promise that resolves to:
- A positive integer representing the new session ID if successful
AUDIO_FOCUS_STATUS_NO_MEMORY (-1)
: Failed to allocate sessionAUDIO_FOCUS_STATUS_BAD_VALUE (-2)
: Internal creation error
destroyAudioFocusSessionAsync()
destroyAudioFocusSessionAsync: (
sessionId
) =>Promise
<number
>
Destroys an existing audio focus session and releases all associated resources. Any active focus requests in this session will be automatically released.
Parameters
sessionId
number
The session ID to destroy, previously obtained from AudioFocusManager.AudioFocusManager.createAudioFocusSessionAsync
Returns
Promise
<number
>
A promise that resolves to:
AUDIO_FOCUS_STATUS_NO_ERROR (0)
: Session successfully destroyedAUDIO_FOCUS_STATUS_BAD_VALUE (-2)
: Invalid session IDAUDIO_FOCUS_STATUS_NO_INIT (-3)
: Session not initialized
getDefaultAudioFocusSessionAsync()
getDefaultAudioFocusSessionAsync: () =>
Promise
<number
>
Retrieves the default audio focus session ID. This session is a singleton instance that is used when an audio stream doesn't explicitly specify a focus session.
Returns
Promise
<number
>
A promise that resolves to:
- A positive integer representing the default session ID if successful
- Negative value indicating an error occurred while retrieving default session
getMajorVersion()
readonly
getMajorVersion: () =>number
Gets the major version number of the AudioFocusClientTurboModule. This can be used for compatibility checking.
Returns
number
The major version number of the module
Overrides
KeplerTurboModule.getMajorVersion
getMinorVersion()
readonly
getMinorVersion: () =>number
Gets the minor version number of the AudioFocusClientTurboModule. This can be used for compatibility checking.
Returns
number
The minor version number of the module
Overrides
KeplerTurboModule.getMinorVersion
getPatchVersion()
readonly
getPatchVersion: () =>number
Gets the patch version number of the AudioFocusClientTurboModule. This can be used for compatibility checking.
Returns
number
The patch version number of the module
Overrides
KeplerTurboModule.getPatchVersion
registerAudioFocusListenerAsync()
registerAudioFocusListenerAsync: (
sessionId
,callback
) =>Promise
<number
>
Registers a callback function to receive audio focus change notifications for a specific session. Only one callback can be registered per session at a time.
Parameters
sessionId
number
The session ID to monitor for focus changes
callback
(value
) => void
Callback function that will receive focus change events:
The callback receives an event object with these possible values:
- focusChange:
GRANTED (0)
- Focus was granted - focusChange:
RELEASED (1)
- Focus was released - focusChange:
DUCKED (2)
- Stream reduces volume - focusChange:
PAUSED (3)
- Stream pauses - focusChange:
STOPPED (4)
- Stream stops
Returns
Promise
<number
>
A promise that resolves to:
AUDIO_FOCUS_STATUS_NO_ERROR (0)
: Callback registered successfullyAUDIO_FOCUS_STATUS_BAD_VALUE (-2)
: Invalid session ID or callbackAUDIO_FOCUS_STATUS_NO_INIT (-3)
: Session not initializedAUDIO_FOCUS_STATUS_INVALID_OPERATION (-8)
: Callback already registered
releaseAudioFocusAsync()
releaseAudioFocusAsync: (
sessionId
) =>Promise
<number
>
Releases previously requested audio focus for the specified session. Function must be called when the audio playback is completed or needs to give up focus.
Parameters
sessionId
number
The session ID for which to release focus
Returns
Promise
<number
>
A promise that resolves to:
AUDIO_FOCUS_STATUS_NO_ERROR (0)
: Focus successfully releasedAUDIO_FOCUS_STATUS_BAD_VALUE (-2)
: Invalid session IDAUDIO_FOCUS_STATUS_NO_INIT (-3)
: Session not initializedAUDIO_FOCUS_STATUS_INVALID_OPERATION (-8)
: No focus was held
requestAudioFocusAsync()
requestAudioFocusAsync: (
sessionId
,usage
) =>Promise
<number
>
Requests audio focus for a specific audio usage within the given session.
Parameters
sessionId
number
The audio focus session ID obtained from AudioFocusManager.AudioFocusManager.createAudioFocusSessionAsync
usage
number
The type of audio usage requesting focus. Valid values are:
USAGE_NONE (0)
: No specific usageUSAGE_MEDIA (1)
: General media playbackUSAGE_COMMUNICATION (2)
: Voice/video callsUSAGE_ALARM (3)
: Alarm soundsUSAGE_NOTIFICATION (4)
: System notificationsUSAGE_ACCESSIBILITY (5)
: Accessibility feedback And others as defined in AudioUsageType enum
Returns
Promise
<number
>
A promise that resolves to one of these status codes:
AUDIO_FOCUS_STATUS_NO_ERROR (0)
: Focus request successfulAUDIO_FOCUS_STATUS_DENIED (1)
: Focus request deniedAUDIO_FOCUS_STATUS_DELAYED (2)
: Focus request delayedAUDIO_FOCUS_STATUS_BAD_VALUE (-2)
: Invalid parametersAUDIO_FOCUS_STATUS_NO_INIT (-3)
: Session not initializedAUDIO_FOCUS_STATUS_INVALID_OPERATION (-8)
: Invalid operation
unregisterAudioFocusListenerAsync()
unregisterAudioFocusListenerAsync: (
sessionId
) =>Promise
<number
>
Unregister the previously registered focus change callback for a session.
Parameters
sessionId
number
The session ID whose callback will be unregistered
Returns
Promise
<number
>
A promise that resolves to:
AUDIO_FOCUS_STATUS_NO_ERROR (0)
: Callback unregistered successfullyAUDIO_FOCUS_STATUS_BAD_VALUE (-2)
: Invalid session IDAUDIO_FOCUS_STATUS_NO_INIT (-3)
: Session not initializedAUDIO_FOCUS_STATUS_INVALID_OPERATION (-8)
: No callback was registered
Methods
getConstants()?
optional
getConstants():object
Returns
object
Inherited from
KeplerTurboModule.getConstants
Last updated: Sep 30, 2025