Added setVolume and setMute

This commit is contained in:
Richard Davey 2018-03-21 14:54:23 +00:00
parent 4c75c48a77
commit 2433844cd3
3 changed files with 76 additions and 4 deletions

View file

@ -34,6 +34,8 @@ A special mention must go to @orblazer for their outstanding assistance in helpi
* Matter.SetBody and SetExistingBody will now set the origin of the Game Object to be the Matter JS sprite.xOffset and yOffset values, which will auto-center the Game Object to the origin of the body, regardless of shape.
* SoundManager.setRate is a chainable method to allow you to set the global playback rate of all sounds in the SoundManager.
* SoundManager.setDetune is a chainable method to allow you to set the global detuning of all sounds in the SoundManager.
* SoundManager.setMute is a chainable method to allow you to set the global mute state of the SoundManager.
* SoundManager.setVolume is a chainable method to allow you to set the global volume of the SoundManager.
### Bug Fixes

View file

@ -150,7 +150,6 @@ var HTML5AudioSoundManager = new Class({
* devices on the initial explicit user interaction.
*
* @method Phaser.Sound.HTML5AudioSoundManager#unlock
* @private
* @since 3.0.0
*/
unlock: function ()
@ -323,6 +322,24 @@ var HTML5AudioSoundManager = new Class({
* @param {boolean} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#mute property.
*/
/**
* Sets the muted state of all this Sound Manager.
*
* @method Phaser.Sound.HTML5AudioSoundManager#setMute
* @fires Phaser.Sound.HTML5AudioSoundManager#MuteEvent
* @since 3.3.0
*
* @param {boolean} value - `true` to mute all sounds, `false` to unmute them.
*
* @return {Phaser.Sound.HTML5AudioSoundManager} This Sound Manager.
*/
setMute: function (value)
{
this.mute = value;
return this;
},
/**
* @name Phaser.Sound.HTML5AudioSoundManager#mute
* @type {boolean}
@ -356,6 +373,24 @@ var HTML5AudioSoundManager = new Class({
* @param {number} value - An updated value of Phaser.Sound.HTML5AudioSoundManager#volume property.
*/
/**
* Sets the volume of this Sound Manager.
*
* @method Phaser.Sound.HTML5AudioSoundManager#setVolume
* @fires Phaser.Sound.HTML5AudioSoundManager#VolumeEvent
* @since 3.3.0
*
* @param {number} value - The global volume of this Sound Manager.
*
* @return {Phaser.Sound.HTML5AudioSoundManager} This Sound Manager.
*/
setVolume: function (value)
{
this.volume = value;
return this;
},
/**
* @name Phaser.Sound.HTML5AudioSoundManager#volume
* @type {number}

View file

@ -1,5 +1,6 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @author Pavle Goloskokovic <pgoloskokovic@gmail.com> (http://prunegames.com)
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
@ -16,7 +17,6 @@ var WebAudioSound = require('./WebAudioSound');
* @extends Phaser.Sound.BaseSoundManager
* @memberOf Phaser.Sound
* @constructor
* @author Pavle Goloskokovic <pgoloskokovic@gmail.com> (http://prunegames.com)
* @since 3.0.0
*
* @param {Phaser.Game} game - Reference to the current game instance.
@ -100,6 +100,7 @@ var WebAudioSoundManager = new Class({
if (audioConfig && audioConfig.context)
{
audioConfig.context.resume();
return audioConfig.context;
}
@ -119,7 +120,6 @@ var WebAudioSoundManager = new Class({
*/
add: function (key, config)
{
var sound = new WebAudioSound(this, key, config);
this.sounds.push(sound);
@ -133,7 +133,6 @@ var WebAudioSoundManager = new Class({
* Read more about how this issue is handled here in [this article](https://medium.com/@pgoloskokovic/unlocking-web-audio-the-smarter-way-8858218c0e09).
*
* @method Phaser.Sound.WebAudioSoundManager#unlock
* @private
* @since 3.0.0
*/
unlock: function ()
@ -215,6 +214,24 @@ var WebAudioSoundManager = new Class({
* @param {boolean} value - An updated value of Phaser.Sound.WebAudioSoundManager#mute property.
*/
/**
* Sets the muted state of all this Sound Manager.
*
* @method Phaser.Sound.WebAudioSoundManager#setMute
* @fires Phaser.Sound.WebAudioSoundManager#MuteEvent
* @since 3.3.0
*
* @param {boolean} value - `true` to mute all sounds, `false` to unmute them.
*
* @return {Phaser.Sound.WebAudioSoundManager} This Sound Manager.
*/
setMute: function (value)
{
this.mute = value;
return this;
},
/**
* @name Phaser.Sound.WebAudioSoundManager#mute
* @type {boolean}
@ -243,6 +260,24 @@ var WebAudioSoundManager = new Class({
* @param {number} value - An updated value of Phaser.Sound.WebAudioSoundManager#volume property.
*/
/**
* Sets the volume of this Sound Manager.
*
* @method Phaser.Sound.WebAudioSoundManager#setVolume
* @fires Phaser.Sound.WebAudioSoundManager#VolumeEvent
* @since 3.3.0
*
* @param {number} value - The global volume of this Sound Manager.
*
* @return {Phaser.Sound.WebAudioSoundManager} This Sound Manager.
*/
setVolume: function (value)
{
this.volume = value;
return this;
},
/**
* @name Phaser.Sound.WebAudioSoundManager#volume
* @type {number}