diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-31 09:51:51 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-31 09:51:51 +0200 |
commit | 77728efa627527a9f0f27010a597e8984d7a27f8 (patch) | |
tree | 487c4b5e90bba172b2d23499605f72f2cf28f207 /client/src/assets/player/peertube-load-progress-bar.ts | |
parent | 0bf1f2652382089c06434a7d297b638aad778b52 (diff) | |
download | PeerTube-77728efa627527a9f0f27010a597e8984d7a27f8.tar.gz PeerTube-77728efa627527a9f0f27010a597e8984d7a27f8.tar.zst PeerTube-77728efa627527a9f0f27010a597e8984d7a27f8.zip |
Fix player progress bar
Diffstat (limited to 'client/src/assets/player/peertube-load-progress-bar.ts')
-rw-r--r-- | client/src/assets/player/peertube-load-progress-bar.ts | 36 |
1 files changed, 36 insertions, 0 deletions
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 index 000000000..cc861c451 --- /dev/null +++ b/client/src/assets/player/peertube-load-progress-bar.ts | |||
@@ -0,0 +1,36 @@ | |||
1 | import * as Bitfield from 'bitfield' | ||
2 | import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' | ||
3 | |||
4 | const Component: VideoJSComponentInterface = videojsUntyped.getComponent('Component') | ||
5 | |||
6 | class PeerTubeLoadProgressBar extends Component { | ||
7 | |||
8 | constructor (player, options) { | ||
9 | super(player, options) | ||
10 | this.partEls_ = [] | ||
11 | this.on(player, 'progress', this.update) | ||
12 | } | ||
13 | |||
14 | createEl () { | ||
15 | return super.createEl('div', { | ||
16 | className: 'vjs-load-progress', | ||
17 | innerHTML: `<span class="vjs-control-text"><span>${this.localize('Loaded')}</span>: 0%</span>` | ||
18 | }) | ||
19 | } | ||
20 | |||
21 | dispose () { | ||
22 | this.partEls_ = null | ||
23 | |||
24 | super.dispose() | ||
25 | } | ||
26 | |||
27 | update () { | ||
28 | const torrent = this.player().peertube().getTorrent() | ||
29 | if (!torrent) return | ||
30 | |||
31 | this.el_.style.width = (torrent.progress * 100) + '%' | ||
32 | } | ||
33 | |||
34 | } | ||
35 | |||
36 | Component.registerComponent('PeerTubeLoadProgressBar', PeerTubeLoadProgressBar) | ||