calls/lib/controller/play.dart
Daniel Ponte 66716c0510 Something mostly working.
Squashed commit of the following:

commit b15263546e
Author: Daniel Ponte <amigan@gmail.com>
Date:   Wed Aug 14 09:29:49 2024 -0400

    save bytes source class

commit 3a6ac88685
Author: Daniel Ponte <amigan@gmail.com>
Date:   Wed Aug 14 09:26:28 2024 -0400

    safearea

commit c411a007e6
Author: Daniel Ponte <amigan@gmail.com>
Date:   Wed Aug 14 08:33:11 2024 -0400

    try to play

commit 5a8e7c7690
Author: Daniel Ponte <amigan@gmail.com>
Date:   Wed Aug 14 08:29:53 2024 -0400

    protoc

commit c776d37765
Author: Daniel Ponte <amigan@gmail.com>
Date:   Wed Aug 14 08:28:26 2024 -0400

    wip

commit 0d150d73d8
Author: Daniel Ponte <amigan@gmail.com>
Date:   Tue Aug 13 23:07:35 2024 -0400

    big huge wip

commit db99eeb43a
Author: Daniel Ponte <amigan@gmail.com>
Date:   Tue Aug 13 21:03:42 2024 -0400

    big wip

commit 5af1b90ccc
Author: Daniel Ponte <amigan@gmail.com>
Date:   Tue Aug 13 20:04:37 2024 -0400

    WIP

commit 08183de44f
Author: Daniel Ponte <amigan@gmail.com>
Date:   Tue Aug 13 10:41:06 2024 -0400

    notifier

commit 5f92cf977b
Author: Daniel Ponte <amigan@gmail.com>
Date:   Mon Aug 12 09:13:43 2024 -0400

    wip

commit d6d590684d
Author: Daniel Ponte <amigan@gmail.com>
Date:   Mon Aug 12 07:47:08 2024 -0400

    fix

commit 9d58f4fa7f
Author: Daniel Ponte <amigan@gmail.com>
Date:   Sun Aug 11 23:59:01 2024 -0400

    wip

commit d61ce79c29
Author: Daniel Ponte <amigan@gmail.com>
Date:   Sun Aug 11 19:23:16 2024 -0400

    wip

commit f4ea5916b8
Author: Daniel Ponte <amigan@gmail.com>
Date:   Sat Aug 10 17:07:52 2024 -0400

    macos stuff

commit fe8bdc13a5
Author: Daniel Ponte <amigan@gmail.com>
Date:   Sat Aug 10 17:07:04 2024 -0400

    add default case

commit 9bc788035b
Author: Daniel Ponte <amigan@gmail.com>
Date:   Sat Aug 10 16:38:46 2024 -0400

    wip

commit 8e99afeb31
Author: Daniel Ponte <amigan@gmail.com>
Date:   Sat Aug 10 14:36:08 2024 -0400

    Controller

commit e64948bef5
Author: Daniel Ponte <amigan@gmail.com>
Date:   Sat Aug 10 14:24:28 2024 -0400

    ws
2024-08-14 09:30:27 -04:00

39 lines
No EOL
1 KiB
Dart

import 'dart:typed_data';
import 'package:audioplayers/audioplayers.dart';
import '../pb/stillbox.pb.dart';
class Player {
final player = AudioPlayer();
Player();
Future<void> play(Call call) {
// TODO make a queue
return player.play(BytesSource(Uint8List.fromList(call.audio)));
}
}
/*
for just_audio (add just_audio and just_audio_linux)
class CallBytesSource extends StreamAudioSource {
late Uint8List _buffer;
final Call _call;
factory CallBytesSource(Call call) {
return CallBytesSource._(call, Uint8List.fromList(call.audio));
}
CallBytesSource._(this._call, this._buffer) : super(tag: 'CallBytesSource');
@override
Future<StreamAudioResponse> request([int? start, int? end]) async {
// Returning the stream audio response with the parameters
return StreamAudioResponse(
sourceLength: _buffer.length,
contentLength: (end ?? _buffer.length) - (start ?? 0),
offset: start ?? 0,
stream: Stream.fromIterable([_buffer.sublist(start ?? 0, end)]),
contentType: _call.audioType,
);
}
}
*/