Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
c3717042a1
|
|||
|
04873f1240
|
|||
|
137f31c104
|
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 8.1 KiB |
1
assets/appicon/radio.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-radio"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M14 3l-9.371 3.749a1 1 0 0 0 -.629 .928v11.323a1 1 0 0 0 1 1h14a1 1 0 0 0 1 -1v-11a1 1 0 0 0 -1 -1h-14.5" /><path d="M4 12h16" /><path d="M7 12v-2" /><path d="M17 16v.01" /><path d="M13 16v.01" /></svg>
|
||||
|
After Width: | Height: | Size: 517 B |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 3.1 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.8 KiB |
@@ -17,6 +17,36 @@ Future<void> setupListenHandler() async {
|
||||
_session = await AudioSession.instance;
|
||||
|
||||
await _session.configure(const AudioSessionConfiguration.music());
|
||||
|
||||
//TODO: Do I need to handle these events? audioplayers may be doing it already
|
||||
//_session.interruptionEventStream.listen((event) {
|
||||
// if (event.begin) {
|
||||
// switch (event.type) {
|
||||
// case AudioInterruptionType.duck:
|
||||
// _listenHandler.duck();
|
||||
// break;
|
||||
// case AudioInterruptionType.pause:
|
||||
// case AudioInterruptionType.unknown:
|
||||
// _listenHandler.pause();
|
||||
// break;
|
||||
// }
|
||||
// } else {
|
||||
// switch (event.type) {
|
||||
// case AudioInterruptionType.duck:
|
||||
// _listenHandler.unDuck();
|
||||
// break;
|
||||
// case AudioInterruptionType.pause:
|
||||
// _listenHandler.play();
|
||||
// break;
|
||||
// case AudioInterruptionType.unknown:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//});
|
||||
|
||||
//_session.becomingNoisyEventStream.listen((_) {
|
||||
// _listenHandler.pause();
|
||||
//});
|
||||
}
|
||||
|
||||
ListenHandler getListenHandlder() => _listenHandler;
|
||||
|
||||
@@ -36,8 +36,6 @@ class _PlayControlsState extends State<PlayControls>
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
bool isPlaying = false;
|
||||
|
||||
final ListenHandler _listenHandler = getListenHandlder();
|
||||
|
||||
@override
|
||||
@@ -46,15 +44,9 @@ class _PlayControlsState extends State<PlayControls>
|
||||
|
||||
print("Listen init");
|
||||
|
||||
_listenHandler.playbackState.listen((PlaybackState event) {
|
||||
if (isPlaying == event.playing) {
|
||||
print("State unchanged, skipping setState()");
|
||||
return;
|
||||
}
|
||||
setState(() {
|
||||
isPlaying = event.playing;
|
||||
print("Updated playing state to $isPlaying");
|
||||
});
|
||||
_listenHandler.playbackState.listen((PlaybackState state) {
|
||||
print("Playback state changed");
|
||||
setState(() {});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,48 +57,33 @@ class _PlayControlsState extends State<PlayControls>
|
||||
_listenHandler.stop();
|
||||
}
|
||||
|
||||
Future<void> playPause() async {
|
||||
print("playPause called");
|
||||
_listenHandler.isPlaying()
|
||||
? await _listenHandler.stop()
|
||||
: await _listenHandler.play();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
|
||||
print("Running build - Listen");
|
||||
|
||||
if (isPlaying) {
|
||||
_listenHandler.play();
|
||||
_listenHandler.playbackState.add(PlaybackState(
|
||||
controls: [
|
||||
MediaControl.stop,
|
||||
MediaControl.pause,
|
||||
],
|
||||
systemActions: {
|
||||
MediaAction.stop,
|
||||
MediaAction.pause,
|
||||
},
|
||||
playing: true,
|
||||
));
|
||||
} else {
|
||||
_listenHandler.stop();
|
||||
_listenHandler.playbackState.add(PlaybackState(
|
||||
controls: [],
|
||||
systemActions: {},
|
||||
playing: false,
|
||||
));
|
||||
}
|
||||
return ClipOval(
|
||||
child: Material(
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
child: InkWell(
|
||||
splashColor: Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
isPlaying = !isPlaying;
|
||||
});
|
||||
onTap: () async {
|
||||
await playPause();
|
||||
setState(() {});
|
||||
},
|
||||
child: SizedBox(
|
||||
width: 100,
|
||||
height: 100,
|
||||
child: Icon(
|
||||
isPlaying ? Icons.stop : Icons.play_arrow,
|
||||
_listenHandler.isPlaying() ? Icons.stop : Icons.play_arrow,
|
||||
color: Colors.white,
|
||||
size: 50,
|
||||
),
|
||||
|
||||
@@ -11,12 +11,59 @@ class ListenHandler extends BaseAudioHandler {
|
||||
|
||||
setup_player() {
|
||||
_player.setReleaseMode(ReleaseMode.release);
|
||||
_player.onPlayerStateChanged.listen((event) {
|
||||
print("Received audioplayers event: $event");
|
||||
|
||||
switch (event) {
|
||||
case PlayerState.playing:
|
||||
super.playbackState.add(PlaybackState(
|
||||
controls: [
|
||||
MediaControl.stop,
|
||||
MediaControl.pause,
|
||||
],
|
||||
systemActions: {
|
||||
MediaAction.stop,
|
||||
MediaAction.pause,
|
||||
},
|
||||
playing: true,
|
||||
));
|
||||
break;
|
||||
case PlayerState.paused:
|
||||
case PlayerState.stopped:
|
||||
case PlayerState.completed:
|
||||
case PlayerState.disposed:
|
||||
super.playbackState.add(PlaybackState(
|
||||
controls: [],
|
||||
systemActions: {},
|
||||
playing: false,
|
||||
));
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ListenHandler() {
|
||||
setup_player();
|
||||
}
|
||||
|
||||
bool isPlaying() => super.playbackState.value.playing;
|
||||
|
||||
double _duckVol = 0;
|
||||
|
||||
void duck() {
|
||||
//TODO: Confirm I need to do this manually, it looks like audioplayers already does this
|
||||
print("Duck requested");
|
||||
//_duckVol = _player.volume;
|
||||
|
||||
//_player.setVolume(_duckVol - 0.4 > 0 ? _duckVol - 0.4 : 0.0);
|
||||
}
|
||||
|
||||
void unDuck() {
|
||||
//TODO: Confirm I need to do this manually, it looks like audioplayers already does this
|
||||
print("Unduck requested");
|
||||
//_player.setVolume(_duckVol);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> play() async {
|
||||
if (await startAudioSession()) {
|
||||
|
||||
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 881 B After Width: | Height: | Size: 851 B |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.8 KiB |
BIN
web/favicon.png
|
Before Width: | Height: | Size: 881 B After Width: | Height: | Size: 851 B |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 4.1 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 4.2 KiB |