diff --git a/cocos2d/core/components/CCAudioSource.js b/cocos2d/core/components/CCAudioSource.js index 5f8080a0df..6481f3554f 100644 --- a/cocos2d/core/components/CCAudioSource.js +++ b/cocos2d/core/components/CCAudioSource.js @@ -5,11 +5,11 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated engine source code (the "Software"), a limited, - worldwide, royalty-free, non-assignable, revocable and non-exclusive license + worldwide, royalty-free, non-assignable, revocable and non-exclusive license to use Cocos Creator solely to develop games on your target platforms. You shall - not use Cocos Creator software for developing other software or tools that's - used for developing games. You are not granted to publish, distribute, - sublicense, and/or sell copies of Cocos Creator. + not use Cocos Creator software for developing other software or tools that's + used for developing games. You are not granted to publish, distribute, + sublicense, and/or sell copies of Cocos Creator. The software or tools in this License Agreement are licensed, not sold. Chukong Aipu reserves all rights not expressly granted to you. @@ -106,8 +106,7 @@ var AudioSource = cc.Class({ if (this.audio) { if (cc.sys.isNative) { cc.audioEngine.setEffectsVolume(value); - } - else { + } else { this.audio.setVolume(value); } } @@ -132,16 +131,13 @@ var AudioSource = cc.Class({ if (this._mute) { if (cc.sys.isNative) { cc.audioEngine.setEffectsVolume(0); - } - else { + } else { this.audio.setVolume(0); } - } - else { + } else { if (cc.sys.isNative) { cc.audioEngine.setEffectsVolume(this._volume); - } - else { + } else { this.audio.setVolume(this._volume); } } @@ -206,15 +202,11 @@ var AudioSource = cc.Class({ play: function () { if ( this._clip ) { var volume = this._mute ? 0 : this._volume; + this.audio = audioEngine.playEffect(this._clip, this._loop, volume); + if (cc.sys.isNative) { - audioEngine.playEffect(this._clip, this._loop); cc.audioEngine.setEffectsVolume(volume); } - else { - this.audio = audioEngine.playEffect(this._clip, this._loop); - if (this.audio) - this.audio.setVolume(volume); - } } },