SoundPlayerUI.fromLoader constructor
SoundPlayerUI.fromLoader allows you to dynamically provide
a Track when the user clicks the play
button.
You can cancel the play action by returning
null when _onLoad is called.
onLoad
is the function that is called when the user clicks the
play button. You return either a Track to be played or null
if you want to cancel the play action.
If showTitle
is true (default is false) then the play bar will also
display the track name and album (if set).
If enabled
is true (the default) then the Player will be enabled.
If enabled
is false then the player will be disabled and the user
will not be able to click the play button.
The audioFocus
allows you to control what happens to other
media that is playing when our player starts.
By default we use AudioFocus.requestFocusAndDuckOthers
which will
reduce the volume of any other players.
Implementation
SoundPlayerUI.fromLoader(
OnLoad onLoad, {
bool showTitle = false,
bool enabled = true,
AudioFocus audioFocus = AudioFocus.requestFocusAndKeepOthers,
Color? backgroundColor,
Color iconColor = Colors.black,
Color disabledIconColor = Colors.grey,
TextStyle? textStyle,
TextStyle? titleStyle,
SliderThemeData? sliderThemeData,
}) : _onLoad = onLoad,
_showTitle = showTitle,
_track = null,
_enabled = enabled,
_backgroundColor =
(backgroundColor == null) ? Color(0xFFFAF0E6) : backgroundColor,
_iconColor = iconColor,
_disabledIconColor = disabledIconColor,
_textStyle = textStyle,
_titleStyle = titleStyle,
_sliderThemeData = sliderThemeData;