UAudio class abstract final

One app-wide music player with a queue and a lock-screen/notification control; all 6 platforms. Background play: dart run u:app permission add background-audio. UAudio.play("https://x.com/song.mp3")

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Static Properties

controller → UMediaController
The shared player behind UAudio (listen to it for UI).
no setter
currentIndex → int
Index of the current track in the queue.
no setter
duration → Duration
Length of the current track.
no setter
isPlaying → bool
True while playing.
no setter
nowPlaying → UMediaMetadata?
Title/artist/artwork of the current track, or null.
no setter
position → Duration
Current position.
no setter
positionStream → Stream<Duration>
Position ticks while playing.
no setter
queue → List<UMediaSource>
Tracks in the queue.
no setter
state → ValueListenable<UMediaValue>
Player state for ValueListenableBuilder. ValueListenableBuilder(valueListenable: UAudio.state, builder: (c, v, _) => Text(v.position.toClock()))
no setter
stateStream → Stream<UMediaValue>
Every state change.
no setter
value → UMediaValue
Current state: playing, position, duration, buffering…
no setter

Static Methods

add(Object input) → Future<void>
Adds a track to the end of the queue.
dispose() → Future<void>
jumpTo(int index) → Future<void>
Plays the queue item at index.
move(int from, int to) → Future<void>
Reorders the queue.
next() → Future<void>
Next track in the queue.
notification({required UMediaMetadata metadata, bool showSeekBar = true}) → Future<void>
Shows/updates the lock-screen and notification controls for the current track.
pause() → Future<void>
Pauses.
play(Object input, {UMediaMetadata? metadata}) → Future<void>
Plays one URL, path or asset; metadata shows on the lock screen. UAudio.play(url, metadata: const UMediaMetadata(title: "Song"))
playFolder(String directoryPath, {bool recursive = true, int startAt = 0}) → Future<void>
Plays every audio file in a folder (not on web). UAudio.playFolder("/storage/emulated/0/Music")
playNext(Object input) → Future<void>
Inserts a track right after the current one.
playQueue(List<Object> inputs, {int startAt = 0}) → Future<void>
Plays a list, starting at startAt. UAudio.playQueue([a, b, c])
previous() → Future<void>
Previous track (or restart the current one).
readTags(String path) → Future<UMediaMetadata>
Title/artist/album/artwork of an audio file.
removeAt(int index) → Future<void>
Removes a queue item.
resume() → Future<void>
Continues playback.
scanFolder(String directoryPath, {bool recursive = true, int limit = 20000}) → Future<List<UMediaSource>>
Audio files in a folder as sources (not on web).
seek(Duration position) → Future<void>
Jumps to a position. UAudio.seek(30.seconds)
seekBy(Duration delta) → Future<void>
Moves forward/back by delta. UAudio.seekBy(-10.seconds)
setMuted(bool muted) → Future<void>
Mutes or unmutes.
setRepeat(URepeatMode mode) → Future<void>
Repeat off / one / all.
setShuffle(bool enabled) → Future<void>
Shuffle on or off.
setSpeed(double speed) → Future<void>
Playback speed, e.g. 1.5.
setVolume(double volume) → Future<void>
Volume 0-1.
source(Object input) → UMediaSource
Turns a URL, file path, "assets/…" or content:// string into a source.
stop() → Future<void>
Stops and releases the current track.
toggle() → Future<void>
Play/pause.
toggleShuffle() → Future<void>
Flips shuffle.

Constants

audioExtensions → const Set<String>
File extensions treated as audio.