Skip to content

Commit 677cfae

Browse files
committed
Docs for Sound Managers
1 parent 88b088b commit 677cfae

4 files changed

Lines changed: 26 additions & 21 deletions

File tree

src/sound/BaseSoundManager.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ var NOOP = require('../utils/NOOP');
1414

1515
/**
1616
* @classdesc
17-
* The sound manager is responsible for playing back audio via Web Audio API or HTML Audio tag as fallback.
18-
* The audio file type and the encoding of those files are extremely important.
19-
*
20-
* Not all browsers can play all audio formats.
21-
*
22-
* There is a good guide to what's supported [here](https://developer.mozilla.org/en-US/Apps/Fundamentals/Audio_and_video_delivery/Cross-browser_audio_basics#Audio_Codec_Support).
17+
* Base class for other Sound Manager classes.
2318
*
2419
* @class BaseSoundManager
2520
* @extends Phaser.Events.EventEmitter
@@ -28,6 +23,10 @@ var NOOP = require('../utils/NOOP');
2823
* @since 3.0.0
2924
*
3025
* @param {Phaser.Game} game - Reference to the current game instance.
26+
*
27+
* @see Phaser.Sound.HTML5AudioSoundManager
28+
* @see Phaser.Sound.NoAudioSoundManager
29+
* @see Phaser.Sound.WebAudioSoundManager
3130
*/
3231
var BaseSoundManager = new Class({
3332

src/sound/html5/HTML5AudioSoundManager.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@ var HTML5AudioSound = require('./HTML5AudioSound');
1212

1313
/**
1414
* HTML5 Audio implementation of the Sound Manager.
15-
*
16-
* Note: To play multiple instances of the same HTML5 Audio sound, you need to provide an `instances` value when
15+
*
16+
* To play multiple instances of the same HTML5 Audio sound, you need to provide an `instances` value when
1717
* loading the sound with the Loader:
18-
*
18+
*
1919
* ```javascript
2020
* this.load.audio('explosion', 'explosion.mp3', {
2121
* instances: 2
2222
* });
2323
* ```
2424
*
25+
* Not all browsers can play all audio formats.
26+
* There is a good guide to what's supported: [Cross-browser audio basics: Audio codec support](https://developer.mozilla.org/en-US/Apps/Fundamentals/Audio_and_video_delivery/Cross-browser_audio_basics#Audio_Codec_Support).
27+
*
2528
* @class HTML5AudioSoundManager
2629
* @extends Phaser.Sound.BaseSoundManager
2730
* @memberof Phaser.Sound

src/sound/noaudio/NoAudioSoundManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ var NOOP = require('../../utils/NOOP');
1313

1414
/**
1515
* @classdesc
16-
* No audio implementation of the sound manager. It is used if audio has been
16+
* No-audio implementation of the Sound Manager. It is used if audio has been
1717
* disabled in the game config or the device doesn't support any audio.
1818
*
19-
* It represents a graceful degradation of sound manager logic that provides
19+
* It represents a graceful degradation of Sound Manager logic that provides
2020
* minimal functionality and prevents Phaser projects that use audio from
2121
* breaking on devices that don't support any audio playback technologies.
2222
*

src/sound/webaudio/WebAudioSoundManager.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ var WebAudioSound = require('./WebAudioSound');
1313

1414
/**
1515
* @classdesc
16-
* Web Audio API implementation of the sound manager.
16+
* Web Audio API implementation of the Sound Manager.
17+
*
18+
* Not all browsers can play all audio formats.
19+
* There is a good guide to what's supported: [Cross-browser audio basics: Audio codec support](https://developer.mozilla.org/en-US/Apps/Fundamentals/Audio_and_video_delivery/Cross-browser_audio_basics#Audio_Codec_Support).
1720
*
1821
* @class WebAudioSoundManager
1922
* @extends Phaser.Sound.BaseSoundManager
@@ -117,7 +120,7 @@ var WebAudioSoundManager = new Class({
117120
/**
118121
* This method takes a new AudioContext reference and then sets
119122
* this Sound Manager to use that context for all playback.
120-
*
123+
*
121124
* As part of this call it also disconnects the master mute and volume
122125
* nodes and then re-creates them on the new given context.
123126
*
@@ -180,16 +183,16 @@ var WebAudioSoundManager = new Class({
180183

181184
/**
182185
* Decode audio data into a format ready for playback via Web Audio.
183-
*
186+
*
184187
* The audio data can be a base64 encoded string, an audio media-type data uri, or an ArrayBuffer instance.
185-
*
188+
*
186189
* The `audioKey` is the key that will be used to save the decoded audio to the audio cache.
187-
*
190+
*
188191
* Instead of passing a single entry you can instead pass an array of `Phaser.Types.Sound.DecodeAudioConfig`
189192
* objects as the first and only argument.
190-
*
193+
*
191194
* Decoding is an async process, so be sure to listen for the events to know when decoding has completed.
192-
*
195+
*
193196
* Once the audio has decoded it can be added to the Sound Manager or played via its key.
194197
*
195198
* @method Phaser.Sound.WebAudioSoundManager#decodeAudio
@@ -231,7 +234,7 @@ var WebAudioSoundManager = new Class({
231234
var success = function (key, audioBuffer)
232235
{
233236
cache.add(key, audioBuffer);
234-
237+
235238
this.emit(Events.DECODED, key);
236239

237240
remaining--;
@@ -241,7 +244,7 @@ var WebAudioSoundManager = new Class({
241244
this.emit(Events.DECODED_ALL);
242245
}
243246
}.bind(this, key);
244-
247+
245248
var failure = function (key, error)
246249
{
247250
// eslint-disable-next-line no-console
@@ -283,7 +286,7 @@ var WebAudioSoundManager = new Class({
283286
body.removeEventListener('touchend', unlockHandler);
284287
body.removeEventListener('click', unlockHandler);
285288
body.removeEventListener('keydown', unlockHandler);
286-
289+
287290
_this.unlocked = true;
288291
}, function ()
289292
{

0 commit comments

Comments
 (0)