You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
539 B
Dart
21 lines
539 B
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:just_audio/just_audio.dart';
|
|
|
|
class MyCustomStream extends StreamAudioSource {
|
|
final Uint8List bytes;
|
|
|
|
MyCustomStream(this.bytes);
|
|
|
|
@override
|
|
Future<StreamAudioResponse> request([int? start, int? end]) async {
|
|
start ??= 0;
|
|
end ??= bytes.length;
|
|
return StreamAudioResponse(
|
|
sourceLength: bytes.length,
|
|
contentLength: end - start,
|
|
offset: start,
|
|
stream: Stream.value(bytes.sublist(start, end)),
|
|
contentType: 'audio/aac',
|
|
);
|
|
}
|
|
} |