From a42f9fe6a836f87b73ffa37fa1abf309e1826d32 Mon Sep 17 00:00:00 2001 From: sinchang Date: Sat, 24 Jun 2017 10:34:49 +0800 Subject: [PATCH 1/2] fixed #85 --- src/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.js b/src/utils.js index 3afe74a..3aaa562 100644 --- a/src/utils.js +++ b/src/utils.js @@ -28,11 +28,11 @@ module.exports = { } } else { - while (current !== null && current !== this.element) { + while (current !== null && current !== element) { actualLeft += current.offsetLeft; current = current.offsetParent; } } return actualLeft - elementScrollLeft; }, -}; \ No newline at end of file +}; From c3adffb1ec7c5f13a9db19c6f80e3fbf89835884 Mon Sep 17 00:00:00 2001 From: sinchang Date: Sat, 24 Jun 2017 11:20:06 +0800 Subject: [PATCH 2/2] update switchVideo method --- src/DPlayer.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/DPlayer.js b/src/DPlayer.js index 89b1866..5c6a2c2 100644 --- a/src/DPlayer.js +++ b/src/DPlayer.js @@ -12,7 +12,7 @@ const isMobile = /mobile/i.test(window.navigator.userAgent); let index = 0; class DPlayer { - + /** * DPlayer constructor function * @@ -868,10 +868,10 @@ class DPlayer { ++readCount; if (err) { if (err.response) { - this.notice(err.response.msg); + this.notice(err.response.msg); } else { - this.notice('Request was unsuccessful: ' + err.status); + this.notice('Request was unsuccessful: ' + err.status); } results[i] = []; } @@ -1022,7 +1022,8 @@ class DPlayer { switchVideo (video, danmaku) { this.video.src = video.url; this.video.poster = video.pic ? video.pic : ''; - this.video.currentTime = 0; + this.video.current.setAttribute('poster', this.video.poster); + this.video.current.setAttribute('src', this.video.src); this.pause(); if (danmaku) { this.dan = []; @@ -1170,7 +1171,7 @@ class DPlayer { this.switchingQuality = true; this.quality = this.option.video.quality[index]; this.element.getElementsByClassName('dplayer-quality-icon')[0].innerHTML = this.quality.name; - + this.video.pause(); const videoHTML = html.video(false, null, this.option.screenshot, 'auto', this.quality.url); const videoEle = new DOMParser().parseFromString(videoHTML, 'text/html').body.firstChild; @@ -1189,7 +1190,7 @@ class DPlayer { } parent.removeChild(this.prevVideo.current); this.video.current.classList.add('dplayer-video-current'); - this.video.play(); + this.video.play(); this.prevVideo = null; this.notice(`${this.tran('Switched to')} ${this.quality.name} ${this.tran('quality')}`); this.switchingQuality = false;