From 0789ac178a8d0fdbbdd5432c2f1246d8d8ccdd94 Mon Sep 17 00:00:00 2001 From: VisualSJ Date: Wed, 19 Jul 2017 15:50:49 +0800 Subject: [PATCH] #6048 currentTime error --- cocos2d/audio/CCAudio.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/cocos2d/audio/CCAudio.js b/cocos2d/audio/CCAudio.js index 12175071e6..798c8d2660 100644 --- a/cocos2d/audio/CCAudio.js +++ b/cocos2d/audio/CCAudio.js @@ -228,7 +228,18 @@ Audio.State = { this._bindEnded(function () { this._bindEnded(); }.bind(this)); - this._element.currentTime = num; + try { + this._element.currentTime = num; + } catch (err) { + var _element = this._element; + if (_element.addEventListener) { + var func = function () { + _element.removeEventListener('loadedmetadata', func); + _element.currentTime = num; + }; + _element.addEventListener('loadedmetadata', func); + } + } }; proto.getCurrentTime = function () { return this._element ? this._element.currentTime : 0;