mirror of
https://github.com/photonstorm/phaser
synced 2024-11-28 15:41:37 +00:00
Merge pull request #5106 from samme/fix/NoAudioSound
Fix destroying NoAudioSound and add missing methods
This commit is contained in:
commit
3122b51f66
1 changed files with 98 additions and 34 deletions
|
@ -10,6 +10,21 @@ var Class = require('../../utils/Class');
|
||||||
var EventEmitter = require('eventemitter3');
|
var EventEmitter = require('eventemitter3');
|
||||||
var Extend = require('../../utils/object/Extend');
|
var Extend = require('../../utils/object/Extend');
|
||||||
|
|
||||||
|
var returnFalse = function ()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
var returnNull = function ()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
var returnThis = function ()
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @classdesc
|
* @classdesc
|
||||||
* No audio implementation of the sound. It is used if audio has been
|
* No audio implementation of the sound. It is used if audio has been
|
||||||
|
@ -20,7 +35,6 @@ var Extend = require('../../utils/object/Extend');
|
||||||
* breaking on devices that don't support any audio playback technologies.
|
* breaking on devices that don't support any audio playback technologies.
|
||||||
*
|
*
|
||||||
* @class NoAudioSound
|
* @class NoAudioSound
|
||||||
* @extends Phaser.Sound.BaseSound
|
|
||||||
* @memberof Phaser.Sound
|
* @memberof Phaser.Sound
|
||||||
* @constructor
|
* @constructor
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
|
@ -71,51 +85,101 @@ var NoAudioSound = new Class({
|
||||||
this.pendingRemove = false;
|
this.pendingRemove = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method Phaser.Sound.NoAudioSound#addMarker
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @param {Phaser.Types.Sound.SoundMarker} marker - Marker object.
|
||||||
|
*
|
||||||
|
* @return {boolean} false
|
||||||
|
*/
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
addMarker: function (marker)
|
addMarker: returnFalse,
|
||||||
{
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @method Phaser.Sound.NoAudioSound#updateMarker
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @param {Phaser.Types.Sound.SoundMarker} marker - Marker object with updated values.
|
||||||
|
*
|
||||||
|
* @return {boolean} false
|
||||||
|
*/
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
updateMarker: function (marker)
|
updateMarker: returnFalse,
|
||||||
{
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
/**
|
||||||
removeMarker: function (markerName)
|
* @method Phaser.Sound.NoAudioSound#removeMarker
|
||||||
{
|
* @since 3.0.0
|
||||||
return null;
|
*
|
||||||
},
|
* @param {string} markerName - The name of the marker to remove.
|
||||||
|
*
|
||||||
|
* @return {null} null
|
||||||
|
*/
|
||||||
|
removeMarker: returnNull,
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
/**
|
||||||
play: function (markerName, config)
|
* @method Phaser.Sound.NoAudioSound#play
|
||||||
{
|
* @since 3.0.0
|
||||||
return false;
|
*
|
||||||
},
|
* @param {(string|Phaser.Types.Sound.SoundConfig)} [markerName=''] - If you want to play a marker then provide the marker name here. Alternatively, this parameter can be a SoundConfig object.
|
||||||
|
* @param {Phaser.Types.Sound.SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound.
|
||||||
|
*
|
||||||
|
* @return {boolean} false
|
||||||
|
*/
|
||||||
|
play: returnFalse,
|
||||||
|
|
||||||
pause: function ()
|
/**
|
||||||
{
|
* @method Phaser.Sound.NoAudioSound#pause
|
||||||
return false;
|
* @since 3.0.0
|
||||||
},
|
*
|
||||||
|
* @return {boolean} false
|
||||||
|
*/
|
||||||
|
pause: returnFalse,
|
||||||
|
|
||||||
resume: function ()
|
/**
|
||||||
{
|
* Resumes the sound.
|
||||||
return false;
|
*
|
||||||
},
|
* @method Phaser.Sound.NoAudioSound#resume
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @return {boolean} false
|
||||||
|
*/
|
||||||
|
resume: returnFalse,
|
||||||
|
|
||||||
stop: function ()
|
/**
|
||||||
{
|
* Stop playing this sound.
|
||||||
return false;
|
*
|
||||||
},
|
* @method Phaser.Sound.NoAudioSound#stop
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @return {boolean} false
|
||||||
|
*/
|
||||||
|
stop: returnFalse,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destroys this sound and all associated events and marks it for removal from the sound manager.
|
||||||
|
*
|
||||||
|
* @method Phaser.Sound.NoAudioSound#destroy
|
||||||
|
* @fires Phaser.Sound.Events#DESTROY
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
destroy: function ()
|
destroy: function ()
|
||||||
{
|
{
|
||||||
this.manager.remove(this);
|
|
||||||
|
|
||||||
BaseSound.prototype.destroy.call(this);
|
BaseSound.prototype.destroy.call(this);
|
||||||
}
|
},
|
||||||
|
|
||||||
|
setMute: returnThis,
|
||||||
|
|
||||||
|
setVolume: returnThis,
|
||||||
|
|
||||||
|
setRate: returnThis,
|
||||||
|
|
||||||
|
setDetune: returnThis,
|
||||||
|
|
||||||
|
setSeek: returnThis,
|
||||||
|
|
||||||
|
setLoop: returnThis
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = NoAudioSound;
|
module.exports = NoAudioSound;
|
||||||
|
|
Loading…
Reference in a new issue