Skip to content

Commit f2c2c93

Browse files
committed
Added new DECODE and DECODE_ALL events
1 parent b1e3ee4 commit f2c2c93

3 files changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2019 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* The Audio Data Decoded All Event.
9+
*
10+
* This event is dispatched by the Web Audio Sound Manager as a result of calling the `decodeAudio` method,
11+
* once all files passed to the method have been decoded (or errored).
12+
*
13+
* Use `Phaser.Sound.Events#DECODED` to listen for single sounds being decoded, and `DECODED_ALL` to
14+
* listen for them all completing.
15+
*
16+
* Listen to it from the Sound Manager in a Scene using `this.sound.on('decodedall', listener)`, i.e.:
17+
*
18+
* ```javascript
19+
* this.sound.once('decodedall', handler);
20+
* this.sound.decodeAudio([ audioFiles ]);
21+
* ```
22+
*
23+
* @event Phaser.Sound.Events#DECODED_ALL
24+
* @since 3.18.0
25+
*/
26+
module.exports = 'decodedall';

src/sound/events/DECODED_EVENT.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2019 Photon Storm Ltd.
4+
* @license {@link https://opensource.org/licenses/MIT|MIT License}
5+
*/
6+
7+
/**
8+
* The Audio Data Decoded Event.
9+
*
10+
* This event is dispatched by the Web Audio Sound Manager as a result of calling the `decodeAudio` method.
11+
*
12+
* Listen to it from the Sound Manager in a Scene using `this.sound.on('decoded', listener)`, i.e.:
13+
*
14+
* ```javascript
15+
* this.sound.on('decoded', handler);
16+
* this.sound.decodeAudio(key, audioData);
17+
* ```
18+
*
19+
* @event Phaser.Sound.Events#DECODED
20+
* @since 3.18.0
21+
*
22+
* @param {string} key - The key of the audio file that was decoded and added to the audio cache.
23+
*/
24+
module.exports = 'decoded';

src/sound/events/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
module.exports = {
1212

1313
COMPLETE: require('./COMPLETE_EVENT'),
14+
DECODED: require('./DECODED_EVENT'),
15+
DECODED_ALL: require('./DECODED_ALL_EVENT'),
1416
DESTROY: require('./DESTROY_EVENT'),
1517
DETUNE: require('./DETUNE_EVENT'),
1618
GLOBAL_DETUNE: require('./GLOBAL_DETUNE_EVENT'),

0 commit comments

Comments
 (0)