AssetsAudioPlayerPlus class
The AssetsAudioPlayer, playing audios from assets/ Example :
AssetsAudioPlayer _assetsAudioPlayer = AssetsAudioPlayer();
_assetsAudioPlayer.open(Audio(
'/assets/audio/myAudio.mp3',
))
Don't forget to declare the audio folder in your pubspec.yaml
flutter:
assets:
- assets/audios/
- Available extensions
Constructors
- AssetsAudioPlayerPlus.new()
-
empty constructor now create a new player
factory
- AssetsAudioPlayerPlus.withId(String? id)
-
factory
- AssetsAudioPlayerPlus.newPlayer()
-
factory
Properties
-
audioSessionId
→ ValueStream<
int> -
no setter
-
cacheDownloadInfos
→ Stream<
CacheDownloadInfos> -
no setter
- cachePathProvider ← AssetsAudioPlayerCache
-
no getter
-
current
→ ValueStream<
Playing?> -
The current playing audio, filled with the total song duration
Exposes a PlayingAudio
no setter
- currentLoopMode → LoopMode?
-
returns the looping state : true -> looping, false -> not looping
no setter
-
currentPosition
→ ValueStream<
Duration> -
Retrieve directly the current song position (in seconds)
final Duration position = _assetsAudioPlayer.currentPosition.value;
no setter
-
forwardRewindSpeed
→ ValueStream<
double> -
no setter
- getCurrentAudioAlbum → String
-
no setter
- getCurrentAudioArtist → String
-
no setter
-
getCurrentAudioextra
→ Map<
String, dynamic> -
no setter
- getCurrentAudioImage → MetasImage?
-
no setter
- getCurrentAudioTitle → String
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
final
-
isBuffering
→ ValueStream<
bool> -
no setter
-
isPlaying
→ ValueStream<
bool> -
Boolean observable representing the current mediaplayer playing state
no setter
-
isShuffling
→ ValueStream<
bool> -
no setter
-
loopMode
→ ValueStream<
LoopMode> -
Called when the looping state changes
_assetsAudioPlayer.isLooping.listen((looping){
no setter
- networkSettings → NetworkSettings
-
final
- onErrorDo ↔ AssetsAudioPlayerErrorHandler?
-
getter/setter pair
-
onReadyToPlay
→ Stream<
PlayingAudio?> -
no setter
-
pitch
→ ValueStream<
double> -
no setter
-
playerState
→ ValueStream<
PlayerState> -
no setter
- playlist → Playlist?
-
no setter
-
playlistAudioFinished
→ Stream<
Playing> -
Called when the current playlist song has finished
Using a playlist, the
finished
stram will be called only if the complete playlist finishedno setter -
playlistFinished
→ ValueStream<
bool> -
Called when the complete playlist has finished to play
_assetsAudioPlayer.finished.listen((finished){
no setter
-
playSpeed
→ ValueStream<
double> -
no setter
- readingPlaylist → ReadingPlaylist?
-
no setter
-
realtimePlayingInfos
→ ValueStream<
RealtimePlayingInfos> -
no setter
- respectSilentMode → bool
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showNotification ↔ bool
-
getter/setter pair
- shuffle ↔ bool
-
assign the shuffling state : true -> shuffling, false -> not shuffling
getter/setter pair
- stopped → bool
-
no setter
-
volume
→ ValueStream<
double> -
Streams the volume of the media Player (min: 0, max: 1)
final double volume = _assetsAudioPlayer.volume.value;
no setter
Methods
-
builderCurrent(
{Key? key, required CurrentWidgetBuilder? builder}) → PlayerBuilder -
Available on AssetsAudioPlayerPlus, provided by the AssetAudioPlayerBuilder extension
-
builderCurrentPosition(
{Key? key, required PositionWidgetBuilder builder}) → PlayerBuilder -
Available on AssetsAudioPlayerPlus, provided by the AssetAudioPlayerBuilder extension
-
builderForwardRewindSpeed(
{Key? key, required ForwardRewindSpeedWidgetBuilder builder}) → PlayerBuilder -
Available on AssetsAudioPlayerPlus, provided by the AssetAudioPlayerBuilder extension
-
builderIsBuffering(
{Key? key, required IsBufferingWidgetBuilder builder}) → PlayerBuilder -
Available on AssetsAudioPlayerPlus, provided by the AssetAudioPlayerBuilder extension
-
builderIsPlaying(
{Key? key, required PlayingWidgetBuilder builder}) → PlayerBuilder -
Available on AssetsAudioPlayerPlus, provided by the AssetAudioPlayerBuilder extension
-
builderLoopMode(
{Key? key, required LoopModeWidgetBuilder builder}) → PlayerBuilder -
Available on AssetsAudioPlayerPlus, provided by the AssetAudioPlayerBuilder extension
-
builderPlayerState(
{Key? key, required PlayerStateBuilder builder}) → PlayerBuilder -
Available on AssetsAudioPlayerPlus, provided by the AssetAudioPlayerBuilder extension
-
builderPlaySpeed(
{Key? key, required PlaySpeedWidgetBuilder builder}) → PlayerBuilder -
Available on AssetsAudioPlayerPlus, provided by the AssetAudioPlayerBuilder extension
-
builderRealtimePlayingInfos(
{Key? key, required RealtimeWidgetBuilder builder}) → PlayerBuilder -
Available on AssetsAudioPlayerPlus, provided by the AssetAudioPlayerBuilder extension
-
builderVolume(
{Key? key, required VolumeWidgetBuilder builder}) → PlayerBuilder -
Available on AssetsAudioPlayerPlus, provided by the AssetAudioPlayerBuilder extension
-
dispose(
) → Future< void> - Call it to dispose stream
-
forwardOrRewind(
double speed) → Future< void> - If positive, forward (progressively) If Negative rewind (progressively) If 0 or null, restore the playing state
-
next(
{bool stopIfLast = false, bool keepLoopMode = true}) → Future< bool> - keepLoopMode: if true : the loopMode is .single => execute next() will keep it .single if false : the loopMode is .single => execute next() will set it as .playlist
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
open(
Playable playable, {bool autoStart = _DEFAULT_AUTO_START, double? volume, bool respectSilentMode = _DEFAULT_RESPECT_SILENT_MODE, bool showNotification = _DEFAULT_SHOW_NOTIFICATION, Duration? seek, double? playSpeed, double? pitch, NotificationSettings? notificationSettings, LoopMode loopMode = _DEFAULT_LOOP_MODE, PlayInBackground playInBackground = _DEFAULT_PLAY_IN_BACKGROUND, HeadPhoneStrategy headPhoneStrategy = _DEFAULT_HEADPHONE_STRATEGY, AudioFocusStrategy? audioFocusStrategy, bool forceOpen = false}) → Future< void> - Open a song from the asset
-
pause(
) → Future< void> - Tells the media player to pause the current song _assetsAudioPlayer.pause();
-
play(
) → Future< void> - Tells the media player to play the current song _assetsAudioPlayer.play();
-
playlistPlayAtIndex(
int index) → Future< void> -
playOrPause(
) → Future< void> - Toggle the current playing state If the media player is playing, then pauses it If the media player has been paused, then play it
-
previous(
{bool keepLoopMode = true}) → Future< bool> - keepLoopMode: if true : the loopMode is .single => execute previous() will keep it .single if false : the loopMode is .single => execute previous() will set it as .playlist
-
seek(
Duration to, {bool force = false}) → Future< void> - Change the current position of the song Tells the player to go to a specific position of the current song
-
seekBy(
Duration by) → Future< void> -
if by > 0 Forward (jump) the current audio, to currentPosition +
by
(duration) -
setLoopMode(
LoopMode value) → Future< void> -
setPitch(
double pitch) → Future< void> - Change the current pitch of the MediaPlayer
-
setPlaySpeed(
double playSpeed) → Future< void> - Change the current play speed (rate) of the MediaPlayer
-
setVolume(
double volume) → Future< void> - Change the current volume of the MediaPlayer
-
stop(
) → Future< void> - Tells the media player to stop the current song, then release the MediaPlayer _assetsAudioPlayer.stop();
-
toggleLoop(
) → Future< void> - toggle the looping state if it was looping -> stops this if it was'nt looping -> now it is
-
toggleShuffle(
) → void - toggle the shuffling state if it was shuffling -> stops this if it was'nt shuffling -> now it is
-
toString(
) → String -
A string representation of this object.
inherited
-
updateCurrentAudioNotification(
{Metas? metas, bool showNotifications = true}) → Future< void>
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- defaultFocusStrategy → AudioFocusStrategy
-
final
- defaultNotificationSettings → NotificationSettings
-
final
- defaultPitch → double
-
final
- defaultPlaySpeed → double
-
final
- defaultVolume → double
-
final
- maxPitch → double
-
final
- maxPlaySpeed → double
-
final
- maxVolume → double
-
final
- minPitch → double
-
final
- minPlaySpeed → double
-
final
- minVolume → double
-
final
- uuid → Uuid
-
final
Static Methods
-
addNotificationOpenAction(
NotificationOpenAction action) → StreamSubscription -
allPlayers(
) → Map< String, AssetsAudioPlayerPlus> -
playAndForget(
Audio audio, {double? volume, bool respectSilentMode = _DEFAULT_RESPECT_SILENT_MODE, Duration? seek, double? playSpeed}) → void - Create a new player for this audio, play it, and dispose it automatically
-
setupNotificationsOpenAction(
NotificationOpenAction action) → void