File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11var Class = require ( '../utils/Class' ) ;
2+ var WebAudioSoundManager = require ( './WebAudioSoundManager' ) ;
23
34// Phaser.Loader.SoundManager
45
56var SoundManager = new Class ( {
67
7- initialize :
8-
9- function SoundManager ( game )
10- {
11-
12- }
8+ // TODO define sound manager interface
139
1410} ) ;
1511
@@ -24,8 +20,7 @@ SoundManager.create = function (game)
2420 if ( game . device . Audio . webAudio
2521 && ! ( game . config . audio && game . config . audio . disableWebAudio ) )
2622 {
27- // TODO create Web Audio sound manager
28- return new SoundManager ( game ) ;
23+ return new WebAudioSoundManager ( game ) ;
2924 }
3025
3126 // TODO return HTML5 Audio sound manager
Original file line number Diff line number Diff line change 1+ var Class = require ( '../utils/Class' ) ;
2+ var SoundManager = require ( './SoundManager' ) ;
3+
4+ var WebAudioSoundManager = new Class ( {
5+
6+ Extends : SoundManager ,
7+
8+ initialize :
9+
10+ function WebAudioSoundManager ( game )
11+ {
12+ /**
13+ * @property {Phaser.Game } game - Local reference to game.
14+ */
15+ this . game = game ;
16+
17+ /**
18+ * @property {AudioContext } context - The AudioContext being used for playback.
19+ * @default
20+ */
21+ this . context = this . createAudioContext ( ) ;
22+ } ,
23+
24+ createAudioContext : function ( )
25+ {
26+ if ( this . game . config . audio . context )
27+ {
28+ return this . game . config . audio . context ;
29+ }
30+
31+ return new ( window [ 'AudioContext' ] || window [ 'webkitAudioContext' ] ) ( ) ;
32+ }
33+
34+ } ) ;
35+
36+ module . exports = WebAudioSoundManager ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ module.exports = {
44
55 Dynamic : require ( './dynamic' ) ,
66
7- SoundManager : require ( './SoundManager' )
7+ SoundManager : require ( './SoundManager' ) ,
8+ WebAudioSoundManager : require ( './WebAudioSoundManager' )
89
910} ;
You can’t perform that action at this time.
0 commit comments