play method
Plays an audio.
If isLocal
is true, url
must be a local file system path.
If isLocal
is false, url
must be a remote URL.
respectSilence and stayAwake are not implemented on macOS.
Implementation
Future<int> play(
String url, {
bool? isLocal,
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 {
isLocal ??= isLocalUrl(url);
final int result = await _invokeMethod('play', {
'url': url,
'isLocal': isLocal,
'volume': volume,
'position': position?.inMilliseconds,
'respectSilence': respectSilence,
'stayAwake': stayAwake,
'duckAudio': duckAudio,
'recordingActive': recordingActive,
});
if (result == 1) {
state = AudioPlayerState.PLAYING;
}
return result;
}