mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
#5920 Audio preload error
This commit is contained in:
@@ -127,6 +127,14 @@ Audio.State = {
|
||||
}
|
||||
};
|
||||
|
||||
proto.unmount = function () {
|
||||
this._src = '';
|
||||
this._audioType = Audio.Type.UNKNOWN;
|
||||
this._element = null;
|
||||
this._state = Audio.State.INITIALZING;
|
||||
this._loaded = false;
|
||||
};
|
||||
|
||||
proto.mount = function (elem) {
|
||||
if (elem instanceof HTMLElement) {
|
||||
this._element = document.createElement('audio');
|
||||
|
||||
@@ -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: {
|
||||
@@ -93,8 +97,12 @@ var AudioSource = cc.Class({
|
||||
this._clip = value;
|
||||
this.audio.stop();
|
||||
this.audio.src = this._clip;
|
||||
if (this.audio.preload) {
|
||||
this.audio.preload();
|
||||
if (value) {
|
||||
if (this.audio.preload) {
|
||||
this.audio.preload();
|
||||
}
|
||||
} else {
|
||||
this.audio.unmount();
|
||||
}
|
||||
},
|
||||
url: cc.AudioClip,
|
||||
|
||||
Reference in New Issue
Block a user