Skip to content

Commit 57c602d

Browse files
added audio buffer property to WebAudioSound class
printing error if audio with provided key is not present in cache updating config duration property based on audio buffer duration
1 parent cae01aa commit 57c602d

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

v3/src/sound/WebAudioSound.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@ var BaseSound = require('./BaseSound');
44
var WebAudioSound = new Class({
55
Extends: BaseSound,
66
initialize: function WebAudioSound(manager, key, config) {
7-
// TODO update config duration
7+
/**
8+
* [description]
9+
*
10+
* @property {AudioBuffer} audioBuffer
11+
*/
12+
this.audioBuffer = this.manager.game.cache.audio.get(key);
13+
if (!this.audioBuffer) {
14+
console.error('No audio loaded in cache with key: \'' + key + '\'!');
15+
return;
16+
}
17+
config.duration = this.audioBuffer.duration;
818
BaseSound.call(this, manager, key, config);
919
}
1020
});

0 commit comments

Comments
 (0)