- this.errorsSub.unsubscribe()
- this.warningsSub.unsubscribe()
- }
-
- loadVideo () {
- // Reset the error
- this.error = false
- // We are loading the video
- this.loading = true
-
- console.log('Adding ' + this.video.magnetUri + '.')
-
- // The callback might never return if there are network issues
- // So we create a timer to inform the user the load is abnormally long
- this.errorTimer = window.setTimeout(() => this.loadTooLong(), VideoWatchComponent.LOADTIME_TOO_LONG)
-
- this.webTorrentService.add(this.video.magnetUri, (torrent) => {
- // Clear the error timer
- window.clearTimeout(this.errorTimer)
- // Maybe the error was fired by the timer, so reset it
- this.error = false
-
- // We are not loading the video anymore
- this.loading = false
-
- console.log('Added ' + this.video.magnetUri + '.')
- torrent.files[0].renderTo(this.playerElement, { autoplay: true }, (err) => {
- if (err) {
- this.notificationsService.error('Error', 'Cannot append the file in the video element.')
- console.error(err)
- }
- })
-
- this.runInProgress(torrent)
- })