Skip to content

Commit

Permalink
fix: don't notify the number of seconds moved after operating the see…
Browse files Browse the repository at this point in the history
…k bar
  • Loading branch information
tsukumijima committed Feb 12, 2025
1 parent d2141ef commit 8495676
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/ts/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Controller {
this.mobileBackwardTime += 10;
this.player.seek(this.player.video.currentTime - 10);
if (this.player.options.lang.includes('ja')) {
this.player.notice(`${this.mobileBackwardTime.toFixed(0)} 秒早戻し`);
this.player.notice(`${this.mobileBackwardTime.toFixed(0)}秒早戻し`);
} else {
this.player.notice(`${this.player.tran('REW')} ${this.mobileBackwardTime.toFixed(0)} ${this.player.tran('s')}`);
}
Expand All @@ -99,7 +99,7 @@ class Controller {
this.mobileForwardTime += 10;
this.player.seek(this.player.video.currentTime + 10);
if (this.player.options.lang.includes('ja')) {
this.player.notice(`${this.mobileForwardTime.toFixed(0)} 秒早送り`);
this.player.notice(`${this.mobileForwardTime.toFixed(0)}秒早送り`);
} else {
this.player.notice(`${this.player.tran('FF')} ${this.mobileForwardTime.toFixed(0)} ${this.player.tran('s')}`);
}
Expand Down Expand Up @@ -192,7 +192,7 @@ class Controller {
percentage = Math.min(percentage, 1);
this.player.bar.set('played', percentage, 'width');
const duration = utils.getVideoDuration(this.player.video, this.player.template);
this.player.seek(this.player.bar.get('played') * duration);
this.player.seek(this.player.bar.get('played') * duration, true); // hide notice
if (!paused) {
this.player.video.play();
}
Expand Down
26 changes: 14 additions & 12 deletions src/ts/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,23 +206,25 @@ class DPlayer {
/**
* Seek video
*/
seek(time: number): void {
seek(time: number, hideNotice = false): void {
time = Math.max(time, 0);
const duration = utils.getVideoDuration(this.video, this.template);
if (duration) {
time = Math.min(time, duration);
}
if (this.video.currentTime < time) {
if (this.options.lang.includes('ja')) {
this.notice(`${(time - this.video.currentTime).toFixed(0)} 秒早送り`);
} else {
this.notice(`${this.tran('FF')} ${(time - this.video.currentTime).toFixed(0)} ${this.tran('s')}`);
}
} else if (this.video.currentTime > time) {
if (this.options.lang.includes('ja')) {
this.notice(`${(this.video.currentTime - time).toFixed(0)} 秒早戻し`);
} else {
this.notice(`${this.tran('REW')} ${(this.video.currentTime - time).toFixed(0)} ${this.tran('s')}`);
if (!hideNotice) {
if (this.video.currentTime < time) {
if (this.options.lang.includes('ja')) {
this.notice(`${(time - this.video.currentTime).toFixed(0)}秒早送り`);
} else {
this.notice(`${this.tran('FF')} ${(time - this.video.currentTime).toFixed(0)} ${this.tran('s')}`);
}
} else if (this.video.currentTime > time) {
if (this.options.lang.includes('ja')) {
this.notice(`${(this.video.currentTime - time).toFixed(0)}秒早戻し`);
} else {
this.notice(`${this.tran('REW')} ${(this.video.currentTime - time).toFixed(0)} ${this.tran('s')}`);
}
}
}

Expand Down

0 comments on commit 8495676

Please sign in to comment.