setSourceBytes method

  1. @override
Future<void> setSourceBytes(
  1. String playerId,
  2. Uint8List bytes, {
  3. String? mimeType,
})

Configures the play to read the audio from a byte array.

Implementation

@override
Future<void> setSourceBytes(
  String playerId,
  Uint8List bytes, {
  String? mimeType,
}) async {
  // Convert to data uri as workaround.
  final uri = Uri.dataFromBytes(bytes, mimeType: mimeType ?? 'audio/mpeg');
  await getPlayer(playerId).setUrl(uri.toString());
}