playBytes method
Plays audio in the form of a byte array.
This is only supported on Android 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 {
stayAwake ??= false;
if (!Platform.isAndroid) {
throw PlatformException(
code: 'Not supported',
message: 'Only Android is currently supported',
);
}
final int result = await _invokeMethod('playBytes', {
'bytes': bytes,
'volume': volume,
'position': position?.inMilliseconds,
'respectSilence': respectSilence,
'stayAwake': stayAwake,
'duckAudio': duckAudio,
'recordingActive': recordingActive,
});
if (result == 1) {
state = AudioPlayerState.PLAYING;
}
return result;
}