-
- All Implemented Interfaces:
-
io.livekit.android.audio.AudioHandler
@Singleton() public class AudioFocusHandler implements AudioHandler
A basic AudioHandler that manages audio focus while started.
-
-
Field Summary
Fields Modifier and Type Field Description private IntegerfocusModeprivate IntegeraudioStreamTypeprivate IntegeraudioAttributeUsageTypeprivate IntegeraudioAttributeContentTypeprivate AudioManager.OnAudioFocusChangeListeneronAudioFocusChangeListener
-
Constructor Summary
Constructors Constructor Description AudioFocusHandler(Context context)
-
Method Summary
Modifier and Type Method Description final IntegergetFocusMode()The audio focus mode to use while started. final UnitsetFocusMode(Integer focusMode)The audio focus mode to use while started. final IntegergetAudioStreamType()The audio stream type to use when requesting audio focus on pre-O devices. final UnitsetAudioStreamType(Integer audioStreamType)The audio stream type to use when requesting audio focus on pre-O devices. final IntegergetAudioAttributeUsageType()The audio attribute usage type to use when requesting audio focus on devices O and beyond. final UnitsetAudioAttributeUsageType(Integer audioAttributeUsageType)The audio attribute usage type to use when requesting audio focus on devices O and beyond. final IntegergetAudioAttributeContentType()The audio attribute content type to use when requesting audio focus on devices O and beyond. final UnitsetAudioAttributeContentType(Integer audioAttributeContentType)The audio attribute content type to use when requesting audio focus on devices O and beyond. final AudioManager.OnAudioFocusChangeListenergetOnAudioFocusChangeListener()Set this to listen to audio focus changes. final UnitsetOnAudioFocusChangeListener(AudioManager.OnAudioFocusChangeListener onAudioFocusChangeListener)Set this to listen to audio focus changes. Unitstart()Called when a room is started. Unitstop()Called when a room is disconnected. AudioFocusRequestcreateAudioRequest()Creates the request used when requesting audio focus. -
-
Constructor Detail
-
AudioFocusHandler
AudioFocusHandler(Context context)
-
-
Method Detail
-
getFocusMode
final Integer getFocusMode()
The audio focus mode to use while started.
Defaults to AudioManager.AUDIOFOCUS_GAIN.
-
setFocusMode
final Unit setFocusMode(Integer focusMode)
The audio focus mode to use while started.
Defaults to AudioManager.AUDIOFOCUS_GAIN.
-
getAudioStreamType
final Integer getAudioStreamType()
The audio stream type to use when requesting audio focus on pre-O devices.
Defaults to AudioManager.STREAM_MUSIC.
Refer to this compatibility table to ensure that your values match between android versions.
-
setAudioStreamType
final Unit setAudioStreamType(Integer audioStreamType)
The audio stream type to use when requesting audio focus on pre-O devices.
Defaults to AudioManager.STREAM_MUSIC.
Refer to this compatibility table to ensure that your values match between android versions.
-
getAudioAttributeUsageType
final Integer getAudioAttributeUsageType()
The audio attribute usage type to use when requesting audio focus on devices O and beyond.
Defaults to AudioAttributes.USAGE_MEDIA.
Refer to this compatibility table to ensure that your values match between android versions.
-
setAudioAttributeUsageType
final Unit setAudioAttributeUsageType(Integer audioAttributeUsageType)
The audio attribute usage type to use when requesting audio focus on devices O and beyond.
Defaults to AudioAttributes.USAGE_MEDIA.
Refer to this compatibility table to ensure that your values match between android versions.
-
getAudioAttributeContentType
final Integer getAudioAttributeContentType()
The audio attribute content type to use when requesting audio focus on devices O and beyond.
Defaults to AudioAttributes.CONTENT_TYPE_SPEECH.
Refer to this compatibility table to ensure that your values match between android versions.
-
setAudioAttributeContentType
final Unit setAudioAttributeContentType(Integer audioAttributeContentType)
The audio attribute content type to use when requesting audio focus on devices O and beyond.
Defaults to AudioAttributes.CONTENT_TYPE_SPEECH.
Refer to this compatibility table to ensure that your values match between android versions.
-
getOnAudioFocusChangeListener
final AudioManager.OnAudioFocusChangeListener getOnAudioFocusChangeListener()
Set this to listen to audio focus changes.
-
setOnAudioFocusChangeListener
final Unit setOnAudioFocusChangeListener(AudioManager.OnAudioFocusChangeListener onAudioFocusChangeListener)
Set this to listen to audio focus changes.
-
createAudioRequest
@RequiresApi(value = 26) AudioFocusRequest createAudioRequest()
Creates the request used when requesting audio focus.
The default implementation creates an audio focus request based on the settings of this object.
Only used on Android O and upwards. On lower platforms, the request will be made using the audioStreamType and focusMode settings.
-
-
-
-