diff options
Diffstat (limited to 'client/src/assets')
-rw-r--r-- | client/src/assets/player/peertube-load-progress-bar.ts | 36 | ||||
-rw-r--r-- | client/src/assets/player/peertube-player.ts | 12 | ||||
-rw-r--r-- | client/src/assets/player/peertube-videojs-plugin.ts | 4 |
3 files changed, 51 insertions, 1 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) | ||
diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts index 9fe5af569..d204b9703 100644 --- a/client/src/assets/player/peertube-player.ts +++ b/client/src/assets/player/peertube-player.ts | |||
@@ -9,6 +9,7 @@ import './resolution-menu-button' | |||
9 | import './settings-menu-button' | 9 | import './settings-menu-button' |
10 | import './webtorrent-info-button' | 10 | import './webtorrent-info-button' |
11 | import './peertube-videojs-plugin' | 11 | import './peertube-videojs-plugin' |
12 | import './peertube-load-progress-bar' | ||
12 | import { videojsUntyped } from './peertube-videojs-typings' | 13 | import { videojsUntyped } from './peertube-videojs-typings' |
13 | import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils' | 14 | import { buildVideoEmbed, buildVideoLink, copyToClipboard } from './utils' |
14 | 15 | ||
@@ -94,7 +95,16 @@ function getControlBarChildren (options: { | |||
94 | 'liveDisplay': {}, | 95 | 'liveDisplay': {}, |
95 | 96 | ||
96 | 'flexibleWidthSpacer': {}, | 97 | 'flexibleWidthSpacer': {}, |
97 | 'progressControl': {}, | 98 | 'progressControl': { |
99 | children: { | ||
100 | 'seekBar': { | ||
101 | children: { | ||
102 | 'peerTubeLoadProgressBar': {}, | ||
103 | 'playProgressBar': {} | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | }, | ||
98 | 108 | ||
99 | 'webTorrentButton': {}, | 109 | 'webTorrentButton': {}, |
100 | 110 | ||
diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts index 65103f3ab..79df42a53 100644 --- a/client/src/assets/player/peertube-videojs-plugin.ts +++ b/client/src/assets/player/peertube-videojs-plugin.ts | |||
@@ -272,6 +272,10 @@ class PeerTubePlugin extends Plugin { | |||
272 | return this.currentVideoFile | 272 | return this.currentVideoFile |
273 | } | 273 | } |
274 | 274 | ||
275 | getTorrent () { | ||
276 | return this.torrent | ||
277 | } | ||
278 | |||
275 | private tryToPlay (done?: Function) { | 279 | private tryToPlay (done?: Function) { |
276 | if (!done) done = function () { /* empty */ } | 280 | if (!done) done = function () { /* empty */ } |
277 | 281 | ||