aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player')
-rw-r--r--client/src/assets/player/peertube-videojs-plugin.ts24
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}
495videojsUntyped.registerPlugin('peertube', PeerTubePlugin) 519videojsUntyped.registerPlugin('peertube', PeerTubePlugin)