Improve player progress bar

pull/489/head
Chocobozzz 2018-03-29 16:01:50 +02:00
parent 779f000083
commit e993ecb3b7
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 38 additions and 13 deletions

View File

@ -408,6 +408,8 @@ class PeerTubePlugin extends Plugin {
}
private initializePlayer () {
this.initSmoothProgressBar()
if (this.autoplay === true) {
this.updateVideoFile(undefined, () => this.player.play())
} else {
@ -491,5 +493,27 @@ class PeerTubePlugin extends Plugin {
private disableErrorDisplay () {
this.player.removeClass('vjs-error-display-enabled')
}
// Thanks: https://github.com/videojs/video.js/issues/4460#issuecomment-312861657
private initSmoothProgressBar () {
const SeekBar = videojsUntyped.getComponent('SeekBar')
SeekBar.prototype.getPercent = function getPercent () {
// Allows for smooth scrubbing, when player can't keep up.
// const time = (this.player_.scrubbing()) ?
// this.player_.getCache().currentTime :
// this.player_.currentTime()
const time = this.player_.currentTime()
const percent = time / this.player_.duration()
return percent >= 1 ? 1 : percent
}
SeekBar.prototype.handleMouseMove = function handleMouseMove (event) {
let newTime = this.calculateDistance(event) * this.player_.duration()
if (newTime === this.player_.duration()) {
newTime = newTime - 0.1
}
this.player_.currentTime(newTime)
this.update()
}
}
}
videojsUntyped.registerPlugin('peertube', PeerTubePlugin)

View File

@ -2,10 +2,15 @@
@import '_mixins';
$primary-foreground-color: #fff;
$primary-foreground-opacity: 0.9;
$primary-foreground-opacity-hover: 1;
$primary-background-color: #000;
$font-size: 13px;
$control-bar-height: 34px;
$slider-bg-color: lighten($primary-background-color, 33%);
.video-js.vjs-peertube-skin {
font-size: $font-size;
color: $primary-foreground-color;
@ -36,8 +41,6 @@ $control-bar-height: 34px;
line-height: $control-bar-height;
}
.vjs-mouse-display:before,
.vjs-play-progress:before,
.vjs-volume-level:before {
content: ''; /* Remove Circle From Progress Bar */
}
@ -96,28 +99,26 @@ $control-bar-height: 34px;
background-color: rgba($primary-background-color, 0.5);
}
$slider-bg-color: lighten($primary-background-color, 33%);
.vjs-slider {
background-color: rgba(255, 255, 255, .3);
border-radius: 2px;
height: 5px;
.vjs-slider-bar {
background: $primary-foreground-color;
}
}
/* The slider bar color is used for the progress bar and the volume bar
(the first two can be removed after a fix that's coming) */
.vjs-volume-level,
.vjs-play-progress,
.vjs-slider-bar {
background: $primary-foreground-color;
.vjs-play-progress .vjs-time-tooltip {
display: none;
}
.vjs-load-progress {
background: rgba($slider-bg-color, 0.5);
}
.vjs-load-progress div {
background: rgba($slider-bg-color, 0.75);
div {
background: rgba($slider-bg-color, 0.75);
}
}
.vjs-poster {