33 * @copyright 2018 Photon Storm Ltd.
44 * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License }
55 */
6-
76var Class = require ( '../../utils/Class' ) ;
87var BaseSoundManager = require ( '../BaseSoundManager' ) ;
98var WebAudioSound = require ( './WebAudioSound' ) ;
@@ -22,12 +21,8 @@ var WebAudioSound = require('./WebAudioSound');
2221 * @param {Phaser.Game } game - Reference to the current game instance.
2322 */
2423var WebAudioSoundManager = new Class ( {
25-
2624 Extends : BaseSoundManager ,
27-
28- initialize :
29-
30- function WebAudioSoundManager ( game )
25+ initialize : function WebAudioSoundManager ( game )
3126 {
3227 /**
3328 * The AudioContext being used for playback.
@@ -58,7 +53,6 @@ var WebAudioSoundManager = new Class({
5853 * @since 3.0.0
5954 */
6055 this . masterVolumeNode = this . context . createGain ( ) ;
61-
6256 this . masterMuteNode . connect ( this . masterVolumeNode ) ;
6357 this . masterVolumeNode . connect ( this . context . destination ) ;
6458
@@ -71,9 +65,7 @@ var WebAudioSoundManager = new Class({
7165 * @since 3.0.0
7266 */
7367 this . destination = this . masterMuteNode ;
74-
7568 this . locked = this . context . state === 'suspended' && 'ontouchstart' in window ;
76-
7769 BaseSoundManager . call ( this , game ) ;
7870 } ,
7971
@@ -95,13 +87,11 @@ var WebAudioSoundManager = new Class({
9587 createAudioContext : function ( game )
9688 {
9789 var audioConfig = game . config . audio ;
98-
9990 if ( audioConfig && audioConfig . context )
10091 {
10192 audioConfig . context . resume ( ) ;
10293 return audioConfig . context ;
10394 }
104-
10595 return new AudioContext ( ) ;
10696 } ,
10797
@@ -119,9 +109,7 @@ var WebAudioSoundManager = new Class({
119109 add : function ( key , config )
120110 {
121111 var sound = new WebAudioSound ( this , key , config ) ;
122-
123112 this . sounds . push ( sound ) ;
124-
125113 return sound ;
126114 } ,
127115
@@ -137,7 +125,6 @@ var WebAudioSoundManager = new Class({
137125 unlock : function ( )
138126 {
139127 var _this = this ;
140-
141128 var unlock = function ( )
142129 {
143130 _this . context . resume ( ) . then ( function ( )
@@ -147,7 +134,6 @@ var WebAudioSoundManager = new Class({
147134 _this . unlocked = true ;
148135 } ) ;
149136 } ;
150-
151137 document . body . addEventListener ( 'touchstart' , unlock , false ) ;
152138 document . body . addEventListener ( 'touchend' , unlock , false ) ;
153139 } ,
@@ -197,14 +183,11 @@ var WebAudioSoundManager = new Class({
197183 this . context = null ;
198184 }
199185} ) ;
200-
201186Object . defineProperty ( WebAudioSoundManager . prototype , 'mute' , {
202-
203187 get : function ( )
204188 {
205189 return this . masterMuteNode . gain . value === 0 ;
206190 } ,
207-
208191 set : function ( value )
209192 {
210193 this . masterMuteNode . gain . setValueAtTime ( value ? 0 : 1 , 0 ) ;
@@ -216,16 +199,12 @@ Object.defineProperty(WebAudioSoundManager.prototype, 'mute', {
216199 */
217200 this . emit ( 'mute' , this , value ) ;
218201 }
219-
220202} ) ;
221-
222203Object . defineProperty ( WebAudioSoundManager . prototype , 'volume' , {
223-
224204 get : function ( )
225205 {
226206 return this . masterVolumeNode . gain . value ;
227207 } ,
228-
229208 set : function ( value )
230209 {
231210 this . masterVolumeNode . gain . setValueAtTime ( value , 0 ) ;
@@ -237,7 +216,5 @@ Object.defineProperty(WebAudioSoundManager.prototype, 'volume', {
237216 */
238217 this . emit ( 'volume' , this , value ) ;
239218 }
240-
241219} ) ;
242-
243220module . exports = WebAudioSoundManager ;
0 commit comments