diff options
Diffstat (limited to 'client/src/assets/player/peertube-plugin.ts')
-rw-r--r-- | client/src/assets/player/peertube-plugin.ts | 38 |
1 files changed, 2 insertions, 36 deletions
diff --git a/client/src/assets/player/peertube-plugin.ts b/client/src/assets/player/peertube-plugin.ts index b4841b235..9b4dc9bd5 100644 --- a/client/src/assets/player/peertube-plugin.ts +++ b/client/src/assets/player/peertube-plugin.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | import './videojs-components/settings-menu-button' | ||
2 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
3 | import { timeToInt } from '@shared/core-utils' | 2 | import { timeToInt } from '@shared/core-utils' |
4 | import { | 3 | import { |
@@ -10,7 +9,7 @@ import { | |||
10 | saveVideoWatchHistory, | 9 | saveVideoWatchHistory, |
11 | saveVolumeInStore | 10 | saveVolumeInStore |
12 | } from './peertube-player-local-storage' | 11 | } from './peertube-player-local-storage' |
13 | import { PeerTubePluginOptions, ResolutionUpdateData, UserWatching, VideoJSCaption } from './peertube-videojs-typings' | 12 | import { PeerTubePluginOptions, UserWatching, VideoJSCaption } from './peertube-videojs-typings' |
14 | import { isMobile } from './utils' | 13 | import { isMobile } from './utils' |
15 | 14 | ||
16 | const Plugin = videojs.getPlugin('plugin') | 15 | const Plugin = videojs.getPlugin('plugin') |
@@ -27,7 +26,6 @@ class PeerTubePlugin extends Plugin { | |||
27 | 26 | ||
28 | private videoViewInterval: any | 27 | private videoViewInterval: any |
29 | private userWatchingVideoInterval: any | 28 | private userWatchingVideoInterval: any |
30 | private lastResolutionChange: ResolutionUpdateData | ||
31 | 29 | ||
32 | private isLive: boolean | 30 | private isLive: boolean |
33 | 31 | ||
@@ -54,22 +52,6 @@ class PeerTubePlugin extends Plugin { | |||
54 | this.player.ready(() => { | 52 | this.player.ready(() => { |
55 | const playerOptions = this.player.options_ | 53 | const playerOptions = this.player.options_ |
56 | 54 | ||
57 | if (options.mode === 'webtorrent') { | ||
58 | this.player.webtorrent().on('resolutionChange', (_: any, d: any) => this.handleResolutionChange(d)) | ||
59 | this.player.webtorrent().on('autoResolutionChange', (_: any, d: any) => this.trigger('autoResolutionChange', d)) | ||
60 | } | ||
61 | |||
62 | if (options.mode === 'p2p-media-loader') { | ||
63 | this.player.p2pMediaLoader().on('resolutionChange', (_: any, d: any) => this.handleResolutionChange(d)) | ||
64 | } | ||
65 | |||
66 | this.player.tech(true).on('loadedqualitydata', () => { | ||
67 | setTimeout(() => { | ||
68 | // Replay a resolution change, now we loaded all quality data | ||
69 | if (this.lastResolutionChange) this.handleResolutionChange(this.lastResolutionChange) | ||
70 | }, 0) | ||
71 | }) | ||
72 | |||
73 | const volume = getStoredVolume() | 55 | const volume = getStoredVolume() |
74 | if (volume !== undefined) this.player.volume(volume) | 56 | if (volume !== undefined) this.player.volume(volume) |
75 | 57 | ||
@@ -97,7 +79,7 @@ class PeerTubePlugin extends Plugin { | |||
97 | }) | 79 | }) |
98 | } | 80 | } |
99 | 81 | ||
100 | this.player.textTracks().on('change', () => { | 82 | this.player.textTracks().addEventListener('change', () => { |
101 | const showing = this.player.textTracks().tracks_.find(t => { | 83 | const showing = this.player.textTracks().tracks_.find(t => { |
102 | return t.kind === 'captions' && t.mode === 'showing' | 84 | return t.kind === 'captions' && t.mode === 'showing' |
103 | }) | 85 | }) |
@@ -216,22 +198,6 @@ class PeerTubePlugin extends Plugin { | |||
216 | return fetch(url, { method: 'PUT', body, headers }) | 198 | return fetch(url, { method: 'PUT', body, headers }) |
217 | } | 199 | } |
218 | 200 | ||
219 | private handleResolutionChange (data: ResolutionUpdateData) { | ||
220 | this.lastResolutionChange = data | ||
221 | |||
222 | const qualityLevels = this.player.qualityLevels() | ||
223 | |||
224 | for (let i = 0; i < qualityLevels.length; i++) { | ||
225 | if (qualityLevels[i].height === data.resolutionId) { | ||
226 | data.id = qualityLevels[i].id | ||
227 | break | ||
228 | } | ||
229 | } | ||
230 | |||
231 | console.log('Resolution changed.', data) | ||
232 | this.trigger('resolutionChange', data) | ||
233 | } | ||
234 | |||
235 | private listenControlBarMouse () { | 201 | private listenControlBarMouse () { |
236 | this.player.controlBar.on('mouseenter', () => { | 202 | this.player.controlBar.on('mouseenter', () => { |
237 | this.mouseInControlBar = true | 203 | this.mouseInControlBar = true |