Skip to content

Commit c51a07f

Browse files
author
SeanLin
committed
Merge pull request cocos2d#499 from ShengxiangChen/issue1195_CocosDenshionTest
fixed cocos2d#1195 audio bug
2 parents aa8ded9 + bfcae48 commit c51a07f

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

CocosDenshion/SimpleAudioEngine.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,12 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
315315
this._effectsVolume = volume;
316316
}
317317
if (this._audioList) {
318+
var au;
318319
for (var i in this._audioList) {
319-
this._audioList[i].volume = this._effectsVolume;
320+
au = this._audioList[i];
321+
if(au){
322+
au.volume = this._effectsVolume;
323+
}
320324
}
321325
}
322326
},
@@ -359,8 +363,12 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
359363
*/
360364
pauseAllEffects:function () {
361365
if (this._audioList) {
366+
var au;
362367
for (var i in this._audioList) {
363-
this._audioList[i].pause();
368+
au = this._audioList[i];
369+
if(au){
370+
au.pause();
371+
}
364372
}
365373
}
366374
},
@@ -386,8 +394,12 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
386394
*/
387395
resumeAllEffects:function () {
388396
if (this._audioList) {
397+
var au;
389398
for (var i in this._audioList) {
390-
this._audioList[i].play();
399+
au = this._audioList[i];
400+
if(au){
401+
au.play();
402+
}
391403
}
392404
}
393405
},
@@ -414,9 +426,13 @@ cc.AudioEngine = cc.Class.extend(/** @lends cc.AudioEngine# */{
414426
*/
415427
stopAllEffects:function () {
416428
if (this._audioList) {
429+
var au;
417430
for (var i in this._audioList) {
418-
this._audioList[i].pause();
419-
this._audioList[i].currentTime = 0;
431+
au = this._audioList[i];
432+
if(au){
433+
au.pause();
434+
au.currentTime = 0;
435+
}
420436
}
421437
}
422438
},

0 commit comments

Comments
 (0)