From b15263546eadbc86de233996c5c32ceb17e0a45d Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Wed, 14 Aug 2024 09:29:49 -0400 Subject: [PATCH] save bytes source class --- lib/controller/play.dart | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/controller/play.dart b/lib/controller/play.dart index eb7f6ab..1a030bf 100644 --- a/lib/controller/play.dart +++ b/lib/controller/play.dart @@ -11,3 +11,29 @@ class Player { 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 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, + ); + } +} +*/ \ No newline at end of file