diff options
author | Chocobozzz <me@florianbigard.com> | 2018-03-29 16:01:50 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-04-03 12:06:28 +0200 |
commit | e993ecb3b761bba8fba2b8329270ae904bd3a0d7 (patch) | |
tree | 6950ae0d3facef3f552ef49361fbc05a9590fe0e /client/src/assets | |
parent | 779f000083145d8f1cc9b28205db53a5ead4bea5 (diff) | |
download | PeerTube-e993ecb3b761bba8fba2b8329270ae904bd3a0d7.tar.gz PeerTube-e993ecb3b761bba8fba2b8329270ae904bd3a0d7.tar.zst PeerTube-e993ecb3b761bba8fba2b8329270ae904bd3a0d7.zip |
Improve player progress bar
Diffstat (limited to 'client/src/assets')
-rw-r--r-- | client/src/assets/player/peertube-videojs-plugin.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts index 52846503d..4843e3d8a 100644 --- a/client/src/assets/player/peertube-videojs-plugin.ts +++ b/client/src/assets/player/peertube-videojs-plugin.ts | |||
@@ -408,6 +408,8 @@ class PeerTubePlugin extends Plugin { | |||
408 | } | 408 | } |
409 | 409 | ||
410 | private initializePlayer () { | 410 | private initializePlayer () { |
411 | this.initSmoothProgressBar() | ||
412 | |||
411 | if (this.autoplay === true) { | 413 | if (this.autoplay === true) { |
412 | this.updateVideoFile(undefined, () => this.player.play()) | 414 | this.updateVideoFile(undefined, () => this.player.play()) |
413 | } else { | 415 | } else { |
@@ -491,5 +493,27 @@ class PeerTubePlugin extends Plugin { | |||
491 | private disableErrorDisplay () { | 493 | private disableErrorDisplay () { |
492 | this.player.removeClass('vjs-error-display-enabled') | 494 | this.player.removeClass('vjs-error-display-enabled') |
493 | } | 495 | } |
496 | |||
497 | // Thanks: https://github.com/videojs/video.js/issues/4460#issuecomment-312861657 | ||
498 | private initSmoothProgressBar () { | ||
499 | const SeekBar = videojsUntyped.getComponent('SeekBar') | ||
500 | SeekBar.prototype.getPercent = function getPercent () { | ||
501 | // Allows for smooth scrubbing, when player can't keep up. | ||
502 | // const time = (this.player_.scrubbing()) ? | ||
503 | // this.player_.getCache().currentTime : | ||
504 | // this.player_.currentTime() | ||
505 | const time = this.player_.currentTime() | ||
506 | const percent = time / this.player_.duration() | ||
507 | return percent >= 1 ? 1 : percent | ||
508 | } | ||
509 | SeekBar.prototype.handleMouseMove = function handleMouseMove (event) { | ||
510 | let newTime = this.calculateDistance(event) * this.player_.duration() | ||
511 | if (newTime === this.player_.duration()) { | ||
512 | newTime = newTime - 0.1 | ||
513 | } | ||
514 | this.player_.currentTime(newTime) | ||
515 | this.update() | ||
516 | } | ||
517 | } | ||
494 | } | 518 | } |
495 | videojsUntyped.registerPlugin('peertube', PeerTubePlugin) | 519 | videojsUntyped.registerPlugin('peertube', PeerTubePlugin) |