PlaybackState class

Represents the current playback state of an audio player.

Constructors

PlaybackState.new({AudioPlaybackState state = AudioPlaybackState.idle, AudioTrack? currentTrack, Duration position = Duration.zero, Duration duration = Duration.zero, Duration bufferedPosition = Duration.zero, double volume = 1.0, double speed = 1.0, ShuffleMode shuffleMode = ShuffleMode.none, RepeatMode repeatMode = RepeatMode.none, bool isBuffering = false, AudioLoadingState loadingState = AudioLoadingState.notLoaded, AudioCacheState cacheState = AudioCacheState.notCached, int currentIndex = 0, String? errorMessage, Map<String, dynamic>? extra})
Creates a playback state with the specified properties.
const
PlaybackState.empty()
Creates an empty playback state.
factory
PlaybackState.fromMap(Map<String, dynamic> map)
Creates a playback state from a map.
factory

Properties

bufferedPosition Duration
Current buffered position.
final
bufferedProgress double
Returns the buffered progress as a percentage (0.0 to 1.0).
no setter
cacheState AudioCacheState
Current cache state.
final
canPause bool
Returns whether the player can pause.
no setter
canPlay bool
Returns whether the player can play.
no setter
currentIndex int
Current track index in playlist.
final
currentTrack AudioTrack?
Currently playing track.
final
duration Duration
Total duration of the current track.
final
errorMessage String?
Error message if in error state.
final
extra Map<String, dynamic>?
Additional custom data.
final
formattedDuration String
Returns a formatted duration string.
no setter
formattedPosition String
Returns a formatted position string.
no setter
formattedRemainingTime String
Returns a formatted remaining time string.
no setter
hasError bool
Returns whether the player is in an error state.
no setter
hashCode int
The hash code for this object.
no setterinherited
isBuffering bool
Whether the player is currently buffering.
final
isCompleted bool
Returns whether playback has completed.
no setter
isLoading bool
Returns whether the player is loading.
no setter
isPaused bool
Returns whether playback is paused.
no setter
isPlaying bool
Returns whether playback is currently active.
no setter
isRepeatAllEnabled bool
Returns whether repeat all is enabled.
no setter
isRepeatEnabled bool
Returns whether repeat is enabled.
no setter
isRepeatOneEnabled bool
Returns whether repeat one is enabled.
no setter
isShuffleEnabled bool
Returns whether shuffle is enabled.
no setter
loadingState AudioLoadingState
Current loading state.
final
position Duration
Current playback position.
final
progress double
Returns the playback progress as a percentage (0.0 to 1.0).
no setter
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setter
remainingTime Duration
Returns the remaining time in the current track.
no setter
repeatMode RepeatMode
Current repeat mode.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shuffleMode ShuffleMode
Current shuffle mode.
final
speed double
Current playback speed.
final
state AudioPlaybackState
Current playback state.
final
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited
volume double
Current volume level (0.0 to 1.0).
final

Methods

copyWith({AudioPlaybackState? state, AudioTrack? currentTrack, Duration? position, Duration? duration, Duration? bufferedPosition, double? volume, double? speed, ShuffleMode? shuffleMode, RepeatMode? repeatMode, bool? isBuffering, AudioLoadingState? loadingState, AudioCacheState? cacheState, int? currentIndex, String? errorMessage, Map<String, dynamic>? extra}) PlaybackState
Creates a copy of this state with the specified properties changed.
fromJson(String json) PlaybackState
Converts the object from a JSON string representation.
inherited
fromMap(Map<String, dynamic> map) PlaybackState
Converts the object from a Map representation.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() String
Converts the object to a JSON string representation.
inherited
toMap() Map<String, dynamic>
Converts the BaseDataModel object to a Map representation.
toString() String
A string representation of this object.
inherited

Operators

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