+ updateResolution (resolutionId: number, delay = 0) {
+ // Remember player state
+ const currentTime = this.player.currentTime()
+ const isPaused = this.player.paused()
+
+ // Remove poster to have black background
+ this.playerElement.poster = ''
+
+ // Hide bigPlayButton
+ if (!isPaused) {
+ this.player.bigPlayButton.hide()
+ }
+
+ const newVideoFile = this.videoFiles.find(f => f.resolution.id === resolutionId)
+ const options = {
+ forcePlay: false,
+ delay,
+ seek: currentTime + (delay / 1000)
+ }
+ this.updateVideoFile(newVideoFile, options)
+ }
+
+ flushVideoFile (videoFile: VideoFile, destroyRenderer = true) {
+ if (videoFile !== undefined && this.webtorrent.get(videoFile.magnetUri)) {
+ if (destroyRenderer === true && this.renderer && this.renderer.destroy) this.renderer.destroy()
+
+ this.webtorrent.remove(videoFile.magnetUri)
+ console.log('Removed ' + videoFile.magnetUri)
+ }
+ }
+
+ isAutoResolutionOn () {
+ return this.autoResolution
+ }
+
+ enableAutoResolution () {
+ this.autoResolution = true
+ this.trigger('autoResolutionUpdate')
+ }
+
+ disableAutoResolution (forbid = false) {
+ if (forbid === true) this.forbidAutoResolution = true
+
+ this.autoResolution = false
+ this.trigger('autoResolutionUpdate')
+ }
+
+ isAutoResolutionForbidden () {
+ return this.forbidAutoResolution === true
+ }
+
+ getCurrentVideoFile () {
+ return this.currentVideoFile
+ }
+
+ getTorrent () {
+ return this.torrent
+ }
+
+ private addTorrent (
+ magnetOrTorrentUrl: string,
+ previousVideoFile: VideoFile,
+ options: PlayOptions,
+ done: Function
+ ) {