@@ -5,13 +5,12 @@ var WebAudioSound = require('./WebAudioSound');
55var WebAudioSoundManager = new Class ( {
66 Extends : BaseSoundManager ,
77 initialize : function WebAudioSoundManager ( game ) {
8- BaseSoundManager . call ( this , game ) ;
98 /**
109 * The AudioContext being used for playback.
1110 *
1211 * @property {AudioContext } context
1312 */
14- this . context = this . createAudioContext ( ) ;
13+ this . context = this . createAudioContext ( game ) ;
1514 /**
1615 * [description]
1716 *
@@ -25,9 +24,10 @@ var WebAudioSoundManager = new Class({
2524 */
2625 this . destination = this . masterVolumeNode ;
2726 this . masterVolumeNode . connect ( this . context . destination ) ;
27+ BaseSoundManager . call ( this , game ) ;
2828 } ,
29- createAudioContext : function ( ) {
30- var audioConfig = this . game . config . audio ;
29+ createAudioContext : function ( game ) {
30+ var audioConfig = game . config . audio ;
3131 if ( audioConfig && audioConfig . context ) {
3232 return audioConfig . context ;
3333 }
@@ -39,4 +39,16 @@ var WebAudioSoundManager = new Class({
3939 return sound ;
4040 }
4141} ) ;
42+ /**
43+ * Global volume setting.
44+ * @property {number } volume
45+ */
46+ Object . defineProperty ( WebAudioSoundManager . prototype , 'volume' , {
47+ get : function ( ) {
48+ return this . masterVolumeNode . gain . value ;
49+ } ,
50+ set : function ( value ) {
51+ this . masterVolumeNode . gain . value = value ;
52+ }
53+ } ) ;
4254module . exports = WebAudioSoundManager ;
0 commit comments