aboutsummaryrefslogtreecommitdiffstats
path: root/lib/data/data_providers/play_controller.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/data/data_providers/play_controller.dart')
-rw-r--r--lib/data/data_providers/play_controller.dart40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/data/data_providers/play_controller.dart b/lib/data/data_providers/play_controller.dart
new file mode 100644
index 0000000..38ef309
--- /dev/null
+++ b/lib/data/data_providers/play_controller.dart
@@ -0,0 +1,40 @@
+import 'package:flutter_ics_homescreen/export.dart';
+
+enum PlaySource { none, media, radio }
+
+class PlayController {
+ final Ref ref;
+ PlaySource source = PlaySource.none;
+
+ PlayController({required this.ref});
+
+ void setSource(PlaySource newSource) {
+ source = newSource;
+ }
+
+ void play() async {
+ switch (source) {
+ case PlaySource.media:
+ ref.read(mpdClientProvider).play();
+ break;
+ case PlaySource.radio:
+ ref.read(radioClientProvider).start();
+ break;
+ default:
+ break;
+ }
+ }
+
+ void pause() async {
+ switch (source) {
+ case PlaySource.media:
+ ref.read(mpdClientProvider).pause();
+ break;
+ case PlaySource.radio:
+ ref.read(radioClientProvider).stop();
+ break;
+ default:
+ break;
+ }
+ }
+}