Skip to content

Commit 6451263

Browse files
committed
Merge pull request #2709 from VisualSJ/develop-audio
audioEngine not playing in Firefox, using minified/compiled lib
2 parents b3e1e9b + 936651b commit 6451263

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cocos2d/audio/CCAudio.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
* auto : Supports auto-play audio - if Don‘t support it, On a touch detecting background music canvas, and then replay
3333
* replay : The first music will fail, must be replay after touchstart
3434
* emptied : Whether to use the emptied event to replace load callback
35+
* delay : delay created the context object - only webAudio
3536
*
3637
* May be modifications for a few browser version
3738
*/
@@ -48,7 +49,7 @@
4849
// ANDROID //
4950
supportTable[sys.BROWSER_TYPE_ANDROID] = {multichannel: false, webAudio: false, auto: false};
5051
supportTable[sys.BROWSER_TYPE_CHROME] = {multichannel: true , webAudio: true , auto: false};
51-
supportTable[sys.BROWSER_TYPE_FIREFOX] = {multichannel: true , webAudio: true , auto: true };
52+
supportTable[sys.BROWSER_TYPE_FIREFOX] = {multichannel: true , webAudio: true , auto: true , delay: true};
5253
supportTable[sys.BROWSER_TYPE_UC] = {multichannel: true , webAudio: false, auto: false};
5354
supportTable[sys.BROWSER_TYPE_QQ] = {multichannel: false, webAudio: false, auto: true };
5455
supportTable[sys.BROWSER_TYPE_OUPENG] = {multichannel: false, webAudio: false, auto: false, replay: true , emptied: true };
@@ -476,6 +477,8 @@ cc.Audio = cc.Class.extend({
476477
try{
477478
if(SWA){
478479
var context = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)();
480+
if(polyfill.delay)
481+
setTimeout(function(){ context = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)(); }, 0);
479482
}
480483
}catch(error){
481484
SWA = false;

0 commit comments

Comments
 (0)