diff --git a/lib/views/play.dart b/lib/views/play.dart index ff05ad5..7cbb9c6 100644 --- a/lib/views/play.dart +++ b/lib/views/play.dart @@ -3,43 +3,10 @@ import 'package:just_audio/just_audio.dart' as justaudio; import 'audio_none.dart' if (dart.library.io) 'audio_mediakit.dart' if (dart.library.html) 'audio_web.dart'; -//import 'package:audioplayers/audioplayers.dart' as auplay; -//import 'dart:io' show Platform; import '../pb/stillbox.pb.dart'; -abstract class AudioDriver { - Future play(Call call); - Stream get playerStateStream; -} - -class Player { - late AudioDriver driver; - Player() { -// if (Platform.isMacOS || Platform.isIOS) { - driver = JustAudioDriver(); -// } else { -// driver = AudioPlayersDriver(); -// } - } - - Future play(Call call) async { - await driver.play(call); - } -} - -/* -class AudioPlayersDriver implements AudioDriver { - final player = auplay.AudioPlayer(); - - @override - Future play(Call call) { - return player.play(auplay.BytesSource(Uint8List.fromList(call.audio))); - } -} -*/ - -class JustAudioDriver implements AudioDriver { +class JustAudioDriver { final player = justaudio.AudioPlayer(); final initializer = AudioInitializer(); diff --git a/lib/views/radio.dart b/lib/views/radio.dart index 07951d2..3b74b99 100644 --- a/lib/views/radio.dart +++ b/lib/views/radio.dart @@ -17,7 +17,7 @@ class MainRadio extends StatefulWidget { } class _MainRadioState extends State { - Player player = Player(); + final player = JustAudioDriver(); bool lcdState = false; static const _lcdTimeout = 3; static const _lcdOnColor = Colors.amber; @@ -26,13 +26,12 @@ class _MainRadioState extends State { Color _ledColor = Colors.black; Timer? _lcdTimer; SBCall? _call; - Future completion; @override void initState() { super.initState(); final sb = Provider.of(context, listen: false); - player.driver.playerStateStream.listen((event) async { + player.player.playerStateStream.listen((event) async { if (!event.playing && event.processingState == ProcessingState.completed) { setState(() {