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' ) ;
22var BaseSound = require ( './BaseSound' ) ;
3+ var Extend = require ( '../utils/object/Extend' ) ;
34// Phaser.Sound.WebAudioSound
45var WebAudioSound = new Class ( {
56 Extends : BaseSound ,
@@ -16,6 +17,27 @@ var WebAudioSound = new Class({
1617 }
1718 config . duration = this . audioBuffer . duration ;
1819 BaseSound . call ( this , manager , key , config ) ;
20+ } ,
21+ play : function ( marker , config ) {
22+ if ( marker === void 0 ) { marker = '' ; }
23+ if ( typeof marker !== 'string' ) {
24+ console . error ( 'Sound marker has to be a string!' ) ;
25+ return ;
26+ }
27+ if ( config ) {
28+ if ( ! marker ) {
29+ this . config = Extend ( this . config , config ) ;
30+ }
31+ else {
32+ this . markers [ marker ] . config = Extend ( this . markers [ marker ] . config , config ) ;
33+ }
34+ }
35+ var source = this . manager . context . createBufferSource ( ) ;
36+ // TODO assign config values to buffer source
37+ source . buffer = this . audioBuffer ;
38+ source . connect ( this . manager . context . destination ) ;
39+ source . start ( ) ;
40+ return this ;
1941 }
2042} ) ;
2143module . exports = WebAudioSound ;
You can’t perform that action at this time.
0 commit comments