TauPlayer class

A Player is an object that can playback from Files, Buffers and Assets. Players do not manage RAW PCM data. Players play to a speaker or a headset. A Player is a High level OS object. It corresponds to an AVAudioPlayer on iOS and a MediaPlayer on Android. The App can create several Players. Each player must be independently opened and closed. Each Player manages its own playback, with its own sound volume, its own seekToPlayer and its own set of callbacks. When you have finished with a Player, you must close it. Opening a player takes resources inside the OS. Those resources are freed with the verb close().


Using a player is very simple :

  1. Create a new TauPlayer()

  2. Open it with open()

  3. Start your playback with play().

  4. Use the various verbs (optional):

  5. Stop your player : stop()

  6. Release your player when you have finished with it : close(). This verb will call stop() if necessary.


Constructors

TauPlayer({Level logLevel = Level.debug})
Instanciate a new TauPlayer. The optional parameter logLevel specify the Logger Level you are interested by.

Properties

hashCode int
The hash code for this object.
no setterinherited
isOpen bool
True if the Player has been open
no setter
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 TauPlayerLogger 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
withShadeUI bool
getter/setter pair

Methods

close({bool? keepFocus}) Future<void>
Close an open session.
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(TauCodec codec) Future<bool>
Returns true if the specified decoder is supported by flutter_sound on this platform
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.
open({required InputNode from, required OutputDeviceNode to, AudioFocus? focus, SessionCategory category = SessionCategory.playAndRecord, SessionMode mode = SessionMode.modeDefault, int audioFlags = outputToSpeaker | allowBlueToothA2DP | allowAirPlay, bool withShadeUI = false}) Future<TauPlayer?>
Open the Player.
pause() Future<void>
Pause the current playback.
play({TWhenFinished? whenFinished, TonSkip? onSkipForward, TonSkip? onSkipBackward, TonPaused? onPaused, bool defaultPauseResume = true, bool removeUIWhenStopped = true}) Future<Duration?>
Used to play a sound.
resume() Future<void>
Resume the current playback.
seekTo(Duration duration) Future<void>
To seek to a new location.
setAudioFocus({AudioFocus focus = AudioFocus.requestFocusAndKeepOthers, SessionCategory category = SessionCategory.playback, SessionMode mode = SessionMode.modeDefault, int audioFlags = outputToSpeaker | allowBlueTooth | allowBlueToothA2DP | allowEarPiece}) Future<void>
setAudioFocus is used to modify the state of the Focus. Very often, the App will not use this verb and will specify the focus value during the open() and close() verbs. If the App does not have the focus when it does a start() it automaticaly gets the focus AudioFocus.requestFocusAndStopOthers, and releases the focus automaticaly when the Player is stopped.
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
stop() Future<void>
Stop a playback.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited