Skip to content

Commit

Permalink
optimize seek marked words; change version link; fix loading checker
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Sep 14, 2017
1 parent 1ff8e0e commit 652c6dc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
2 changes: 1 addition & 1 deletion dist/DPlayer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/DPlayer.min.js.map

Large diffs are not rendered by default.

29 changes: 11 additions & 18 deletions src/DPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ class DPlayer {
// whether the video is buffering
currentPlayPos = this.video.currentTime;
if (!bufferingDetected
&& currentPlayPos < lastPlayPos + 0.01
&& currentPlayPos === lastPlayPos
&& !this.video.paused) {
this.element.classList.add('dplayer-loading');
bufferingDetected = true;
}
if (bufferingDetected
&& currentPlayPos > lastPlayPos + 0.01
&& currentPlayPos > lastPlayPos
&& !this.video.paused) {
this.element.classList.remove('dplayer-loading');
bufferingDetected = false;
Expand Down Expand Up @@ -231,16 +231,6 @@ class DPlayer {
}
};

pbar.addEventListener('click', (event) => {
const e = event || window.event;
barWidth = pbar.clientWidth;
let percentage = (e.clientX - utils.getElementViewLeft(pbar)) / barWidth;
percentage = percentage > 0 ? percentage : 0;
percentage = percentage < 1 ? percentage : 1;
this.updateBar('played', percentage, 'width');
this.seek(parseFloat(bar.playedBar.style.width) / 100 * this.video.duration);
});

if (this.option.video.thumbnails) {
this.initThumbnails();
}
Expand All @@ -251,18 +241,21 @@ class DPlayer {
pbar.addEventListener('mouseleave', this.mouseHandler);


const thumbMove = (event) => {
const e = event || window.event;
const thumbMove = (e) => {
let percentage = (e.clientX - utils.getElementViewLeft(pbar)) / barWidth;
percentage = percentage > 0 ? percentage : 0;
percentage = percentage < 1 ? percentage : 1;
this.updateBar('played', percentage, 'width');
this.element.getElementsByClassName('dplayer-ptime')[0].innerHTML = utils.secondToTime(percentage * this.video.duration);
};

const thumbUp = () => {
const thumbUp = (e) => {
document.removeEventListener('mouseup', thumbUp);
document.removeEventListener('mousemove', thumbMove);
let percentage = (e.clientX - utils.getElementViewLeft(pbar)) / barWidth;
percentage = percentage > 0 ? percentage : 0;
percentage = percentage < 1 ? percentage : 1;
this.updateBar('played', percentage, 'width');
this.seek(parseFloat(bar.playedBar.style.width) / 100 * this.video.duration);
this.setTime();
};
Expand Down Expand Up @@ -779,12 +772,12 @@ class DPlayer {
if (this.video.duration) {
time = Math.min(time, this.video.duration);
}

console.log(time, this.video.currentTime, time - this.video.currentTime);
if (this.video.currentTime < time) {
this.notice(`${this.tran('FF to')} ${utils.secondToTime(time)}`);
this.notice(`${this.tran('FF')} ${(time - this.video.currentTime).toFixed(0)} ${this.tran('s')}`);
}
else if (this.video.currentTime > time) {
this.notice(`${this.tran('REW to')} ${utils.secondToTime(time)}`);
this.notice(`${this.tran('REW')} ${(this.video.currentTime - time).toFixed(0)} ${this.tran('s')}`);
}

this.video.currentTime = time;
Expand Down
11 changes: 6 additions & 5 deletions src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ const tranTxt = {
'Switching to': '正在切换至',
'Switched to': '已经切换至',
'quality': '画质',
'FF to': '快进至',
'REW to': '快退至',
'FF': '快进',
'REW': '快退',
'Unlimited danmaku': '海量弹幕',
'Send danmaku': '发送弹幕',
'Setting': '设置',
'Full screen': '全屏',
'Web full screen': '页面全屏',
'Send': '发送',
'Screenshot': '截图'
'Screenshot': '截图',
's': '秒'
},
"zh-tw" : {
'Danmaku is loading': '彈幕加載中',
Expand All @@ -73,8 +74,8 @@ const tranTxt = {
'Switching to': '正在切換至',
'Switched to': '已經切換至',
'quality': '畫質',
'FF to': '快進至',
'REW to': '快退至',
'FF': '快進',
'REW': '快退',
'Unlimited danmaku': '海量彈幕'
}
};
2 changes: 1 addition & 1 deletion src/option.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = (option) => {
link: 'https://github.com/DIYgod/DPlayer/issues'
}, {
text: `DPlayer ${DPLAYER_VERSION} ${GIT_HASH}`,
link: 'https://github.com/MoePlayer/DPlayer/commits/master'
link: 'https://github.com/MoePlayer/DPlayer/releases'
}]);

return option;
Expand Down

0 comments on commit 652c6dc

Please sign in to comment.