Phaser v3.15.1-FB (Canvas | Web Audio)
Operating system: Linux (ubuntu bionic/kde neon)
Browser: Firefox, Chrome (newest versions)
sound.add() allows to add configuration like 'volume'. The option 'delay' has no effect.
From my understanding
delay: 0.5
should make the sound play 0.5 seconds after play() was called.
The sound is played immediately no matter which value delay has (0.1, 1, 5000).
this.load.audio('example', [
'http://localhost:8080/assets/example.mp3',
]);
...
this.audioExample = this.sound.add('example', {
delay: 0.5
});
this.audioExample.play();
I forced HTML5 Audio by setting
audio: {
disableWebAudio: true
},
in games config, but that didn't change the behaviour.
Hey @colorcube i can confirm in this way it doesn't work.
I don't know why but glob config doesn't work with play...
But any how if you would like to use @colorcube you can do this:
// ....
this.audioExample = this.sound.add('example');
this.audioExample.play('', { delay: 0.5 }); //don't give marker, only options :)
Tried like this and worked on win10 -> chrome
Oh bdw, it doesn't change anything with this:
audio: {
disableWebAudio: true
},
Cause at the end, all sound's are created by BaseSound class
thanks for the hint
Works:
this.audioExample.play('', { delay: 0.5 });
Even shorter, you can do this.audioExample.play({ delay: 0.5 });
Delay is option only relevant to specific playback so it has to be passed to the play method and can not be set globally at the point of adding sound due to the way how it is handled under the hood.
Thanks for clarification.
I ask myself why I thought it is possible to set delay with add() and it is because of the TypeScript definition.
SoundConfig has the delay property. SoundConfig is defined as a parameter of add() and play().
I don't know if anything has to be done or the ticket can be closed?!
Thank you for submitting this docs issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.
Most helpful comment
thanks for the hint
Works: