mirror of
https://github.com/photonstorm/phaser
synced 2024-11-28 07:31:11 +00:00
defined volume property on WebAudioSoundManager prototype
This commit is contained in:
parent
3820e75a5a
commit
e5a5ee847f
1 changed files with 16 additions and 4 deletions
|
@ -5,13 +5,12 @@ var WebAudioSound = require('./WebAudioSound');
|
||||||
var WebAudioSoundManager = new Class({
|
var WebAudioSoundManager = new Class({
|
||||||
Extends: BaseSoundManager,
|
Extends: BaseSoundManager,
|
||||||
initialize: function WebAudioSoundManager(game) {
|
initialize: function WebAudioSoundManager(game) {
|
||||||
BaseSoundManager.call(this, game);
|
|
||||||
/**
|
/**
|
||||||
* The AudioContext being used for playback.
|
* The AudioContext being used for playback.
|
||||||
*
|
*
|
||||||
* @property {AudioContext} context
|
* @property {AudioContext} context
|
||||||
*/
|
*/
|
||||||
this.context = this.createAudioContext();
|
this.context = this.createAudioContext(game);
|
||||||
/**
|
/**
|
||||||
* [description]
|
* [description]
|
||||||
*
|
*
|
||||||
|
@ -25,9 +24,10 @@ var WebAudioSoundManager = new Class({
|
||||||
*/
|
*/
|
||||||
this.destination = this.masterVolumeNode;
|
this.destination = this.masterVolumeNode;
|
||||||
this.masterVolumeNode.connect(this.context.destination);
|
this.masterVolumeNode.connect(this.context.destination);
|
||||||
|
BaseSoundManager.call(this, game);
|
||||||
},
|
},
|
||||||
createAudioContext: function () {
|
createAudioContext: function (game) {
|
||||||
var audioConfig = this.game.config.audio;
|
var audioConfig = game.config.audio;
|
||||||
if (audioConfig && audioConfig.context) {
|
if (audioConfig && audioConfig.context) {
|
||||||
return audioConfig.context;
|
return audioConfig.context;
|
||||||
}
|
}
|
||||||
|
@ -39,4 +39,16 @@ var WebAudioSoundManager = new Class({
|
||||||
return sound;
|
return sound;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
/**
|
||||||
|
* Global volume setting.
|
||||||
|
* @property {number} volume
|
||||||
|
*/
|
||||||
|
Object.defineProperty(WebAudioSoundManager.prototype, 'volume', {
|
||||||
|
get: function () {
|
||||||
|
return this.masterVolumeNode.gain.value;
|
||||||
|
},
|
||||||
|
set: function (value) {
|
||||||
|
this.masterVolumeNode.gain.value = value;
|
||||||
|
}
|
||||||
|
});
|
||||||
module.exports = WebAudioSoundManager;
|
module.exports = WebAudioSoundManager;
|
||||||
|
|
Loading…
Reference in a new issue