From 936651b64728b8f5ba3d381aeca93a6d9c9be767 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Tue, 3 Mar 2015 14:01:06 +0800 Subject: [PATCH] audioEngine not playing in Firefox, using minified/compiled lib --- cocos2d/audio/CCAudio.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 4c4b565d32..de28710216 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -32,6 +32,7 @@ * auto : Supports auto-play audio - if Don‘t support it, On a touch detecting background music canvas, and then replay * replay : The first music will fail, must be replay after touchstart * emptied : Whether to use the emptied event to replace load callback + * delay : delay created the context object - only webAudio * * May be modifications for a few browser version */ @@ -48,7 +49,7 @@ // ANDROID // supportTable[sys.BROWSER_TYPE_ANDROID] = {multichannel: false, webAudio: false, auto: false}; supportTable[sys.BROWSER_TYPE_CHROME] = {multichannel: true , webAudio: true , auto: false}; - supportTable[sys.BROWSER_TYPE_FIREFOX] = {multichannel: true , webAudio: true , auto: true }; + supportTable[sys.BROWSER_TYPE_FIREFOX] = {multichannel: true , webAudio: true , auto: true , delay: true}; supportTable[sys.BROWSER_TYPE_UC] = {multichannel: true , webAudio: false, auto: false}; supportTable[sys.BROWSER_TYPE_QQ] = {multichannel: false, webAudio: false, auto: true }; supportTable[sys.BROWSER_TYPE_OUPENG] = {multichannel: false, webAudio: false, auto: false, replay: true , emptied: true }; @@ -476,6 +477,8 @@ cc.Audio = cc.Class.extend({ try{ if(SWA){ var context = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)(); + if(polyfill.delay) + setTimeout(function(){ context = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)(); }, 0); } }catch(error){ SWA = false;