mirror of
https://github.com/amigan/calls.git
synced 2024-11-21 12:29:47 -05:00
collapse audio
This commit is contained in:
parent
486e078dfd
commit
d52c8310a3
2 changed files with 3 additions and 37 deletions
|
@ -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<void> play(Call call);
|
||||
Stream<justaudio.PlayerState> get playerStateStream;
|
||||
}
|
||||
|
||||
class Player {
|
||||
late AudioDriver driver;
|
||||
Player() {
|
||||
// if (Platform.isMacOS || Platform.isIOS) {
|
||||
driver = JustAudioDriver();
|
||||
// } else {
|
||||
// driver = AudioPlayersDriver();
|
||||
// }
|
||||
}
|
||||
|
||||
Future<void> play(Call call) async {
|
||||
await driver.play(call);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
class AudioPlayersDriver implements AudioDriver {
|
||||
final player = auplay.AudioPlayer();
|
||||
|
||||
@override
|
||||
Future<void> 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();
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class MainRadio extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _MainRadioState extends State<MainRadio> {
|
||||
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<MainRadio> {
|
|||
Color _ledColor = Colors.black;
|
||||
Timer? _lcdTimer;
|
||||
SBCall? _call;
|
||||
Future<bool> completion;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final sb = Provider.of<Stillbox>(context, listen: false);
|
||||
player.driver.playerStateStream.listen((event) async {
|
||||
player.player.playerStateStream.listen((event) async {
|
||||
if (!event.playing &&
|
||||
event.processingState == ProcessingState.completed) {
|
||||
setState(() {
|
||||
|
|
Loading…
Reference in a new issue