Fix player progress bar
authorChocobozzz <me@florianbigard.com>
Thu, 31 May 2018 07:51:51 +0000 (09:51 +0200)
committerChocobozzz <me@florianbigard.com>
Thu, 31 May 2018 07:51:51 +0000 (09:51 +0200)
client/src/assets/player/peertube-load-progress-bar.ts [new file with mode: 0644]
client/src/assets/player/peertube-player.ts
client/src/assets/player/peertube-videojs-plugin.ts
client/src/sass/video-js-custom.scss

diff --git a/client/src/assets/player/peertube-load-progress-bar.ts b/client/src/assets/player/peertube-load-progress-bar.ts
new file mode 100644 (file)
index 0000000..cc861c4
--- /dev/null
@@ -0,0 +1,36 @@
+import * as Bitfield from 'bitfield'
+import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
+
+const Component: VideoJSComponentInterface = videojsUntyped.getComponent('Component')
+
+class PeerTubeLoadProgressBar extends Component {
+
+  constructor (player, options) {
+    super(player, options)
+    this.partEls_ = []
+    this.on(player, 'progress', this.update)
+  }
+
+  createEl () {
+    return super.createEl('div', {
+      className: 'vjs-load-progress',
+      innerHTML: `<span class="vjs-control-text"><span>${this.localize('Loaded')}</span>: 0%</span>`
+    })
+  }
+
+  dispose () {
+    this.partEls_ = null
+
+    super.dispose()
+  }
+
+  update () {
+    const torrent = this.player().peertube().getTorrent()
+    if (!torrent) return
+
+    this.el_.style.width = (torrent.progress * 100) + '%'
+  }
+
+}
+
+Component.registerComponent('PeerTubeLoadProgressBar', PeerTubeLoadProgressBar)
index 9fe5af5692a425e7d73bbe984ed3b654d117faed..d204b9703ea5094a89be8f1f36c1c5f5d7102b9b 100644 (file)
@@ -9,6 +9,7 @@ import './resolution-menu-button'
 import './settings-menu-button'
 import './webtorrent-info-button'
 import './peertube-videojs-plugin'
+import './peertube-load-progress-bar'
 import { videojsUntyped } from './peertube-videojs-typings'
 import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils'
 
@@ -94,7 +95,16 @@ function getControlBarChildren (options: {
     'liveDisplay': {},
 
     'flexibleWidthSpacer': {},
-    'progressControl': {},
+    'progressControl': {
+      children: {
+        'seekBar': {
+          children: {
+            'peerTubeLoadProgressBar': {},
+            'playProgressBar': {}
+          }
+        }
+      }
+    },
 
     'webTorrentButton': {},
 
index 65103f3ab732bc99586eb5ca6b3564285ce82417..79df42a533783f81269f1746a49bb8c75b8f7139 100644 (file)
@@ -272,6 +272,10 @@ class PeerTubePlugin extends Plugin {
     return this.currentVideoFile
   }
 
+  getTorrent () {
+    return this.torrent
+  }
+
   private tryToPlay (done?: Function) {
     if (!done) done = function () { /* empty */ }
 
index 350e7cdd589814c5de5c87d7b31a43a5a48186bd..64805a3a154ee44fd549d82b508882cf24ba8896 100644 (file)
@@ -130,39 +130,6 @@ $context-menu-width: 350px;
     background-color: rgba($primary-background-color, 0.5);
   }
 
-  .vjs-slider {
-    background-color: rgba(255, 255, 255, .3);
-    border-radius: 2px;
-    height: 5px;
-
-    .vjs-slider-bar {
-      background: $primary-foreground-color;
-    }
-  }
-
-  .vjs-play-progress {
-
-    &::before {
-      top: -0.3em;
-
-      &:hover {
-        top: -0.372em;
-      }
-    }
-
-    .vjs-time-tooltip {
-      display: none;
-    }
-  }
-
-  .vjs-load-progress {
-    background: rgba($slider-bg-color, 0.5);
-
-    div {
-      background: rgba($slider-bg-color, 0.75);
-    }
-  }
-
   .vjs-poster {
     outline: none; /* Remove Blue Outline on Click*/
     outline: 0;
@@ -197,6 +164,37 @@ $context-menu-width: 350px;
       opacity: $primary-foreground-opacity;
     }
 
+    .vjs-slider {
+      background-color: rgba(255, 255, 255, .2);
+      border-radius: 2px;
+      height: 5px;
+
+      .vjs-slider-bar {
+        background: $primary-foreground-color;
+      }
+    }
+
+    .vjs-play-progress {
+
+      &::before {
+        top: -0.3em;
+
+        &:hover {
+          top: -0.372em;
+        }
+      }
+
+      .vjs-time-tooltip {
+        display: none;
+      }
+    }
+
+    .vjs-load-progress {
+      &, & div {
+        background: rgba(255, 255, 255, .2);
+      }
+    }
+
     .vjs-progress-control {
       bottom: 34px;
       width: 100%;