mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
Audio - Prevent repeated callbacks
This commit is contained in:
@@ -44,6 +44,8 @@ var Audio = function (src) {
|
||||
this._state = Audio.State.INITIALZING;
|
||||
this._loaded = false;
|
||||
|
||||
this._preloadSrc = null;
|
||||
|
||||
this._onended = function () {
|
||||
this.emit('ended');
|
||||
}.bind(this);
|
||||
@@ -89,6 +91,11 @@ Audio.State = {
|
||||
proto.preload = function () {
|
||||
var src = this._src, audio = this;
|
||||
|
||||
if (this._preloadSrc === src) {
|
||||
return;
|
||||
}
|
||||
this._preloadSrc = src;
|
||||
|
||||
if (!src) {
|
||||
this._src = '';
|
||||
this._audioType = Audio.Type.UNKNOWN;
|
||||
|
||||
Reference in New Issue
Block a user