summaryrefslogtreecommitdiffstats
path: root/lib/data/models/mediaplayer_state.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/data/models/mediaplayer_state.dart')
-rw-r--r--lib/data/models/mediaplayer_state.dart49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/data/models/mediaplayer_state.dart b/lib/data/models/mediaplayer_state.dart
new file mode 100644
index 0000000..f880a1e
--- /dev/null
+++ b/lib/data/models/mediaplayer_state.dart
@@ -0,0 +1,49 @@
+import 'package:flutter_ics_homescreen/export.dart';
+import 'package:flutter_ics_homescreen/data/data_providers/playlist_notifier.dart';
+
+enum PlayState { stopped, playing, paused }
+
+@immutable
+class MediaPlayerState {
+ final int playlistPosition;
+ final PlayState playState;
+ final PlaylistEntry? song;
+
+ const MediaPlayerState(
+ {required this.playlistPosition,
+ required this.playState,
+ required this.song});
+
+ const MediaPlayerState.initial()
+ : playlistPosition = -1,
+ playState = PlayState.stopped,
+ song = null;
+
+ MediaPlayerState copyWith(
+ {int? playlistPosition,
+ PlayState? playState,
+ PlaylistEntry? song,
+ Duration? songPosition,
+ Duration? songLength}) {
+ return MediaPlayerState(
+ playlistPosition: playlistPosition ?? this.playlistPosition,
+ playState: playState ?? this.playState,
+ song: song ?? this.song,
+ );
+ }
+
+ @override
+ bool operator ==(Object other) {
+ if (identical(this, other)) return true;
+
+ return other is MediaPlayerState &&
+ other.playlistPosition == playlistPosition &&
+ other.playState == playState &&
+ other.song == song;
+ }
+
+ @override
+ int get hashCode {
+ return playlistPosition.hashCode ^ playState.hashCode ^ song.hashCode;
+ }
+}