JustAudioPlayer class

JustAudio implementation of the AudioPlayerInterface. Note: This is a basic implementation. For production use, consider using AudioPlayersPlayer instead as it has better platform support.

Implemented types

Properties

audioInterruptionStream → Stream<AudioInterruptionType>
Stream of audio session interruptions.
no setteroverride
bufferedPositionStream → Stream<Duration>
Stream of buffered position updates.
no setteroverride
cacheStateStream → Stream<AudioCacheState>
Stream of cache state changes.
no setteroverride
config → AudioPlayerConfig
Audio player configuration.
final
currentBufferedPosition → Duration
Current buffered position.
no setteroverride
currentCacheState → AudioCacheState
Current cache state.
no setteroverride
currentDuration → Duration
Total duration of the current audio track.
no setteroverride
currentLoadingState → AudioLoadingState
Current loading state.
no setteroverride
currentPlaybackState → PlaybackState
Current playback state.
no setteroverride
currentPlaylist → Playlist?
Current playlist.
no setteroverride
currentPosition → Duration
Current position in the audio track.
no setteroverride
currentRepeatMode → RepeatMode
Current repeat mode.
no setteroverride
currentShuffleMode → ShuffleMode
Current shuffle mode.
no setteroverride
currentSpeed → double
Current playback speed (0.5 to 2.0 typically).
no setteroverride
currentTrack → AudioTrack?
Current audio track being played.
no setteroverride
currentTrackStream → Stream<AudioTrack?>
Stream of current track changes.
no setteroverride
currentVolume → double
Current volume level (0.0 to 1.0).
no setteroverride
durationStream → Stream<Duration>
Stream of duration updates.
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
isInitialized → bool
Whether the player is initialized.
no setteroverride
loadingStateStream → Stream<AudioLoadingState>
Stream of loading state changes.
no setteroverride
playbackStateStream → Stream<PlaybackState>
Stream of playback state changes.
no setteroverride
playerId → String?
Optional player ID for multi-player scenarios.
final
playerType → AudioPlayerType
Audio player type identifier.
no setteroverride
playlistStream → Stream<Playlist?>
Stream of playlist changes.
no setteroverride
positionStream → Stream<Duration>
Stream of current position updates.
no setteroverride
repeatModeStream → Stream<RepeatMode>
Stream of repeat mode changes.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
shuffleModeStream → Stream<ShuffleMode>
Stream of shuffle mode changes.
no setteroverride
speedStream → Stream<double>
Stream of playback speed changes.
no setteroverride
supportsAudioEffects → bool
Whether the player supports audio effects/equalizer.
no setteroverride
supportsBackgroundPlayback → bool
Whether the player supports background playback.
no setteroverride
supportsCrossfade → bool
Whether the player supports crossfade.
no setteroverride
supportsGaplessPlayback → bool
Whether the player supports gapless playback.
no setteroverride
supportsPitchAdjustment → bool
Whether the player supports pitch adjustment.
no setteroverride
supportsSpeedAdjustment → bool
Whether the player supports playback speed adjustment.
no setteroverride
supportsVisualization → bool
Whether the player supports audio visualization data.
no setteroverride
volumeStream → Stream<double>
Stream of volume changes.
no setteroverride

Methods

activateAudioSession() → Future<void>
Activates the audio session for playback.
override
addTracksToPlaylist(List<AudioTrack> tracks, {int? index}) → Future<void>
Adds multiple tracks to the current playlist.
override
addTrackToPlaylist(AudioTrack track, {int? index}) → Future<void>
Adds a track to the current playlist.
override
cacheTrack(AudioTrack track) → Future<void>
Caches an audio track for offline playback.
override
cacheTracks(List<AudioTrack> tracks) → Future<void>
Caches multiple audio tracks for offline playback.
override
clearCache() → Future<void>
Clears all cached audio tracks.
override
clearPlaylist() → Future<void>
Clears the current playlist.
override
deactivateAudioSession() → Future<void>
Deactivates the audio session.
override
dispose() → Future<void>
Disposes of the audio player and releases all resources.
override
initialize(AudioPlayerConfig config) → Future<void>
Initializes the audio player with the given configuration.
override
initializeServices({PlaylistService? playlistService, BaseCacheManagerInterface? cacheManager}) → Future<void>
Initialize with services (separate method for factory use).
loadPlaylist(Playlist playlist, {int startIndex = 0}) → Future<void>
Loads a playlist and optionally starts playing from a specific index.
override
loadTrack(AudioTrack track) → Future<void>
Loads and plays a single audio track.
override
moveTrackInPlaylist(int fromIndex, int toIndex) → Future<void>
Moves a track within the playlist from one index to another.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pause() → Future<void>
Pauses the current audio track.
override
play() → Future<void>
Plays the current audio track.
override
preloadTrack(AudioTrack track) → Future<void>
Preloads a track for faster playback later.
override
preloadTracks(List<AudioTrack> tracks) → Future<void>
Preloads multiple tracks for faster playback later.
override
removeTrackFromPlaylist(int index) → Future<void>
Removes a track from the current playlist by index.
override
seek(Duration position) → Future<void>
Seeks to the specified position in the current audio track.
override
setPitch(double pitch) → Future<void>
Sets the pitch adjustment (if supported).
override
setRepeatMode(RepeatMode mode) → Future<void>
Sets the repeat mode.
override
setShuffleMode(ShuffleMode mode) → Future<void>
Sets the shuffle mode.
override
setSpeed(double speed) → Future<void>
Sets the playback speed (typically 0.5 to 2.0).
override
setVolume(double volume) → Future<void>
Sets the volume level (0.0 to 1.0).
override
skipToIndex(int index) → Future<void>
Skips to a specific track index in the playlist.
override
skipToNext() → Future<void>
Moves to the next track in the playlist.
override
skipToPrevious() → Future<void>
Moves to the previous track in the playlist.
override
stop() → Future<void>
Stops the current audio track and resets position to beginning.
override
toString() → String
A string representation of this object.
inherited
updateConfiguration(AudioPlayerConfig config) → Future<void>
Updates the player configuration.
override

Operators

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

Static Methods

create({required AudioPlayerConfig config, String? playerId, PlaylistService? playlistService, BaseCacheManagerInterface? cacheManager}) → Future<JustAudioPlayer>
Factory constructor that creates and initializes a JustAudio player instance.