aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts')
-rw-r--r--client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts25
1 files changed, 13 insertions, 12 deletions
diff --git a/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts b/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts
index 83b483d87..ab9ab56ac 100644
--- a/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts
+++ b/client/src/assets/player/shared/webtorrent/webtorrent-plugin.ts
@@ -1,5 +1,6 @@
1import videojs from 'video.js' 1import videojs from 'video.js'
2import * as WebTorrent from 'webtorrent' 2import * as WebTorrent from 'webtorrent'
3import { logger } from '@root-helpers/logger'
3import { isIOS } from '@root-helpers/web-browser' 4import { isIOS } from '@root-helpers/web-browser'
4import { timeToInt } from '@shared/core-utils' 5import { timeToInt } from '@shared/core-utils'
5import { VideoFile } from '@shared/models' 6import { VideoFile } from '@shared/models'
@@ -210,7 +211,7 @@ class WebTorrentPlugin extends Plugin {
210 if (destroyRenderer === true && this.renderer && this.renderer.destroy) this.renderer.destroy() 211 if (destroyRenderer === true && this.renderer && this.renderer.destroy) this.renderer.destroy()
211 212
212 this.webtorrent.remove(videoFile.magnetUri) 213 this.webtorrent.remove(videoFile.magnetUri)
213 console.log('Removed ' + videoFile.magnetUri) 214 logger.info(`Removed ${videoFile.magnetUri}`)
214 } 215 }
215 } 216 }
216 217
@@ -256,7 +257,7 @@ class WebTorrentPlugin extends Plugin {
256 ) { 257 ) {
257 if (!magnetOrTorrentUrl) return this.fallbackToHttp(options, done) 258 if (!magnetOrTorrentUrl) return this.fallbackToHttp(options, done)
258 259
259 console.log('Adding ' + magnetOrTorrentUrl + '.') 260 logger.info(`Adding ${magnetOrTorrentUrl}.`)
260 261
261 const oldTorrent = this.torrent 262 const oldTorrent = this.torrent
262 const torrentOptions = { 263 const torrentOptions = {
@@ -269,7 +270,7 @@ class WebTorrentPlugin extends Plugin {
269 } 270 }
270 271
271 this.torrent = this.webtorrent.add(magnetOrTorrentUrl, torrentOptions, torrent => { 272 this.torrent = this.webtorrent.add(magnetOrTorrentUrl, torrentOptions, torrent => {
272 console.log('Added ' + magnetOrTorrentUrl + '.') 273 logger.info(`Added ${magnetOrTorrentUrl}.`)
273 274
274 if (oldTorrent) { 275 if (oldTorrent) {
275 // Pause the old torrent 276 // Pause the old torrent
@@ -309,7 +310,7 @@ class WebTorrentPlugin extends Plugin {
309 }, options.delay || 0) 310 }, options.delay || 0)
310 }) 311 })
311 312
312 this.torrent.on('error', (err: any) => console.error(err)) 313 this.torrent.on('error', (err: any) => logger.error(err))
313 314
314 this.torrent.on('warning', (err: any) => { 315 this.torrent.on('warning', (err: any) => {
315 // We don't support HTTP tracker but we don't care -> we use the web socket tracker 316 // We don't support HTTP tracker but we don't care -> we use the web socket tracker
@@ -317,13 +318,13 @@ class WebTorrentPlugin extends Plugin {
317 318
318 // Users don't care about issues with WebRTC, but developers do so log it in the console 319 // Users don't care about issues with WebRTC, but developers do so log it in the console
319 if (err.message.indexOf('Ice connection failed') !== -1) { 320 if (err.message.indexOf('Ice connection failed') !== -1) {
320 console.log(err) 321 logger.info(err)
321 return 322 return
322 } 323 }
323 324
324 // Magnet hash is not up to date with the torrent file, add directly the torrent file 325 // Magnet hash is not up to date with the torrent file, add directly the torrent file
325 if (err.message.indexOf('incorrect info hash') !== -1) { 326 if (err.message.indexOf('incorrect info hash') !== -1) {
326 console.error('Incorrect info hash detected, falling back to torrent file.') 327 logger.error('Incorrect info hash detected, falling back to torrent file.')
327 const newOptions = { forcePlay: true, seek: options.seek } 328 const newOptions = { forcePlay: true, seek: options.seek }
328 return this.addTorrent(this.torrent['xs'], previousVideoFile, newOptions, done) 329 return this.addTorrent(this.torrent['xs'], previousVideoFile, newOptions, done)
329 } 330 }
@@ -333,7 +334,7 @@ class WebTorrentPlugin extends Plugin {
333 this.handleError(err) 334 this.handleError(err)
334 } 335 }
335 336
336 console.warn(err) 337 logger.warn(err)
337 }) 338 })
338 } 339 }
339 340
@@ -348,7 +349,7 @@ class WebTorrentPlugin extends Plugin {
348 return 349 return
349 } 350 }
350 351
351 console.error(err) 352 logger.error(err)
352 this.player.pause() 353 this.player.pause()
353 this.player.posterImage.show() 354 this.player.posterImage.show()
354 this.player.removeClass('vjs-has-autoplay') 355 this.player.removeClass('vjs-has-autoplay')
@@ -465,10 +466,10 @@ class WebTorrentPlugin extends Plugin {
465 466
466 // Lower resolution 467 // Lower resolution
467 if (this.isPlayerWaiting() && file.resolution.id < this.currentVideoFile.resolution.id) { 468 if (this.isPlayerWaiting() && file.resolution.id < this.currentVideoFile.resolution.id) {
468 console.log('Downgrading automatically the resolution to: %s', file.resolution.label) 469 logger.info(`Downgrading automatically the resolution to: ${file.resolution.label}`)
469 changeResolution = true 470 changeResolution = true
470 } else if (file.resolution.id > this.currentVideoFile.resolution.id) { // Higher resolution 471 } else if (file.resolution.id > this.currentVideoFile.resolution.id) { // Higher resolution
471 console.log('Upgrading automatically the resolution to: %s', file.resolution.label) 472 logger.info(`Upgrading automatically the resolution to: ${file.resolution.label}`)
472 changeResolution = true 473 changeResolution = true
473 changeResolutionDelay = this.CONSTANTS.AUTO_QUALITY_HIGHER_RESOLUTION_DELAY 474 changeResolutionDelay = this.CONSTANTS.AUTO_QUALITY_HIGHER_RESOLUTION_DELAY
474 } 475 }
@@ -577,7 +578,7 @@ class WebTorrentPlugin extends Plugin {
577 578
578 // The renderer returns an error when we destroy it, so skip them 579 // The renderer returns an error when we destroy it, so skip them
579 if (this.destroyingFakeRenderer === false && err) { 580 if (this.destroyingFakeRenderer === false && err) {
580 console.error('Cannot render new torrent in fake video element.', err) 581 logger.error('Cannot render new torrent in fake video element.', err)
581 } 582 }
582 583
583 // Load the future file at the correct time (in delay MS - 2 seconds) 584 // Load the future file at the correct time (in delay MS - 2 seconds)
@@ -593,7 +594,7 @@ class WebTorrentPlugin extends Plugin {
593 try { 594 try {
594 this.fakeRenderer.destroy() 595 this.fakeRenderer.destroy()
595 } catch (err) { 596 } catch (err) {
596 console.log('Cannot destroy correctly fake renderer.', err) 597 logger.info('Cannot destroy correctly fake renderer.', err)
597 } 598 }
598 } 599 }
599 this.fakeRenderer = undefined 600 this.fakeRenderer = undefined