playSound method
SynthizerSound
playSound({
- required AssetReference assetReference,
- bool keepAlive = false,
- double? gain,
- bool looping = false,
- double pitchBend = 1.0,
override
Play a sound with the given assetReference
.
Implementation
@override
SynthizerSound playSound({
required final AssetReference assetReference,
final bool keepAlive = false,
final double? gain,
final bool looping = false,
final double pitchBend = 1.0,
}) {
final buffer = backend.bufferCache.getBuffer(assetReference);
final generator = context.createBufferGenerator()
..gain.value = gain ?? assetReference.gain
..looping.value = looping
..pitchBend.value = pitchBend
..buffer.value = buffer;
source.addGenerator(generator);
configureLinger(generator: generator, keepAlive: keepAlive);
return SynthizerSound(
backend: backend,
channel: this,
keepAlive: keepAlive,
generator: generator,
);
}