diff options
Diffstat (limited to 'client/src/assets')
-rw-r--r-- | client/src/assets/player/peertube-chunk-store.ts | 16 | ||||
-rw-r--r-- | client/src/assets/player/peertube-link-button.ts | 3 | ||||
-rw-r--r-- | client/src/assets/player/peertube-load-progress-bar.ts | 2 | ||||
-rw-r--r-- | client/src/assets/player/peertube-player.ts | 16 | ||||
-rw-r--r-- | client/src/assets/player/peertube-videojs-plugin.ts | 40 | ||||
-rw-r--r-- | client/src/assets/player/peertube-videojs-typings.ts | 6 | ||||
-rw-r--r-- | client/src/assets/player/resolution-menu-button.ts | 3 | ||||
-rw-r--r-- | client/src/assets/player/resolution-menu-item.ts | 5 | ||||
-rw-r--r-- | client/src/assets/player/settings-menu-button.ts | 18 | ||||
-rw-r--r-- | client/src/assets/player/settings-menu-item.ts | 11 | ||||
-rw-r--r-- | client/src/assets/player/theater-button.ts | 2 | ||||
-rw-r--r-- | client/src/assets/player/utils.ts | 2 | ||||
-rw-r--r-- | client/src/assets/player/video-renderer.ts | 18 | ||||
-rw-r--r-- | client/src/assets/player/webtorrent-info-button.ts | 2 |
14 files changed, 70 insertions, 74 deletions
diff --git a/client/src/assets/player/peertube-chunk-store.ts b/client/src/assets/player/peertube-chunk-store.ts index 767e46821..ac3f9e654 100644 --- a/client/src/assets/player/peertube-chunk-store.ts +++ b/client/src/assets/player/peertube-chunk-store.ts | |||
@@ -40,15 +40,15 @@ export class PeertubeChunkStore extends EventEmitter { | |||
40 | // If the store is full | 40 | // If the store is full |
41 | private memoryChunks: { [ id: number ]: Buffer | true } = {} | 41 | private memoryChunks: { [ id: number ]: Buffer | true } = {} |
42 | private databaseName: string | 42 | private databaseName: string |
43 | private putBulkTimeout | 43 | private putBulkTimeout: any |
44 | private cleanerInterval | 44 | private cleanerInterval: any |
45 | private db: ChunkDatabase | 45 | private db: ChunkDatabase |
46 | private expirationDB: ExpirationDatabase | 46 | private expirationDB: ExpirationDatabase |
47 | private readonly length: number | 47 | private readonly length: number |
48 | private readonly lastChunkLength: number | 48 | private readonly lastChunkLength: number |
49 | private readonly lastChunkIndex: number | 49 | private readonly lastChunkIndex: number |
50 | 50 | ||
51 | constructor (chunkLength: number, opts) { | 51 | constructor (chunkLength: number, opts: any) { |
52 | super() | 52 | super() |
53 | 53 | ||
54 | this.databaseName = 'webtorrent-chunks-' | 54 | this.databaseName = 'webtorrent-chunks-' |
@@ -113,13 +113,13 @@ export class PeertubeChunkStore extends EventEmitter { | |||
113 | }, PeertubeChunkStore.BUFFERING_PUT_MS) | 113 | }, PeertubeChunkStore.BUFFERING_PUT_MS) |
114 | } | 114 | } |
115 | 115 | ||
116 | get (index: number, opts, cb) { | 116 | get (index: number, opts: any, cb: any): any { |
117 | if (typeof opts === 'function') return this.get(index, null, opts) | 117 | if (typeof opts === 'function') return this.get(index, null, opts) |
118 | 118 | ||
119 | // IndexDB could be slow, use our memory index first | 119 | // IndexDB could be slow, use our memory index first |
120 | const memoryChunk = this.memoryChunks[index] | 120 | const memoryChunk = this.memoryChunks[index] |
121 | if (memoryChunk === undefined) { | 121 | if (memoryChunk === undefined) { |
122 | const err = new Error('Chunk not found') | 122 | const err = new Error('Chunk not found') as any |
123 | err['notFound'] = true | 123 | err['notFound'] = true |
124 | 124 | ||
125 | return process.nextTick(() => cb(err)) | 125 | return process.nextTick(() => cb(err)) |
@@ -146,11 +146,11 @@ export class PeertubeChunkStore extends EventEmitter { | |||
146 | }) | 146 | }) |
147 | } | 147 | } |
148 | 148 | ||
149 | close (db) { | 149 | close (db: any) { |
150 | return this.destroy(db) | 150 | return this.destroy(db) |
151 | } | 151 | } |
152 | 152 | ||
153 | async destroy (cb) { | 153 | async destroy (cb: any) { |
154 | try { | 154 | try { |
155 | if (this.pendingPut) { | 155 | if (this.pendingPut) { |
156 | clearTimeout(this.putBulkTimeout) | 156 | clearTimeout(this.putBulkTimeout) |
@@ -225,7 +225,7 @@ export class PeertubeChunkStore extends EventEmitter { | |||
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | private nextTick (cb, err, val?) { | 228 | private nextTick (cb: any, err: Error, val?: any) { |
229 | process.nextTick(() => cb(err, val), undefined) | 229 | process.nextTick(() => cb(err, val), undefined) |
230 | } | 230 | } |
231 | } | 231 | } |
diff --git a/client/src/assets/player/peertube-link-button.ts b/client/src/assets/player/peertube-link-button.ts index 715207bc0..b03952b47 100644 --- a/client/src/assets/player/peertube-link-button.ts +++ b/client/src/assets/player/peertube-link-button.ts | |||
@@ -1,11 +1,10 @@ | |||
1 | import * as videojs from 'video.js' | ||
2 | import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' | 1 | import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' |
3 | import { buildVideoLink } from './utils' | 2 | import { buildVideoLink } from './utils' |
4 | 3 | ||
5 | const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button') | 4 | const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button') |
6 | class PeerTubeLinkButton extends Button { | 5 | class PeerTubeLinkButton extends Button { |
7 | 6 | ||
8 | constructor (player: videojs.Player, options) { | 7 | constructor (player: any, options: any) { |
9 | super(player, options) | 8 | super(player, options) |
10 | } | 9 | } |
11 | 10 | ||
diff --git a/client/src/assets/player/peertube-load-progress-bar.ts b/client/src/assets/player/peertube-load-progress-bar.ts index aedc641e4..ee8a6cd81 100644 --- a/client/src/assets/player/peertube-load-progress-bar.ts +++ b/client/src/assets/player/peertube-load-progress-bar.ts | |||
@@ -4,7 +4,7 @@ const Component: VideoJSComponentInterface = videojsUntyped.getComponent('Compon | |||
4 | 4 | ||
5 | class PeerTubeLoadProgressBar extends Component { | 5 | class PeerTubeLoadProgressBar extends Component { |
6 | 6 | ||
7 | constructor (player, options) { | 7 | constructor (player: any, options: any) { |
8 | super(player, options) | 8 | super(player, options) |
9 | this.partEls_ = [] | 9 | this.partEls_ = [] |
10 | this.on(player, 'progress', this.update) | 10 | this.on(player, 'progress', this.update) |
diff --git a/client/src/assets/player/peertube-player.ts b/client/src/assets/player/peertube-player.ts index 792662b6c..ef9e7fcc0 100644 --- a/client/src/assets/player/peertube-player.ts +++ b/client/src/assets/player/peertube-player.ts | |||
@@ -75,12 +75,12 @@ function getVideojsOptions (options: { | |||
75 | enableVolumeScroll: false, | 75 | enableVolumeScroll: false, |
76 | enableModifiersForNumbers: false, | 76 | enableModifiersForNumbers: false, |
77 | 77 | ||
78 | fullscreenKey: function (event) { | 78 | fullscreenKey: function (event: any) { |
79 | // fullscreen with the f key or Ctrl+Enter | 79 | // fullscreen with the f key or Ctrl+Enter |
80 | return event.key === 'f' || (event.ctrlKey && event.key === 'Enter') | 80 | return event.key === 'f' || (event.ctrlKey && event.key === 'Enter') |
81 | }, | 81 | }, |
82 | 82 | ||
83 | seekStep: function (event) { | 83 | seekStep: function (event: any) { |
84 | // mimic VLC seek behavior, and default to 5 (original value is 5). | 84 | // mimic VLC seek behavior, and default to 5 (original value is 5). |
85 | if (event.ctrlKey && event.altKey) { | 85 | if (event.ctrlKey && event.altKey) { |
86 | return 5 * 60 | 86 | return 5 * 60 |
@@ -95,26 +95,26 @@ function getVideojsOptions (options: { | |||
95 | 95 | ||
96 | customKeys: { | 96 | customKeys: { |
97 | increasePlaybackRateKey: { | 97 | increasePlaybackRateKey: { |
98 | key: function (event) { | 98 | key: function (event: any) { |
99 | return event.key === '>' | 99 | return event.key === '>' |
100 | }, | 100 | }, |
101 | handler: function (player) { | 101 | handler: function (player: any) { |
102 | player.playbackRate((player.playbackRate() + 0.1).toFixed(2)) | 102 | player.playbackRate((player.playbackRate() + 0.1).toFixed(2)) |
103 | } | 103 | } |
104 | }, | 104 | }, |
105 | decreasePlaybackRateKey: { | 105 | decreasePlaybackRateKey: { |
106 | key: function (event) { | 106 | key: function (event: any) { |
107 | return event.key === '<' | 107 | return event.key === '<' |
108 | }, | 108 | }, |
109 | handler: function (player) { | 109 | handler: function (player: any) { |
110 | player.playbackRate((player.playbackRate() - 0.1).toFixed(2)) | 110 | player.playbackRate((player.playbackRate() - 0.1).toFixed(2)) |
111 | } | 111 | } |
112 | }, | 112 | }, |
113 | frameByFrame: { | 113 | frameByFrame: { |
114 | key: function (event) { | 114 | key: function (event: any) { |
115 | return event.key === '.' | 115 | return event.key === '.' |
116 | }, | 116 | }, |
117 | handler: function (player, options, event) { | 117 | handler: function (player: any) { |
118 | player.pause() | 118 | player.pause() |
119 | // Calculate movement distance (assuming 30 fps) | 119 | // Calculate movement distance (assuming 30 fps) |
120 | const dist = 1 / 30 | 120 | const dist = 1 / 30 |
diff --git a/client/src/assets/player/peertube-videojs-plugin.ts b/client/src/assets/player/peertube-videojs-plugin.ts index 5cebab6d9..03def186e 100644 --- a/client/src/assets/player/peertube-videojs-plugin.ts +++ b/client/src/assets/player/peertube-videojs-plugin.ts | |||
@@ -1,11 +1,11 @@ | |||
1 | import * as videojs from 'video.js' | 1 | const videojs = require('video.js') |
2 | import * as WebTorrent from 'webtorrent' | 2 | import * as WebTorrent from 'webtorrent' |
3 | import { VideoFile } from '../../../../shared/models/videos/video.model' | 3 | import { VideoFile } from '../../../../shared/models/videos/video.model' |
4 | import { renderVideo } from './video-renderer' | 4 | import { renderVideo } from './video-renderer' |
5 | import './settings-menu-button' | 5 | import './settings-menu-button' |
6 | import { PeertubePluginOptions, UserWatching, VideoJSCaption, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' | 6 | import { PeertubePluginOptions, UserWatching, VideoJSCaption, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' |
7 | import { isMobile, timeToInt, videoFileMaxByResolution, videoFileMinByResolution } from './utils' | 7 | import { isMobile, timeToInt, videoFileMaxByResolution, videoFileMinByResolution } from './utils' |
8 | import * as CacheChunkStore from 'cache-chunk-store' | 8 | const CacheChunkStore = require('cache-chunk-store') |
9 | import { PeertubeChunkStore } from './peertube-chunk-store' | 9 | import { PeertubeChunkStore } from './peertube-chunk-store' |
10 | import { | 10 | import { |
11 | getAverageBandwidthInStore, | 11 | getAverageBandwidthInStore, |
@@ -61,11 +61,11 @@ class PeerTubePlugin extends Plugin { | |||
61 | 61 | ||
62 | private player: any | 62 | private player: any |
63 | private currentVideoFile: VideoFile | 63 | private currentVideoFile: VideoFile |
64 | private torrent: WebTorrent.Torrent | 64 | private torrent: any |
65 | private videoCaptions: VideoJSCaption[] | 65 | private videoCaptions: VideoJSCaption[] |
66 | 66 | ||
67 | private renderer | 67 | private renderer: any |
68 | private fakeRenderer | 68 | private fakeRenderer: any |
69 | private destoyingFakeRenderer = false | 69 | private destoyingFakeRenderer = false |
70 | 70 | ||
71 | private autoResolution = true | 71 | private autoResolution = true |
@@ -73,17 +73,17 @@ class PeerTubePlugin extends Plugin { | |||
73 | private isAutoResolutionObservation = false | 73 | private isAutoResolutionObservation = false |
74 | private playerRefusedP2P = false | 74 | private playerRefusedP2P = false |
75 | 75 | ||
76 | private videoViewInterval | 76 | private videoViewInterval: any |
77 | private torrentInfoInterval | 77 | private torrentInfoInterval: any |
78 | private autoQualityInterval | 78 | private autoQualityInterval: any |
79 | private userWatchingVideoInterval | 79 | private userWatchingVideoInterval: any |
80 | private addTorrentDelay | 80 | private addTorrentDelay: any |
81 | private qualityObservationTimer | 81 | private qualityObservationTimer: any |
82 | private runAutoQualitySchedulerTimer | 82 | private runAutoQualitySchedulerTimer: any |
83 | 83 | ||
84 | private downloadSpeeds: number[] = [] | 84 | private downloadSpeeds: number[] = [] |
85 | 85 | ||
86 | constructor (player: videojs.Player, options: PeertubePluginOptions) { | 86 | constructor (player: any, options: PeertubePluginOptions) { |
87 | super(player, options) | 87 | super(player, options) |
88 | 88 | ||
89 | // Disable auto play on iOS | 89 | // Disable auto play on iOS |
@@ -273,7 +273,7 @@ class PeerTubePlugin extends Plugin { | |||
273 | 273 | ||
274 | const oldTorrent = this.torrent | 274 | const oldTorrent = this.torrent |
275 | const torrentOptions = { | 275 | const torrentOptions = { |
276 | store: (chunkLength, storeOpts) => new CacheChunkStore(new PeertubeChunkStore(chunkLength, storeOpts), { | 276 | store: (chunkLength: any, storeOpts: any) => new CacheChunkStore(new PeertubeChunkStore(chunkLength, storeOpts), { |
277 | max: 100 | 277 | max: 100 |
278 | }) | 278 | }) |
279 | } | 279 | } |
@@ -304,7 +304,7 @@ class PeerTubePlugin extends Plugin { | |||
304 | 304 | ||
305 | if (err) return this.fallbackToHttp(options, done) | 305 | if (err) return this.fallbackToHttp(options, done) |
306 | 306 | ||
307 | return this.tryToPlay(err => { | 307 | return this.tryToPlay((err: Error) => { |
308 | if (err) return done(err) | 308 | if (err) return done(err) |
309 | 309 | ||
310 | if (options.seek) this.seek(options.seek) | 310 | if (options.seek) this.seek(options.seek) |
@@ -316,7 +316,7 @@ class PeerTubePlugin extends Plugin { | |||
316 | }, options.delay || 0) | 316 | }, options.delay || 0) |
317 | }) | 317 | }) |
318 | 318 | ||
319 | this.torrent.on('error', err => console.error(err)) | 319 | this.torrent.on('error', (err: any) => console.error(err)) |
320 | 320 | ||
321 | this.torrent.on('warning', (err: any) => { | 321 | this.torrent.on('warning', (err: any) => { |
322 | // We don't support HTTP tracker but we don't care -> we use the web socket tracker | 322 | // We don't support HTTP tracker but we don't care -> we use the web socket tracker |
@@ -350,7 +350,7 @@ class PeerTubePlugin extends Plugin { | |||
350 | const playPromise = this.player.play() | 350 | const playPromise = this.player.play() |
351 | if (playPromise !== undefined) { | 351 | if (playPromise !== undefined) { |
352 | return playPromise.then(done) | 352 | return playPromise.then(done) |
353 | .catch(err => { | 353 | .catch((err: Error) => { |
354 | if (err.message.indexOf('The play() request was interrupted by a call to pause()') !== -1) { | 354 | if (err.message.indexOf('The play() request was interrupted by a call to pause()') !== -1) { |
355 | return | 355 | return |
356 | } | 356 | } |
@@ -627,7 +627,7 @@ class PeerTubePlugin extends Plugin { | |||
627 | this.player.options_.inactivityTimeout = saveInactivityTimeout | 627 | this.player.options_.inactivityTimeout = saveInactivityTimeout |
628 | } | 628 | } |
629 | 629 | ||
630 | const settingsDialog = this.player.children_.find(c => c.name_ === 'SettingsDialog') | 630 | const settingsDialog = this.player.children_.find((c: any) => c.name_ === 'SettingsDialog') |
631 | 631 | ||
632 | this.player.controlBar.on('mouseenter', () => disableInactivity()) | 632 | this.player.controlBar.on('mouseenter', () => disableInactivity()) |
633 | settingsDialog.on('mouseenter', () => disableInactivity()) | 633 | settingsDialog.on('mouseenter', () => disableInactivity()) |
@@ -641,7 +641,7 @@ class PeerTubePlugin extends Plugin { | |||
641 | return this.videoFiles[Math.floor(this.videoFiles.length / 2)] | 641 | return this.videoFiles[Math.floor(this.videoFiles.length / 2)] |
642 | } | 642 | } |
643 | 643 | ||
644 | private stopTorrent (torrent: WebTorrent.Torrent) { | 644 | private stopTorrent (torrent: any) { |
645 | torrent.pause() | 645 | torrent.pause() |
646 | // Pause does not remove actual peers (in particular the webseed peer) | 646 | // Pause does not remove actual peers (in particular the webseed peer) |
647 | torrent.removePeer(torrent[ 'ws' ]) | 647 | torrent.removePeer(torrent[ 'ws' ]) |
@@ -703,7 +703,7 @@ class PeerTubePlugin extends Plugin { | |||
703 | const percent = time / this.player_.duration() | 703 | const percent = time / this.player_.duration() |
704 | return percent >= 1 ? 1 : percent | 704 | return percent >= 1 ? 1 : percent |
705 | } | 705 | } |
706 | SeekBar.prototype.handleMouseMove = function handleMouseMove (event) { | 706 | SeekBar.prototype.handleMouseMove = function handleMouseMove (event: any) { |
707 | let newTime = this.calculateDistance(event) * this.player_.duration() | 707 | let newTime = this.calculateDistance(event) * this.player_.duration() |
708 | if (newTime === this.player_.duration()) { | 708 | if (newTime === this.player_.duration()) { |
709 | newTime = newTime - 0.1 | 709 | newTime = newTime - 0.1 |
diff --git a/client/src/assets/player/peertube-videojs-typings.ts b/client/src/assets/player/peertube-videojs-typings.ts index b117007af..98a33077d 100644 --- a/client/src/assets/player/peertube-videojs-typings.ts +++ b/client/src/assets/player/peertube-videojs-typings.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import * as videojs from 'video.js' | 1 | const videojs = require('video.js') |
2 | import { VideoFile } from '../../../../shared/models/videos/video.model' | 2 | import { VideoFile } from '../../../../shared/models/videos/video.model' |
3 | import { PeerTubePlugin } from './peertube-videojs-plugin' | 3 | import { PeerTubePlugin } from './peertube-videojs-plugin' |
4 | 4 | ||
@@ -11,9 +11,9 @@ declare namespace videojs { | |||
11 | interface VideoJSComponentInterface { | 11 | interface VideoJSComponentInterface { |
12 | _player: videojs.Player | 12 | _player: videojs.Player |
13 | 13 | ||
14 | new (player: videojs.Player, options?: any) | 14 | new (player: videojs.Player, options?: any): any |
15 | 15 | ||
16 | registerComponent (name: string, obj: any) | 16 | registerComponent (name: string, obj: any): any |
17 | } | 17 | } |
18 | 18 | ||
19 | type VideoJSCaption = { | 19 | type VideoJSCaption = { |
diff --git a/client/src/assets/player/resolution-menu-button.ts b/client/src/assets/player/resolution-menu-button.ts index d53a24151..91818efc9 100644 --- a/client/src/assets/player/resolution-menu-button.ts +++ b/client/src/assets/player/resolution-menu-button.ts | |||
@@ -1,4 +1,3 @@ | |||
1 | import * as videojs from 'video.js' | ||
2 | import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' | 1 | import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' |
3 | import { ResolutionMenuItem } from './resolution-menu-item' | 2 | import { ResolutionMenuItem } from './resolution-menu-item' |
4 | 3 | ||
@@ -7,7 +6,7 @@ const MenuButton: VideoJSComponentInterface = videojsUntyped.getComponent('MenuB | |||
7 | class ResolutionMenuButton extends MenuButton { | 6 | class ResolutionMenuButton extends MenuButton { |
8 | label: HTMLElement | 7 | label: HTMLElement |
9 | 8 | ||
10 | constructor (player: videojs.Player, options) { | 9 | constructor (player: any, options: any) { |
11 | super(player, options) | 10 | super(player, options) |
12 | this.player = player | 11 | this.player = player |
13 | 12 | ||
diff --git a/client/src/assets/player/resolution-menu-item.ts b/client/src/assets/player/resolution-menu-item.ts index 0ab0f53b5..afe490abb 100644 --- a/client/src/assets/player/resolution-menu-item.ts +++ b/client/src/assets/player/resolution-menu-item.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | import * as videojs from 'video.js' | ||
2 | import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' | 1 | import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' |
3 | 2 | ||
4 | const MenuItem: VideoJSComponentInterface = videojsUntyped.getComponent('MenuItem') | 3 | const MenuItem: VideoJSComponentInterface = videojsUntyped.getComponent('MenuItem') |
5 | class ResolutionMenuItem extends MenuItem { | 4 | class ResolutionMenuItem extends MenuItem { |
6 | 5 | ||
7 | constructor (player: videojs.Player, options) { | 6 | constructor (player: any, options: any) { |
8 | const currentResolutionId = player.peertube().getCurrentResolutionId() | 7 | const currentResolutionId = player.peertube().getCurrentResolutionId() |
9 | options.selectable = true | 8 | options.selectable = true |
10 | options.selected = options.id === currentResolutionId | 9 | options.selected = options.id === currentResolutionId |
@@ -18,7 +17,7 @@ class ResolutionMenuItem extends MenuItem { | |||
18 | player.peertube().on('autoResolutionUpdate', () => this.updateSelection()) | 17 | player.peertube().on('autoResolutionUpdate', () => this.updateSelection()) |
19 | } | 18 | } |
20 | 19 | ||
21 | handleClick (event) { | 20 | handleClick (event: any) { |
22 | if (this.id === -1 && this.player_.peertube().isAutoResolutionForbidden()) return | 21 | if (this.id === -1 && this.player_.peertube().isAutoResolutionForbidden()) return |
23 | 22 | ||
24 | super.handleClick(event) | 23 | super.handleClick(event) |
diff --git a/client/src/assets/player/settings-menu-button.ts b/client/src/assets/player/settings-menu-button.ts index b51c52506..f0ccb5862 100644 --- a/client/src/assets/player/settings-menu-button.ts +++ b/client/src/assets/player/settings-menu-button.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | // Author: Yanko Shterev | 1 | // Author: Yanko Shterev |
2 | // Thanks https://github.com/yshterev/videojs-settings-menu | 2 | // Thanks https://github.com/yshterev/videojs-settings-menu |
3 | 3 | ||
4 | import * as videojs from 'video.js' | 4 | const videojs = require('video.js') |
5 | import { SettingsMenuItem } from './settings-menu-item' | 5 | import { SettingsMenuItem } from './settings-menu-item' |
6 | import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' | 6 | import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' |
7 | import { toTitleCase } from './utils' | 7 | import { toTitleCase } from './utils' |
@@ -11,7 +11,7 @@ const Menu: VideoJSComponentInterface = videojsUntyped.getComponent('Menu') | |||
11 | const Component: VideoJSComponentInterface = videojsUntyped.getComponent('Component') | 11 | const Component: VideoJSComponentInterface = videojsUntyped.getComponent('Component') |
12 | 12 | ||
13 | class SettingsButton extends Button { | 13 | class SettingsButton extends Button { |
14 | constructor (player: videojs.Player, options) { | 14 | constructor (player: any, options: any) { |
15 | super(player, options) | 15 | super(player, options) |
16 | 16 | ||
17 | this.playerComponent = player | 17 | this.playerComponent = player |
@@ -48,7 +48,7 @@ class SettingsButton extends Button { | |||
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | onDisposeSettingsItem (event, name: string) { | 51 | onDisposeSettingsItem (name: string) { |
52 | if (name === undefined) { | 52 | if (name === undefined) { |
53 | let children = this.menu.children() | 53 | let children = this.menu.children() |
54 | 54 | ||
@@ -74,7 +74,7 @@ class SettingsButton extends Button { | |||
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | onAddSettingsItem (event, data) { | 77 | onAddSettingsItem (data: any) { |
78 | const [ entry, options ] = data | 78 | const [ entry, options ] = data |
79 | 79 | ||
80 | this.addMenuItem(entry, options) | 80 | this.addMenuItem(entry, options) |
@@ -120,7 +120,7 @@ class SettingsButton extends Button { | |||
120 | this.resetChildren() | 120 | this.resetChildren() |
121 | } | 121 | } |
122 | 122 | ||
123 | getComponentSize (element) { | 123 | getComponentSize (element: any) { |
124 | let width: number = null | 124 | let width: number = null |
125 | let height: number = null | 125 | let height: number = null |
126 | 126 | ||
@@ -178,7 +178,7 @@ class SettingsButton extends Button { | |||
178 | this.panelChild.addChild(this.menu) | 178 | this.panelChild.addChild(this.menu) |
179 | } | 179 | } |
180 | 180 | ||
181 | addMenuItem (entry, options) { | 181 | addMenuItem (entry: any, options: any) { |
182 | const openSubMenu = function () { | 182 | const openSubMenu = function () { |
183 | if (videojsUntyped.dom.hasClass(this.el_, 'open')) { | 183 | if (videojsUntyped.dom.hasClass(this.el_, 'open')) { |
184 | videojsUntyped.dom.removeClass(this.el_, 'open') | 184 | videojsUntyped.dom.removeClass(this.el_, 'open') |
@@ -218,7 +218,7 @@ class SettingsButton extends Button { | |||
218 | } | 218 | } |
219 | 219 | ||
220 | class SettingsPanel extends Component { | 220 | class SettingsPanel extends Component { |
221 | constructor (player: videojs.Player, options) { | 221 | constructor (player: any, options: any) { |
222 | super(player, options) | 222 | super(player, options) |
223 | } | 223 | } |
224 | 224 | ||
@@ -232,7 +232,7 @@ class SettingsPanel extends Component { | |||
232 | } | 232 | } |
233 | 233 | ||
234 | class SettingsPanelChild extends Component { | 234 | class SettingsPanelChild extends Component { |
235 | constructor (player: videojs.Player, options) { | 235 | constructor (player: any, options: any) { |
236 | super(player, options) | 236 | super(player, options) |
237 | } | 237 | } |
238 | 238 | ||
@@ -246,7 +246,7 @@ class SettingsPanelChild extends Component { | |||
246 | } | 246 | } |
247 | 247 | ||
248 | class SettingsDialog extends Component { | 248 | class SettingsDialog extends Component { |
249 | constructor (player: videojs.Player, options) { | 249 | constructor (player: any, options: any) { |
250 | super(player, options) | 250 | super(player, options) |
251 | this.hide() | 251 | this.hide() |
252 | } | 252 | } |
diff --git a/client/src/assets/player/settings-menu-item.ts b/client/src/assets/player/settings-menu-item.ts index 665ce6fc2..2d752b62e 100644 --- a/client/src/assets/player/settings-menu-item.ts +++ b/client/src/assets/player/settings-menu-item.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | // Author: Yanko Shterev | 1 | // Author: Yanko Shterev |
2 | // Thanks https://github.com/yshterev/videojs-settings-menu | 2 | // Thanks https://github.com/yshterev/videojs-settings-menu |
3 | 3 | ||
4 | import * as videojs from 'video.js' | ||
5 | import { toTitleCase } from './utils' | 4 | import { toTitleCase } from './utils' |
6 | import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' | 5 | import { VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' |
7 | 6 | ||
@@ -10,7 +9,7 @@ const component: VideoJSComponentInterface = videojsUntyped.getComponent('Compon | |||
10 | 9 | ||
11 | class SettingsMenuItem extends MenuItem { | 10 | class SettingsMenuItem extends MenuItem { |
12 | 11 | ||
13 | constructor (player: videojs.Player, options, entry: string, menuButton: VideoJSComponentInterface) { | 12 | constructor (player: any, options: any, entry: string, menuButton: VideoJSComponentInterface) { |
14 | super(player, options) | 13 | super(player, options) |
15 | 14 | ||
16 | this.settingsButton = menuButton | 15 | this.settingsButton = menuButton |
@@ -55,7 +54,7 @@ class SettingsMenuItem extends MenuItem { | |||
55 | this.transitionEndHandler = this.onTransitionEnd.bind(this) | 54 | this.transitionEndHandler = this.onTransitionEnd.bind(this) |
56 | } | 55 | } |
57 | 56 | ||
58 | onSubmenuClick (event) { | 57 | onSubmenuClick (event: any) { |
59 | let target = null | 58 | let target = null |
60 | 59 | ||
61 | if (event.type === 'tap') { | 60 | if (event.type === 'tap') { |
@@ -150,7 +149,7 @@ class SettingsMenuItem extends MenuItem { | |||
150 | * | 149 | * |
151 | * @method PrefixedEvent | 150 | * @method PrefixedEvent |
152 | */ | 151 | */ |
153 | PrefixedEvent (element, type, callback, action = 'addEvent') { | 152 | PrefixedEvent (element: any, type: any, callback: any, action = 'addEvent') { |
154 | let prefix = ['webkit', 'moz', 'MS', 'o', ''] | 153 | let prefix = ['webkit', 'moz', 'MS', 'o', ''] |
155 | 154 | ||
156 | for (let p = 0; p < prefix.length; p++) { | 155 | for (let p = 0; p < prefix.length; p++) { |
@@ -166,7 +165,7 @@ class SettingsMenuItem extends MenuItem { | |||
166 | } | 165 | } |
167 | } | 166 | } |
168 | 167 | ||
169 | onTransitionEnd (event) { | 168 | onTransitionEnd (event: any) { |
170 | if (event.propertyName !== 'margin-right') { | 169 | if (event.propertyName !== 'margin-right') { |
171 | return | 170 | return |
172 | } | 171 | } |
@@ -229,7 +228,7 @@ class SettingsMenuItem extends MenuItem { | |||
229 | ) | 228 | ) |
230 | } | 229 | } |
231 | 230 | ||
232 | update (event?: Event) { | 231 | update (event?: any) { |
233 | let target = null | 232 | let target = null |
234 | let subMenu = this.subMenu.name() | 233 | let subMenu = this.subMenu.name() |
235 | 234 | ||
diff --git a/client/src/assets/player/theater-button.ts b/client/src/assets/player/theater-button.ts index 5cf0b6425..b761f6030 100644 --- a/client/src/assets/player/theater-button.ts +++ b/client/src/assets/player/theater-button.ts | |||
@@ -6,7 +6,7 @@ class TheaterButton extends Button { | |||
6 | 6 | ||
7 | private static readonly THEATER_MODE_CLASS = 'vjs-theater-enabled' | 7 | private static readonly THEATER_MODE_CLASS = 'vjs-theater-enabled' |
8 | 8 | ||
9 | constructor (player, options) { | 9 | constructor (player: any, options: any) { |
10 | super(player, options) | 10 | super(player, options) |
11 | 11 | ||
12 | const enabled = getStoredTheater() | 12 | const enabled = getStoredTheater() |
diff --git a/client/src/assets/player/utils.ts b/client/src/assets/player/utils.ts index cf4f60f55..46081c0d2 100644 --- a/client/src/assets/player/utils.ts +++ b/client/src/assets/player/utils.ts | |||
@@ -12,7 +12,7 @@ const dictionaryBytes: Array<{max: number, type: string}> = [ | |||
12 | { max: 1073741824, type: 'MB' }, | 12 | { max: 1073741824, type: 'MB' }, |
13 | { max: 1.0995116e12, type: 'GB' } | 13 | { max: 1.0995116e12, type: 'GB' } |
14 | ] | 14 | ] |
15 | function bytes (value) { | 15 | function bytes (value: any) { |
16 | const format = dictionaryBytes.find(d => value < d.max) || dictionaryBytes[dictionaryBytes.length - 1] | 16 | const format = dictionaryBytes.find(d => value < d.max) || dictionaryBytes[dictionaryBytes.length - 1] |
17 | const calc = Math.floor(value / (format.max / 1024)).toString() | 17 | const calc = Math.floor(value / (format.max / 1024)).toString() |
18 | 18 | ||
diff --git a/client/src/assets/player/video-renderer.ts b/client/src/assets/player/video-renderer.ts index 2cb05a448..a3415937b 100644 --- a/client/src/assets/player/video-renderer.ts +++ b/client/src/assets/player/video-renderer.ts | |||
@@ -1,9 +1,9 @@ | |||
1 | // Thanks: https://github.com/feross/render-media | 1 | // Thanks: https://github.com/feross/render-media |
2 | // TODO: use render-media once https://github.com/feross/render-media/issues/32 is fixed | 2 | // TODO: use render-media once https://github.com/feross/render-media/issues/32 is fixed |
3 | 3 | ||
4 | import * as MediaElementWrapper from 'mediasource' | 4 | const MediaElementWrapper = require('mediasource') |
5 | import { extname } from 'path' | 5 | import { extname } from 'path' |
6 | import * as videostream from 'videostream' | 6 | const videostream = require('videostream') |
7 | 7 | ||
8 | const VIDEOSTREAM_EXTS = [ | 8 | const VIDEOSTREAM_EXTS = [ |
9 | '.m4a', | 9 | '.m4a', |
@@ -17,7 +17,7 @@ type RenderMediaOptions = { | |||
17 | } | 17 | } |
18 | 18 | ||
19 | function renderVideo ( | 19 | function renderVideo ( |
20 | file, | 20 | file: any, |
21 | elem: HTMLVideoElement, | 21 | elem: HTMLVideoElement, |
22 | opts: RenderMediaOptions, | 22 | opts: RenderMediaOptions, |
23 | callback: (err: Error, renderer: any) => void | 23 | callback: (err: Error, renderer: any) => void |
@@ -27,11 +27,11 @@ function renderVideo ( | |||
27 | return renderMedia(file, elem, opts, callback) | 27 | return renderMedia(file, elem, opts, callback) |
28 | } | 28 | } |
29 | 29 | ||
30 | function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, callback: (err: Error, renderer?: any) => void) { | 30 | function renderMedia (file: any, elem: HTMLVideoElement, opts: RenderMediaOptions, callback: (err: Error, renderer?: any) => void) { |
31 | const extension = extname(file.name).toLowerCase() | 31 | const extension = extname(file.name).toLowerCase() |
32 | let preparedElem = undefined | 32 | let preparedElem: any = undefined |
33 | let currentTime = 0 | 33 | let currentTime = 0 |
34 | let renderer | 34 | let renderer: any |
35 | 35 | ||
36 | try { | 36 | try { |
37 | if (VIDEOSTREAM_EXTS.indexOf(extension) >= 0) { | 37 | if (VIDEOSTREAM_EXTS.indexOf(extension) >= 0) { |
@@ -45,7 +45,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca | |||
45 | 45 | ||
46 | function useVideostream () { | 46 | function useVideostream () { |
47 | prepareElem() | 47 | prepareElem() |
48 | preparedElem.addEventListener('error', function onError (err) { | 48 | preparedElem.addEventListener('error', function onError (err: Error) { |
49 | preparedElem.removeEventListener('error', onError) | 49 | preparedElem.removeEventListener('error', onError) |
50 | 50 | ||
51 | return callback(err) | 51 | return callback(err) |
@@ -58,7 +58,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca | |||
58 | const codecs = getCodec(file.name, useVP9) | 58 | const codecs = getCodec(file.name, useVP9) |
59 | 59 | ||
60 | prepareElem() | 60 | prepareElem() |
61 | preparedElem.addEventListener('error', function onError (err) { | 61 | preparedElem.addEventListener('error', function onError (err: Error) { |
62 | preparedElem.removeEventListener('error', onError) | 62 | preparedElem.removeEventListener('error', onError) |
63 | 63 | ||
64 | // Try with vp9 before returning an error | 64 | // Try with vp9 before returning an error |
@@ -102,7 +102,7 @@ function renderMedia (file, elem: HTMLVideoElement, opts: RenderMediaOptions, ca | |||
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | function validateFile (file) { | 105 | function validateFile (file: any) { |
106 | if (file == null) { | 106 | if (file == null) { |
107 | throw new Error('file cannot be null or undefined') | 107 | throw new Error('file cannot be null or undefined') |
108 | } | 108 | } |
diff --git a/client/src/assets/player/webtorrent-info-button.ts b/client/src/assets/player/webtorrent-info-button.ts index deef253ce..5b9d0a401 100644 --- a/client/src/assets/player/webtorrent-info-button.ts +++ b/client/src/assets/player/webtorrent-info-button.ts | |||
@@ -65,7 +65,7 @@ class WebtorrentInfoButton extends Button { | |||
65 | subDivHttp.appendChild(subDivHttpText) | 65 | subDivHttp.appendChild(subDivHttpText) |
66 | div.appendChild(subDivHttp) | 66 | div.appendChild(subDivHttp) |
67 | 67 | ||
68 | this.player_.peertube().on('torrentInfo', (event, data) => { | 68 | this.player_.peertube().on('torrentInfo', (data: any) => { |
69 | // We are in HTTP fallback | 69 | // We are in HTTP fallback |
70 | if (!data) { | 70 | if (!data) { |
71 | subDivHttp.className = 'vjs-peertube-displayed' | 71 | subDivHttp.className = 'vjs-peertube-displayed' |