diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-11 11:52:34 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-02-11 11:52:34 +0100 |
commit | 88108880bbdba473cfe36ecbebc1c3c4f972e102 (patch) | |
tree | b242efb3b4f0d7e49d88f2d1f2063b5b3b0489c0 /client/src/assets/player/videojs-components/peertube-load-progress-bar.ts | |
parent | 53a94c7cfa8368da4cd248d65df8346905938f0c (diff) | |
parent | 9b712a2017e4ab3cf12cd6bd58278905520159d0 (diff) | |
download | PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.gz PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.tar.zst PeerTube-88108880bbdba473cfe36ecbebc1c3c4f972e102.zip |
Merge branch 'develop' into pr/1217
Diffstat (limited to 'client/src/assets/player/videojs-components/peertube-load-progress-bar.ts')
-rw-r--r-- | client/src/assets/player/videojs-components/peertube-load-progress-bar.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/client/src/assets/player/videojs-components/peertube-load-progress-bar.ts b/client/src/assets/player/videojs-components/peertube-load-progress-bar.ts new file mode 100644 index 000000000..9a0e3b550 --- /dev/null +++ b/client/src/assets/player/videojs-components/peertube-load-progress-bar.ts | |||
@@ -0,0 +1,38 @@ | |||
1 | import { VideoJSComponentInterface, videojsUntyped } from '../peertube-videojs-typings' | ||
2 | // FIXME: something weird with our path definition in tsconfig and typings | ||
3 | // @ts-ignore | ||
4 | import { Player } from 'video.js' | ||
5 | |||
6 | const Component: VideoJSComponentInterface = videojsUntyped.getComponent('Component') | ||
7 | |||
8 | class PeerTubeLoadProgressBar extends Component { | ||
9 | |||
10 | constructor (player: Player, options: any) { | ||
11 | super(player, options) | ||
12 | this.partEls_ = [] | ||
13 | this.on(player, 'progress', this.update) | ||
14 | } | ||
15 | |||
16 | createEl () { | ||
17 | return super.createEl('div', { | ||
18 | className: 'vjs-load-progress', | ||
19 | innerHTML: `<span class="vjs-control-text"><span>${this.localize('Loaded')}</span>: 0%</span>` | ||
20 | }) | ||
21 | } | ||
22 | |||
23 | dispose () { | ||
24 | this.partEls_ = null | ||
25 | |||
26 | super.dispose() | ||
27 | } | ||
28 | |||
29 | update () { | ||
30 | const torrent = this.player().webtorrent().getTorrent() | ||
31 | if (!torrent) return | ||
32 | |||
33 | this.el_.style.width = (torrent.progress * 100) + '%' | ||
34 | } | ||
35 | |||
36 | } | ||
37 | |||
38 | Component.registerComponent('PeerTubeLoadProgressBar', PeerTubeLoadProgressBar) | ||