Phaser: sound config option 'delay' seems not to do anything

Created on 23 Jan 2019  路  5Comments  路  Source: photonstorm/phaser

Version

  • Phaser v3.15.1-FB (Canvas | HTML5 Audio)
  • Phaser v3.15.1-FB (Canvas | Web Audio)

  • Operating system: Linux (ubuntu bionic/kde neon)

  • Browser: Firefox, Chrome (newest versions)

Description

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).

Example Test Code

this.load.audio('example', [
  'http://localhost:8080/assets/example.mp3',
]);
...
this.audioExample = this.sound.add('example', {
  delay: 0.5
});
this.audioExample.play();

Additional Information

I forced HTML5 Audio by setting

audio: {
  disableWebAudio: true
},

in games config, but that didn't change the behaviour.

馃悰 TypeScript Bug

Most helpful comment

thanks for the hint

Works:

this.audioExample.play('', { delay: 0.5 });

All 5 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MarkSky picture MarkSky  路  3Comments

frob picture frob  路  4Comments

samme picture samme  路  3Comments

Colbydude picture Colbydude  路  4Comments

Secretmapper picture Secretmapper  路  3Comments