diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index e86787a786..12175071e6 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -85,8 +85,17 @@ Audio.State = { (function (proto) { proto.preload = function () { - var src = this._src, - audio = this; + var src = this._src, audio = this; + + if (!src) { + this._src = ''; + this._audioType = Audio.Type.UNKNOWN; + this._element = null; + this._state = Audio.State.INITIALZING; + this._loaded = false; + return; + } + var item = cc.loader.getItem(src); if (!item) { diff --git a/cocos2d/core/components/CCAudioSource.js b/cocos2d/core/components/CCAudioSource.js index 91d2cd5a44..37da741dd2 100644 --- a/cocos2d/core/components/CCAudioSource.js +++ b/cocos2d/core/components/CCAudioSource.js @@ -41,7 +41,11 @@ var AudioSource = cc.Class({ }, ctor: function () { - this.audio = new cc.Audio(this._clip); + this.audio = new cc.Audio(); + }, + + onLoad: function () { + this.clip = this._clip; }, properties: {