FlutterSoundPlayer class
A Player is an object that can playback from various sources.
Using a player is very simple :
-
Create a new
FlutterSoundPlayer
-
Open it with openAudioSession()
-
Start your playback with startPlayer().
-
Use the various verbs (optional):
-
Stop your player : stopPlayer()
-
Release your player when you have finished with it : closeAudioSession(). This verb will call stopPlayer() if necessary.
Constructors
- FlutterSoundPlayer({Level logLevel = Level.debug})
-
Instanciate a new Flutter Sound player.
The optional paramater
Level logLevel
specify the Logger Level you are interested by.
Properties
-
foodSink
→ StreamSink<
Food> ? -
The sink side of the Food Controller
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isPaused → bool
-
Test the Player State
no setter
- isPlaying → bool
-
Test the Player State
no setter
- isStopped → bool
-
Test the Player State
no setter
- logger → Logger
-
The FlutterSoundPlayerLogger Logger getter
no setter
-
onProgress
→ Stream<
PlaybackDisposition> ? -
The stream side of the Food Controller
no setter
- playerState → PlayerState
-
The current state of the Player
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
closeAudioSession(
) → Future< void> - Close an open session.
-
dispositionStream(
) → Stream< PlaybackDisposition> ? - Provides a stream of dispositions which provide updated position and duration as the audio is played.
-
feedFromStream(
Uint8List buffer) → Future< void> - Used when you want to play live PCM data synchronously.
-
getPlayerState(
) → Future< PlayerState> - Query the current state to the Tau Core layer.
-
getProgress(
) → Future< Map< String, Duration> > - Get the current progress of a playback.
-
getResourcePath(
) → Future< String?> - Get the resource path.
-
isDecoderSupported(
Codec codec) → Future< bool> - Returns true if the specified decoder is supported by flutter_sound on this platform
-
isOpen(
) → bool - Return true if the Player has been open
-
log(
Level logLevel, String msg) → void -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
nowPlaying(
Track track, {Duration? duration, Duration? progress, TonSkip? onSkipForward, TonSkip? onSkipBackward, TonPaused? onPaused, bool? defaultPauseResume}) → Future< void> - Set the Lock screen fields without starting a new playback.
-
openAudioSession(
{AudioFocus focus = AudioFocus.requestFocusAndKeepOthers, SessionCategory category = SessionCategory.playAndRecord, SessionMode mode = SessionMode.modeDefault, AudioDevice device = AudioDevice.speaker, int audioFlags = outputToSpeaker | allowBlueToothA2DP | allowAirPlay, bool withUI = false}) → Future< FlutterSoundPlayer?> - Open the Player.
-
pausePlayer(
) → Future< void> - Pause the current playback.
-
resumePlayer(
) → Future< void> - Resume the current playback.
-
seekToPlayer(
Duration duration) → Future< void> - To seek to a new location.
-
setAudioFocus(
{AudioFocus focus = AudioFocus.requestFocusAndKeepOthers, SessionCategory category = SessionCategory.playback, SessionMode mode = SessionMode.modeDefault, AudioDevice device = AudioDevice.speaker, int audioFlags = outputToSpeaker | allowBlueTooth | allowBlueToothA2DP | allowEarPiece}) → Future< void> - Set or unset the Audio Focus.
-
setLogLevel(
Level aLevel) → Future< void> - Used if the App wants to dynamically change the Log Level. Seldom used. Most of the time the Log Level is specified during the constructor.
-
setSpeed(
double speed) → Future< void> - Change the playback speed
-
setSubscriptionDuration(
Duration duration) → Future< void> - Specify the callbacks frenquency, before calling startPlayer.
-
setUIProgressBar(
{Duration? duration, Duration? progress}) → Future< void> - Used if the App wants to control itself the Progress Bar on the lock screen.
-
setVolume(
double volume) → Future< void> - Change the output volume
-
startPlayer(
{String? fromURI, Uint8List? fromDataBuffer, Codec codec = Codec.aacADTS, int sampleRate = 16000, int numChannels = 1, TWhenFinished? whenFinished}) → Future< Duration?> - Used to play a sound.
-
startPlayerFromMic(
{int sampleRate = 44000, int numChannels = 1}) → Future< void> - Starts the Microphone and plays what is recorded.
-
startPlayerFromStream(
{Codec codec = Codec.pcm16, int numChannels = 1, int sampleRate = 16000}) → Future< void> - Used to play something from a Dart stream
-
startPlayerFromTrack(
Track track, {TonSkip? onSkipForward, TonSkip? onSkipBackward, TonPaused? onPaused, TWhenFinished? whenFinished, Duration? progress, Duration? duration, bool? defaultPauseResume, bool removeUIWhenStopped = true}) → Future< Duration?> - Play data from a track specification and display controls on the lock screen or an Apple Watch.
-
stopPlayer(
) → Future< void> - Stop a playback.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited