Fix webtorrent player
authorChocobozzz <me@florianbigard.com>
Tue, 30 Jul 2019 08:54:14 +0000 (10:54 +0200)
committerChocobozzz <me@florianbigard.com>
Tue, 30 Jul 2019 08:54:14 +0000 (10:54 +0200)
client/package.json
client/src/assets/player/webtorrent/video-renderer.ts
client/src/assets/player/webtorrent/webtorrent-plugin.ts
client/yarn.lock

index f770be5fe3a1eed084f9f5674aafc39a58c54530..5d733f1b8ac0d6816572c12ad3244dfc7f4a2ec2 100644 (file)
     "videojs-contrib-quality-levels": "^2.0.9",
     "videojs-dock": "^2.0.2",
     "videojs-hotkeys": "^0.2.21",
+    "videostream": "~3.1",
     "webpack-bundle-analyzer": "^3.0.2",
     "webpack-cli": "^3.0.8",
     "webtorrent": "^0.105.1",
index 4dce871124ae3d8b44ee78ea8f0980c164d23e18..c3cbea7256fba1ac5ab75a035435354db446d518 100644 (file)
@@ -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) {
index eee3d4db9fd492b11a75a496e7b0f86bbbf27294..95f52dfe193ab41b099dfbc098f28e8182f3b5da 100644 (file)
@@ -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 => {
index c93872a1708f25723ab9fa513bbc2e3161c47d8e..714e5c5cc3ae82a07d44ed65677bed12dae5cc13 100644 (file)
@@ -5779,7 +5779,7 @@ move-concurrently@^1.0.1:
     rimraf "^2.5.4"
     run-queue "^1.0.3"
 
-mp4-box-encoding@^1.3.0:
+mp4-box-encoding@^1.1.0, mp4-box-encoding@^1.3.0:
   version "1.3.0"
   resolved "https://registry.yarnpkg.com/mp4-box-encoding/-/mp4-box-encoding-1.3.0.tgz#2a6f750947ff68c3a498fd76cd6424c53d995d48"
   integrity sha512-U4pMLpjT/UzB8d36dxj6Mf1bG9xypEvgbuRIa1fztRXNKKTCAtRxsnFZhNOd7YDFOKtjBgssYGvo4H/Q3ZY1MA==
@@ -5788,6 +5788,17 @@ mp4-box-encoding@^1.3.0:
     buffer-from "^1.1.0"
     uint64be "^2.0.2"
 
+mp4-stream@^2.0.0:
+  version "2.0.3"
+  resolved "https://registry.yarnpkg.com/mp4-stream/-/mp4-stream-2.0.3.tgz#30acee07709d323f8dcd87a07b3ce9c3c4bfb364"
+  integrity sha512-5NzgI0+bGakoZEwnIYINXqB3mnewkt3Y7jcvkXsTubnCNUSdM8cpP0Vemxf6FLg0qUN8fydTgNMVAc3QU8B92g==
+  dependencies:
+    buffer-alloc "^1.1.0"
+    inherits "^2.0.1"
+    mp4-box-encoding "^1.1.0"
+    next-event "^1.0.0"
+    readable-stream "^2.0.3"
+
 mp4-stream@^3.0.0:
   version "3.0.0"
   resolved "https://registry.yarnpkg.com/mp4-stream/-/mp4-stream-3.0.0.tgz#8a2be63abe7fe8b57e28bf538e486b076880c485"
@@ -5835,6 +5846,14 @@ multicast-dns@^6.0.1:
     dns-packet "^1.3.1"
     thunky "^1.0.2"
 
+multistream@^2.0.2:
+  version "2.1.1"
+  resolved "https://registry.yarnpkg.com/multistream/-/multistream-2.1.1.tgz#629d3a29bd76623489980d04519a2c365948148c"
+  integrity sha512-xasv76hl6nr1dEy3lPvy7Ej7K/Lx3O/FCvwge8PeVJpciPPoNCbaANcNiBug3IpdvTveZUcAV0DJzdnUDMesNQ==
+  dependencies:
+    inherits "^2.0.1"
+    readable-stream "^2.0.5"
+
 multistream@^3.0.0:
   version "3.0.0"
   resolved "https://registry.yarnpkg.com/multistream/-/multistream-3.0.0.tgz#93d6a672828c311a5b228212d319a5e9073d2e45"
@@ -7257,7 +7276,7 @@ read-pkg@^2.0.0:
     normalize-package-data "^2.3.2"
     path-type "^2.0.0"
 
-"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.4, readable-stream@^2.3.6, readable-stream@~2.3.6:
+"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.3, readable-stream@^2.0.4, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.4, readable-stream@^2.3.6, readable-stream@~2.3.6:
   version "2.3.6"
   resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"
   integrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==
@@ -9251,6 +9270,19 @@ videostream@^3.2.0:
     pump "^3.0.0"
     range-slice-stream "^2.0.0"
 
+videostream@~3.1:
+  version "3.1.0"
+  resolved "https://registry.yarnpkg.com/videostream/-/videostream-3.1.0.tgz#a265ea9bb94462604c3a480920ed0fae1e1fe5b9"
+  integrity sha512-xCIjdqCyYnFxUAYs52GxheAAPO9V+hTQKs/yBUUGFK94db+kJ28B2hvDCnXACEnhX4hf9Cq7G3bVS+fOMpvXKw==
+  dependencies:
+    binary-search "^1.3.4"
+    mediasource "^2.2.2"
+    mp4-box-encoding "^1.3.0"
+    mp4-stream "^2.0.0"
+    multistream "^2.0.2"
+    pump "^3.0.0"
+    range-slice-stream "^2.0.0"
+
 vm-browserify@^1.0.1:
   version "1.1.0"
   resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.0.tgz#bd76d6a23323e2ca8ffa12028dc04559c75f9019"