MediaPlayerManager class
State-management-agnostic media player manager This class provides a clean API without forcing any specific state management solution Users can wrap this with their preferred state management (GetX, Riverpod, Bloc, etc.)
Constructors
- MediaPlayerManager({PlayerctlService? service, LogLevel? logLevel})
- Constructor with optional dependency injection
Properties
-
availablePlayers
→ List<
String> -
Get list of available players
no setter
- currentMedia → MediaInfo
-
Get current media info
no setter
- errorMessage → String
-
Get error message
no setter
- hasActivePlayer → bool
-
Check if there's an active player
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isLoading → bool
-
Check if loading
no setter
- isPlayerctlInstalled → bool
-
Check if playerctl is installed
no setter
- logLevel → LogLevel
-
Get current log level
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- selectedPlayer → String
-
Get selected player
no setter
- state → PlayerState
-
Get current state (synchronous)
no setter
-
stateStream
→ Stream<
PlayerState> -
Stream of state changes (for reactive programming)
no setter
- volume → int
-
Get current volume
no setter
Methods
-
cycleLoop(
) → Future< bool> - Cycle through loop modes (None → Track → Playlist → None)
-
dispose(
) → void - Dispose resources
-
getPosition(
) → Future< int?> - Get current playback position in microseconds
-
initialize(
) → Future< void> - Initialize the manager
-
next(
) → Future< bool> - Next track - pauses other players when skipping
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pause(
) → Future< bool> - Pause
-
play(
) → Future< bool> - Play - pauses other players when starting playback
-
playPause(
) → Future< bool> - Play/Pause toggle - pauses other players when starting playback
-
previous(
) → Future< bool> - Previous track - pauses other players when skipping
-
refreshPlayerList(
) → Future< void> - Refresh the list of available players
-
retry(
) → Future< void> - Retry initialization if it failed
-
seek(
int offsetMicroseconds) → Future< bool> - Seek relative to current position (positive = forward, negative = backward)
-
seekBackward(
int seconds) → Future< bool> - Skip backward by specified number of seconds
-
seekForward(
int seconds) → Future< bool> - Skip forward by specified number of seconds
-
seekTo(
int positionMicroseconds) → Future< bool> - Seek to absolute position in microseconds
-
setLogLevel(
LogLevel level) → void - Set log level at runtime
-
setVolume(
int newVolume) → Future< bool> - Set volume (0-100)
-
startListening(
[String? player]) → void - Start listening to metadata changes
-
stop(
) → Future< bool> - Stop
-
stopListening(
) → void - Stop listening to metadata changes
-
switchPlayer(
String playerName) → Future< void> - Switch to a different player
-
toggleShuffle(
) → Future< bool> - Toggle shuffle
-
toString(
) → String -
A string representation of this object.
inherited
-
updateCurrentVolume(
) → Future< void> - Get current volume
-
updateLoopStatus(
) → Future< void> - Update loop status from player
-
updateShuffleStatus(
) → Future< void> - Update shuffle status from player
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited