📗
sounds
  • Introduction
  • Installing
  • Roadmap
  • API
    • Overview
    • AudioSource
    • Albums
    • Downloader
    • iOSCategory
    • MediaFormat
    • Monitoring
    • Quickplay
    • RecorderPlaybackController
    • SoundPlayer
    • SoundPlayerUI
    • SoundRecorder
    • SoundRecorderUI
    • Track
  • Platforms
    • Overview
    • Android
    • iOS
  • Contributing
    • Overview
    • Building
    • Debugging
    • Logging
  • ETC
    • Migrating from Flutter Sound
Powered by GitBook
On this page
  • TODO this section needs reviewing as I don't think it is correct it also breaks our stated purpose of being OS agnostic.
  • The android documentation states that requestFocus should be called on the play() callback which we do by default.

Was this helpful?

  1. API

iOSCategory

PreviousDownloaderNextMediaFormat

Last updated 4 years ago

Was this helpful?

TODO this section needs reviewing as I don't think it is correct it also breaks our stated purpose of being OS agnostic.

The android documentation states that requestFocus should be called on the play() callback which we do by default.

Before controlling the focus with requestFocs() you must call iosSetCategory() on iOS or androidAudioFocusRequest() on Android. requesFocus() and androidAudioFocusRequest() are useful if you want to hush others (in android terminology duck others). Those functions are probably called just once when the app starts. After calling this function, the caller is calling requestFocus()/abandonFocus() as required.

You can refer to to understand the parameters needed for iosSetCategory() and to the to understand the parameter needed for androidAudioFocusRequest().

Remark : those three functions do NOT work on Android before SDK 26.

Note: these platform specific methods are under review with the intent to remove any/all platform specific elements to the api.

if (_hushOthers)
{
	if (Platform.isIOS)
		await player.iosSetCategory( t_IOS_SESSION_CATEGORY.PLAY_AND_RECORD, t_IOS_SESSION_MODE.DEFAULT, IOS_DUCK_OTHERS |  IOS_DEFAULT_TO_SPEAKER );
	else if (Platform.isAndroid)
		await player.androidAudioFocusRequest( ANDROID_AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK );
} else
{
	if (Platform.isIOS)
		await player.iosSetCategory( t_IOS_SESSION_CATEGORY.PLAY_AND_RECORD, t_IOS_SESSION_MODE.DEFAULT, IOS_DEFAULT_TO_SPEAKER );
	else if (Platform.isAndroid)
		await player.androidAudioFocusRequest( ANDROID_AUDIOFOCUS_GAIN );
}
...
iOS documentation
Android documentation