aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/webtorrent/webtorrent-plugin.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-17 14:42:53 +0200
committerChocobozzz <me@florianbigard.com>2021-08-18 08:35:06 +0200
commit9df52d660feb722404be00a50f3c8a612bec1c15 (patch)
treedde52880fa012874d24c60f64eb596b0a789cc8b /client/src/assets/player/webtorrent/webtorrent-plugin.ts
parentadb8809d43648ea0a64d6845bb39aa3bd0e005a6 (diff)
downloadPeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.tar.gz
PeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.tar.zst
PeerTube-9df52d660feb722404be00a50f3c8a612bec1c15.zip
Migrate client to eslint
Diffstat (limited to 'client/src/assets/player/webtorrent/webtorrent-plugin.ts')
-rw-r--r--client/src/assets/player/webtorrent/webtorrent-plugin.ts24
1 files changed, 12 insertions, 12 deletions
diff --git a/client/src/assets/player/webtorrent/webtorrent-plugin.ts b/client/src/assets/player/webtorrent/webtorrent-plugin.ts
index 17d369c10..0587ddee6 100644
--- a/client/src/assets/player/webtorrent/webtorrent-plugin.ts
+++ b/client/src/assets/player/webtorrent/webtorrent-plugin.ts
@@ -17,8 +17,8 @@ import { renderVideo } from './video-renderer'
17const CacheChunkStore = require('cache-chunk-store') 17const CacheChunkStore = require('cache-chunk-store')
18 18
19type PlayOptions = { 19type PlayOptions = {
20 forcePlay?: boolean, 20 forcePlay?: boolean
21 seek?: number, 21 seek?: number
22 delay?: number 22 delay?: number
23} 23}
24 24
@@ -126,8 +126,8 @@ class WebTorrentPlugin extends Plugin {
126 updateVideoFile ( 126 updateVideoFile (
127 videoFile?: VideoFile, 127 videoFile?: VideoFile,
128 options: { 128 options: {
129 forcePlay?: boolean, 129 forcePlay?: boolean
130 seek?: number, 130 seek?: number
131 delay?: number 131 delay?: number
132 } = {}, 132 } = {},
133 done: () => void = () => { /* empty */ } 133 done: () => void = () => { /* empty */ }
@@ -248,7 +248,7 @@ class WebTorrentPlugin extends Plugin {
248 magnetOrTorrentUrl: string, 248 magnetOrTorrentUrl: string,
249 previousVideoFile: VideoFile, 249 previousVideoFile: VideoFile,
250 options: PlayOptions, 250 options: PlayOptions,
251 done: Function 251 done: (err?: Error) => void
252 ) { 252 ) {
253 if (!magnetOrTorrentUrl) return this.fallbackToHttp(options, done) 253 if (!magnetOrTorrentUrl) return this.fallbackToHttp(options, done)
254 254
@@ -272,7 +272,7 @@ class WebTorrentPlugin extends Plugin {
272 this.stopTorrent(oldTorrent) 272 this.stopTorrent(oldTorrent)
273 273
274 // We use a fake renderer so we download correct pieces of the next file 274 // We use a fake renderer so we download correct pieces of the next file
275 if (options.delay) this.renderFileInFakeElement(torrent.files[ 0 ], options.delay) 275 if (options.delay) this.renderFileInFakeElement(torrent.files[0], options.delay)
276 } 276 }
277 277
278 // Render the video in a few seconds? (on resolution change for example, we wait some seconds of the new video resolution) 278 // Render the video in a few seconds? (on resolution change for example, we wait some seconds of the new video resolution)
@@ -288,7 +288,7 @@ class WebTorrentPlugin extends Plugin {
288 if (options.seek) this.player.currentTime(options.seek) 288 if (options.seek) this.player.currentTime(options.seek)
289 289
290 const renderVideoOptions = { autoplay: false, controls: true } 290 const renderVideoOptions = { autoplay: false, controls: true }
291 renderVideo(torrent.files[ 0 ], this.playerElement, renderVideoOptions, (err, renderer) => { 291 renderVideo(torrent.files[0], this.playerElement, renderVideoOptions, (err, renderer) => {
292 this.renderer = renderer 292 this.renderer = renderer
293 293
294 if (err) return this.fallbackToHttp(options, done) 294 if (err) return this.fallbackToHttp(options, done)
@@ -321,7 +321,7 @@ class WebTorrentPlugin extends Plugin {
321 if (err.message.indexOf('incorrect info hash') !== -1) { 321 if (err.message.indexOf('incorrect info hash') !== -1) {
322 console.error('Incorrect info hash detected, falling back to torrent file.') 322 console.error('Incorrect info hash detected, falling back to torrent file.')
323 const newOptions = { forcePlay: true, seek: options.seek } 323 const newOptions = { forcePlay: true, seek: options.seek }
324 return this.addTorrent(this.torrent[ 'xs' ], previousVideoFile, newOptions, done) 324 return this.addTorrent(this.torrent['xs'], previousVideoFile, newOptions, done)
325 } 325 }
326 326
327 // Remote instance is down 327 // Remote instance is down
@@ -340,7 +340,7 @@ class WebTorrentPlugin extends Plugin {
340 if (playPromise !== undefined) { 340 if (playPromise !== undefined) {
341 return playPromise.then(() => done()) 341 return playPromise.then(() => done())
342 .catch((err: Error) => { 342 .catch((err: Error) => {
343 if (err.message.indexOf('The play() request was interrupted by a call to pause()') !== -1) { 343 if (err.message.includes('The play() request was interrupted by a call to pause()')) {
344 return 344 return
345 } 345 }
346 346
@@ -479,7 +479,7 @@ class WebTorrentPlugin extends Plugin {
479 } 479 }
480 480
481 private isPlayerWaiting () { 481 private isPlayerWaiting () {
482 return this.player && this.player.hasClass('vjs-waiting') 482 return this.player?.hasClass('vjs-waiting')
483 } 483 }
484 484
485 private runTorrentInfoScheduler () { 485 private runTorrentInfoScheduler () {
@@ -513,7 +513,7 @@ class WebTorrentPlugin extends Plugin {
513 }, this.CONSTANTS.INFO_SCHEDULER) 513 }, this.CONSTANTS.INFO_SCHEDULER)
514 } 514 }
515 515
516 private fallbackToHttp (options: PlayOptions, done?: Function) { 516 private fallbackToHttp (options: PlayOptions, done?: (err?: Error) => void) {
517 const paused = this.player.paused() 517 const paused = this.player.paused()
518 518
519 this.disableAutoResolution(true) 519 this.disableAutoResolution(true)
@@ -565,7 +565,7 @@ class WebTorrentPlugin extends Plugin {
565 private stopTorrent (torrent: WebTorrent.Torrent) { 565 private stopTorrent (torrent: WebTorrent.Torrent) {
566 torrent.pause() 566 torrent.pause()
567 // Pause does not remove actual peers (in particular the webseed peer) 567 // Pause does not remove actual peers (in particular the webseed peer)
568 torrent.removePeer(torrent[ 'ws' ]) 568 torrent.removePeer(torrent['ws'])
569 } 569 }
570 570
571 private renderFileInFakeElement (file: WebTorrent.TorrentFile, delay: number) { 571 private renderFileInFakeElement (file: WebTorrent.TorrentFile, delay: number) {