play method
Begins (or restarts) playback.
Implementation
@override
void play() {
final paused = _liveVoice;
if (paused != null && paused.isPaused) {
paused.resume();
return;
}
final engine = this.engine;
final clip = _clip;
if (engine == null || clip == null) {
// Not ready yet (asset still loading, or mounted without an
// engine). Remember the intent; onLoad retries.
_pendingPlay = true;
return;
}
_pendingPlay = false;
_voice?.stop();
final voice = engine.createVoice(clip)
..volume = _volume
..pitch = _pitch
..looping = _looping
..setBus(bus ?? (busName != null ? engine.findBus(busName!) : null))
..setPositional(positional);
if (positional && isMounted) {
voice.update3d(
node.globalTransform.getTranslation(),
Vector3.zero(),
attenuation,
);
}
voice.start();
_voice = voice;
}