From e5a5ee847fef16327e236d2f4a6b907344cd0bc0 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Wed, 15 Nov 2017 15:11:37 +0100 Subject: [PATCH] defined volume property on WebAudioSoundManager prototype --- v3/src/sound/WebAudioSoundManager.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/v3/src/sound/WebAudioSoundManager.js b/v3/src/sound/WebAudioSoundManager.js index 4009d519e..2c0c8469b 100644 --- a/v3/src/sound/WebAudioSoundManager.js +++ b/v3/src/sound/WebAudioSoundManager.js @@ -5,13 +5,12 @@ var WebAudioSound = require('./WebAudioSound'); var WebAudioSoundManager = new Class({ Extends: BaseSoundManager, initialize: function WebAudioSoundManager(game) { - BaseSoundManager.call(this, game); /** * The AudioContext being used for playback. * * @property {AudioContext} context */ - this.context = this.createAudioContext(); + this.context = this.createAudioContext(game); /** * [description] * @@ -25,9 +24,10 @@ var WebAudioSoundManager = new Class({ */ this.destination = this.masterVolumeNode; this.masterVolumeNode.connect(this.context.destination); + BaseSoundManager.call(this, game); }, - createAudioContext: function () { - var audioConfig = this.game.config.audio; + createAudioContext: function (game) { + var audioConfig = game.config.audio; if (audioConfig && audioConfig.context) { return audioConfig.context; } @@ -39,4 +39,16 @@ var WebAudioSoundManager = new Class({ 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;