event broadcasting and listening
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:audio_service/audio_service.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'Globals.dart';
|
import 'Globals.dart';
|
||||||
@@ -38,6 +39,12 @@ class _PlayControlsState extends State<PlayControls>
|
|||||||
|
|
||||||
print("Listen init");
|
print("Listen init");
|
||||||
|
|
||||||
|
_listenHandler.playbackState.listen((PlaybackState event) {
|
||||||
|
setState(() {
|
||||||
|
isPlaying = event.playing;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
//player = AudioPlayer();
|
//player = AudioPlayer();
|
||||||
|
|
||||||
//player.setReleaseMode(ReleaseMode.release);
|
//player.setReleaseMode(ReleaseMode.release);
|
||||||
@@ -64,9 +71,19 @@ class _PlayControlsState extends State<PlayControls>
|
|||||||
if (isPlaying) {
|
if (isPlaying) {
|
||||||
//player.resume();
|
//player.resume();
|
||||||
_listenHandler.play();
|
_listenHandler.play();
|
||||||
|
_listenHandler.playbackState.add(PlaybackState(
|
||||||
|
controls: [
|
||||||
|
MediaControl.stop,
|
||||||
|
],
|
||||||
|
playing: true,
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
//player.stop();
|
//player.stop();
|
||||||
_listenHandler.stop();
|
_listenHandler.stop();
|
||||||
|
_listenHandler.playbackState.add(PlaybackState(
|
||||||
|
controls: [],
|
||||||
|
playing: false,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
return ClipOval(
|
return ClipOval(
|
||||||
child: Material(
|
child: Material(
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ import 'Globals.dart';
|
|||||||
import 'YthingRadio.dart';
|
import 'YthingRadio.dart';
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
setupListenHandler();
|
await setupListenHandler();
|
||||||
runApp(const YthingRadio());
|
runApp(const YthingRadio());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user