X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fassets%2Fplayer%2Fwebtorrent%2Fwebtorrent-plugin.ts;h=e557fe722e3f7d81989d8d0769355fcb02548fcd;hb=d61893f7236abbed30c25b1823e6ecad93a8e8dd;hp=96ba497a05dce8dba66c70574bb9d14efd801583;hpb=171528373e89560b3c396bc0d510d013e1f9c28e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/assets/player/webtorrent/webtorrent-plugin.ts b/client/src/assets/player/webtorrent/webtorrent-plugin.ts index 96ba497a0..e557fe722 100644 --- a/client/src/assets/player/webtorrent/webtorrent-plugin.ts +++ b/client/src/assets/player/webtorrent/webtorrent-plugin.ts @@ -132,13 +132,17 @@ class WebTorrentPlugin extends Plugin { done: () => void = () => { /* empty */ } ) { // Automatically choose the adapted video file - if (videoFile === undefined) { + if (!videoFile) { const savedAverageBandwidth = getAverageBandwidthInStore() videoFile = savedAverageBandwidth ? this.getAppropriateFile(savedAverageBandwidth) : this.pickAverageVideoFile() } + if (!videoFile) { + throw Error(`Can't update video file since videoFile is undefined.`) + } + // Don't add the same video file once again if (this.currentVideoFile !== undefined && this.currentVideoFile.magnetUri === videoFile.magnetUri) { return @@ -245,6 +249,8 @@ class WebTorrentPlugin extends Plugin { options: PlayOptions, done: Function ) { + if (!magnetOrTorrentUrl) return this.fallbackToHttp(options, done) + console.log('Adding ' + magnetOrTorrentUrl + '.') const oldTorrent = this.torrent