play method
Future<void>
play(
- Source source, {
- double? volume,
- double? balance,
- AudioContext? ctx,
- Duration? position,
- PlayerMode? mode,
Play an audio source
.
To reduce preparation latency, instead consider calling setSource beforehand and then resume separately.
Implementation
Future<void> play(
Source source, {
double? volume,
double? balance,
AudioContext? ctx,
Duration? position,
PlayerMode? mode,
}) async {
desiredState = PlayerState.playing;
if (mode != null) {
await setPlayerMode(mode);
}
if (volume != null) {
await setVolume(volume);
}
if (balance != null) {
await setBalance(balance);
}
if (ctx != null) {
await setAudioContext(ctx);
}
await setSource(source);
if (position != null) {
await seek(position);
}
await _resume();
}