aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-videojs-plugin.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/peertube-videojs-plugin.ts')
-rw-r--r--client/src/assets/player/peertube-videojs-plugin.ts40
1 files changed, 20 insertions, 20 deletions
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 @@
1import * as videojs from 'video.js' 1const videojs = require('video.js')
2import * as WebTorrent from 'webtorrent' 2import * as WebTorrent from 'webtorrent'
3import { VideoFile } from '../../../../shared/models/videos/video.model' 3import { VideoFile } from '../../../../shared/models/videos/video.model'
4import { renderVideo } from './video-renderer' 4import { renderVideo } from './video-renderer'
5import './settings-menu-button' 5import './settings-menu-button'
6import { PeertubePluginOptions, UserWatching, VideoJSCaption, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings' 6import { PeertubePluginOptions, UserWatching, VideoJSCaption, VideoJSComponentInterface, videojsUntyped } from './peertube-videojs-typings'
7import { isMobile, timeToInt, videoFileMaxByResolution, videoFileMinByResolution } from './utils' 7import { isMobile, timeToInt, videoFileMaxByResolution, videoFileMinByResolution } from './utils'
8import * as CacheChunkStore from 'cache-chunk-store' 8const CacheChunkStore = require('cache-chunk-store')
9import { PeertubeChunkStore } from './peertube-chunk-store' 9import { PeertubeChunkStore } from './peertube-chunk-store'
10import { 10import {
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