Skip to content

Commit a4eac00

Browse files
committed
Merge branch 'master' of https://github.com/photonstorm/phaser
2 parents 97efeff + 8bc6979 commit a4eac00

4 files changed

Lines changed: 78 additions & 20 deletions

File tree

v3/src/sound/BaseSound.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
var Class = require('../utils/Class');
2+
var Extend = require('../utils/object/Extend');
3+
var EventDispatcher = require('../events/EventDispatcher');
4+
// Phaser.Sound.BaseSound
5+
var BaseSound = new Class({
6+
initialize: function BaseSound(manager, key, config) {
7+
/**
8+
* Local reference to sound manager.
9+
* @property {Phaser.Sound.BaseSoundManager} manager
10+
*/
11+
this.manager = manager;
12+
this.key = key;
13+
this.config = Extend({
14+
mute: false,
15+
volume: 1,
16+
rate: 1,
17+
seek: 0,
18+
loop: false,
19+
pan: 0,
20+
duration: 0 // TODO set duration to correct value
21+
}, config);
22+
this.isPlaying = false;
23+
this.markers = {};
24+
this.currentMarker = '';
25+
this.fadeTween = null; // TODO see how to use global tween
26+
this.mute = false;
27+
this.volume = 1;
28+
this.rate = 1;
29+
this.seek = 0;
30+
this.loop = false;
31+
this.pan = 0;
32+
this.events = new EventDispatcher();
33+
},
34+
addMarker: function (marker) {
35+
return false;
36+
},
37+
removeMarker: function (markerName) {
38+
return false;
39+
},
40+
play: function (marker, config) {
41+
return this;
42+
},
43+
pause: function () {
44+
return this;
45+
},
46+
resume: function () {
47+
return this;
48+
},
49+
stop: function () {
50+
return this;
51+
},
52+
fadeTo: function (volume, duration) {
53+
return null;
54+
},
55+
update: function () {
56+
},
57+
destroy: function () {
58+
}
59+
});
60+
module.exports = BaseSound;

v3/src/sound/WebAudioSound.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var Class = require('../utils/Class');
2+
var BaseSound = require('./BaseSound');
3+
// Phaser.Sound.WebAudioSound
4+
var WebAudioSound = new Class({
5+
Extends: BaseSound,
6+
initialize: function WebAudioSound(manager, key, config) {
7+
// TODO update config duration
8+
BaseSound.call(this, manager, key, config);
9+
}
10+
});
11+
module.exports = WebAudioSound;
Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,22 @@
11
var Class = require('../utils/Class');
22
var BaseSoundManager = require('./BaseSoundManager');
3-
43
// Phaser.Loader.WebAudioSoundManager
5-
64
var WebAudioSoundManager = new Class({
7-
85
Extends: BaseSoundManager,
9-
10-
initialize:
11-
12-
function WebAudioSoundManager (game)
13-
{
14-
BaseSoundManager.call(this, game);
15-
6+
initialize: function WebAudioSoundManager(game) {
167
/**
178
* @property {AudioContext} context - The AudioContext being used for playback.
189
* @default
1910
*/
2011
this.context = this.createAudioContext();
12+
BaseSoundManager.call(this, game);
2113
},
22-
23-
createAudioContext: function ()
24-
{
14+
createAudioContext: function () {
2515
var audioConfig = this.game.config.audio;
26-
27-
if (audioConfig && audioConfig.context)
28-
{
16+
if (audioConfig && audioConfig.context) {
2917
return audioConfig.context;
3018
}
31-
3219
return new (window['AudioContext'] || window['webkitAudioContext'])();
3320
}
34-
3521
});
36-
3722
module.exports = WebAudioSoundManager;

v3/src/sound/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ module.exports = {
55
Dynamic: require('./dynamic'),
66

77
BaseSoundManager: require('./BaseSoundManager'),
8-
WebAudioSoundManager: require('./WebAudioSoundManager')
8+
WebAudioSoundManager: require('./WebAudioSoundManager'),
9+
10+
BaseSound: require('./BaseSound')
911

1012
};

0 commit comments

Comments
 (0)