Audio - Prevent repeated callbacks

This commit is contained in:
VisualSJ
2018-02-27 09:53:34 +08:00
parent 6c809263e6
commit 8f89d9dc32
+7
View File
@@ -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;