Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions lib/mpris.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ class MPRISPlayer {
/// Get the metadata of the current element
Future<Metadata> getMetadata() async =>
Metadata.fromMap(await _mediaPlayer.getMetadata());

/// Get the playback status
Future<PlaybackStatus> getPlaybackStatus() async {
final status = await _mediaPlayer.getPlaybackStatus();
switch (status) {
case 'Playing':
return PlaybackStatus.playing;
case 'Paused':
return PlaybackStatus.paused;
case 'Stopped':
return PlaybackStatus.stopped;
default:
throw Exception("Unknown playback status '$status'");
}
}

/// Get the volume level
Future<double> getVolume() => _mediaPlayer.getVolume();
Expand Down Expand Up @@ -209,6 +224,16 @@ enum LoopStatus {
/// If the playback loops through a list of tracks
playlist,
}
enum PlaybackStatus {
/// If the track is playing
playing,

// If the track is paused
paused,

/// If the track was stopped
stopped,
}

// ignore: public_member_api_docs
class Metadata {
Expand Down Expand Up @@ -282,3 +307,4 @@ class Metadata {
// ignore: public_member_api_docs
final int discNumber;
}