From 85394ba22a07bde1dfccebf3f591a5d6dbe9df56 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 30 Jul 2019 10:54:14 +0200 Subject: Fix webtorrent player --- client/src/assets/player/webtorrent/video-renderer.ts | 2 +- client/src/assets/player/webtorrent/webtorrent-plugin.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'client/src/assets/player') diff --git a/client/src/assets/player/webtorrent/video-renderer.ts b/client/src/assets/player/webtorrent/video-renderer.ts index 4dce87112..c3cbea725 100644 --- a/client/src/assets/player/webtorrent/video-renderer.ts +++ b/client/src/assets/player/webtorrent/video-renderer.ts @@ -51,7 +51,7 @@ function renderMedia (file: any, elem: HTMLVideoElement, opts: RenderMediaOption return callback(err) }) preparedElem.addEventListener('loadstart', onLoadStart) - return videostream(file, preparedElem) + return new videostream(file, preparedElem) } function useMediaSource (useVP9 = false) { diff --git a/client/src/assets/player/webtorrent/webtorrent-plugin.ts b/client/src/assets/player/webtorrent/webtorrent-plugin.ts index eee3d4db9..95f52dfe1 100644 --- a/client/src/assets/player/webtorrent/webtorrent-plugin.ts +++ b/client/src/assets/player/webtorrent/webtorrent-plugin.ts @@ -234,9 +234,12 @@ class WebTorrentPlugin extends Plugin { const oldTorrent = this.torrent const torrentOptions = { - store: (chunkLength: number, storeOpts: any) => new CacheChunkStore(new PeertubeChunkStore(chunkLength, storeOpts), { - max: 100 - }) + // Don't use arrow function: it breaks webtorrent (that uses `new` keyword) + store: function (chunkLength: number, storeOpts: any) { + return new CacheChunkStore(new PeertubeChunkStore(chunkLength, storeOpts), { + max: 100 + }) + } } this.torrent = this.webtorrent.add(magnetOrTorrentUrl, torrentOptions, torrent => { -- cgit v1.2.3