From 52118be088921be202b3208e46b16df4bae9f7e2 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Sun, 2 Mar 2014 11:11:20 +0000 Subject: [PATCH] Sound.onMarkerComplete event is now dispatched when a marker stops. See Sound.onLoop for a looping marker event (thanks registered99, fixes #500) --- README.md | 1 + src/sound/Sound.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c011d01..a1b93595 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,7 @@ Bug Fixes: * Loader.replaceInFileList wouldn't over-write the previous entry correctly, which caused the Loader.image overwrite parameter to fail (thanks basoko, fixes #493) * If the game was set to NO_SCALE and you swapped orientation, it would pause and resize, then fail to resize when you swapped back (thanks starnut, fixes #258) * Device no longer things a Windows Phone or Windows Tablet are desktop devices (thanks wombatbuddy, fixes #506) +* Sound.onMarkerComplete event is now dispatched when a marker stops. See Sound.onLoop for a looping marker event (thanks registered99, fixes #500) TO DO: diff --git a/src/sound/Sound.js b/src/sound/Sound.js index a69b1804..bdefe079 100644 --- a/src/sound/Sound.js +++ b/src/sound/Sound.js @@ -341,7 +341,7 @@ Phaser.Sound.prototype = { if (this.currentTime >= this.durationMS) { - console.log(this.currentMarker, 'has hit duration'); + // console.log(this.currentMarker, 'has hit duration'); if (this.usingWebAudio) { if (this.loop) @@ -359,6 +359,7 @@ Phaser.Sound.prototype = { else { // console.log('loop3'); + this.onMarkerComplete.dispatch(this.currentMarker, this); this.play(this.currentMarker, 0, this.volume, true, true); } } @@ -709,6 +710,11 @@ Phaser.Sound.prototype = { this.isPlaying = false; var prevMarker = this.currentMarker; + if (this.currentMarker !== '') + { + this.onMarkerComplete.dispatch(this.currentMarker, this); + } + this.currentMarker = ''; this.onStop.dispatch(this, prevMarker);