playBytes method
Plays audio in the form of a byte array.
This is only supported on Android (SDK >= 23) currently.
Implementation
Future<int> playBytes(
Uint8List bytes, {
double volume = 1.0,
// position must be null by default to be compatible with radio streams
Duration? position,
bool respectSilence = false,
bool stayAwake = false,
bool duckAudio = false,
bool recordingActive = false,
}) async {
if (!_isAndroid()) {
throw PlatformException(
code: 'Not supported',
message: 'Only Android is currently supported',
);
}
final result = await _invokeMethod(
'playBytes',
<String, dynamic>{
'bytes': bytes,
'volume': volume,
'position': position?.inMilliseconds,
'respectSilence': respectSilence,
'stayAwake': stayAwake,
'duckAudio': duckAudio,
'recordingActive': recordingActive,
},
);
if (result == 1) {
state = PlayerState.PLAYING;
}
return result;
}