From ab8c98676e3e62917c1c440dbc1b3cf285569997 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Tue, 16 Jun 2015 14:28:46 +0100 Subject: [PATCH] Sound.resume wouldn't properly restart looped sounds in Chrome after being paused. Phaser now specifically handles the Chrome 42 bug and later fix (thanks @nkovacs #1820) --- README.md | 2 +- src/sound/Sound.js | 17 ++++++++++++++++- typescript/phaser.d.ts | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9a1fb8102..a96b617fe 100644 --- a/README.md +++ b/README.md @@ -383,7 +383,7 @@ Version 2.4 - "Katar" - in dev * Tween.to and Tween.from can now accept `null` as the ease parameter value. If `null` it will use the default tween, as per the documentation (thanks @nkovacs #1817) * TilemapParser.parseTiledJSON would ignore 'falsey' properties set on Objects in Tiled JSON tilemaps, such as `x: 0` or `visible: false`. These properties are now accurately copied over to the destination map data (thanks @MaksJS #1818) * Removed un-necessary PIXI.TextureCache pollution in Phaser.LoaderParser.bitmapFont. -* +* Sound.resume wouldn't properly restart looped sounds in Chrome after being paused. Phaser now specifically handles the Chrome 42 bug and later fix (thanks @nkovacs #1820) For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md). diff --git a/src/sound/Sound.js b/src/sound/Sound.js index 45998eaf0..28433fc77 100644 --- a/src/sound/Sound.js +++ b/src/sound/Sound.js @@ -804,7 +804,22 @@ Phaser.Sound.prototype = { } else { - this._sound.start(0, p, duration); + if (this.loop && this.game.device.chrome) + { + // Handle chrome bug: https://code.google.com/p/chromium/issues/detail?id=457099 + if (this.game.device.chromeVersion === 42) + { + this._sound.start(0); + } + else + { + this._sound.start(0, p); + } + } + else + { + this._sound.start(0, p, duration); + } } } else diff --git a/typescript/phaser.d.ts b/typescript/phaser.d.ts index 73b786e0f..e338e86fa 100644 --- a/typescript/phaser.d.ts +++ b/typescript/phaser.d.ts @@ -654,6 +654,7 @@ declare module Phaser { canvas: boolean; chrome: boolean; chromeOS: boolean; + chromeVersion: number; cocoonJS: boolean; cocoonJSApp: boolean; cordova: boolean;