]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Load embed api resolutions on init
authorChocobozzz <me@florianbigard.com>
Tue, 8 Jun 2021 08:17:47 +0000 (10:17 +0200)
committerChocobozzz <me@florianbigard.com>
Tue, 8 Jun 2021 08:17:47 +0000 (10:17 +0200)
client/src/assets/player/p2p-media-loader/p2p-media-loader-plugin.ts
client/src/standalone/videos/embed-api.ts

index 4275a5e5e49452da487e0eb59a933d65c481f24b..f1bd9f0c41d1b4f812116bbe4ed87875303a4160 100644 (file)
@@ -124,6 +124,10 @@ class P2pMediaLoaderPlugin extends Plugin {
       this.trigger('resolutionChange', { auto: this.hlsjs.autoLevelEnabled, resolutionId: data.height })
     })
 
+    this.hlsjs.on(Hlsjs.Events.MANIFEST_LOADED, (_: any, data: any) => {
+      this.trigger('resolutionsLoaded')
+    })
+
     this.p2pEngine.on(Events.SegmentError, (segment: Segment, err) => {
       console.error('Segment error.', segment, err)
 
index 94e39ec29c4c3e124442da6780c537917787428f..75174f2f8ef2a6eca1362ab52db7d3e7b8234001 100644 (file)
@@ -140,12 +140,14 @@ export class PeerTubeEmbedApi {
     })
 
     // PeerTube specific capabilities
-
     if (this.isWebtorrent()) {
       this.embed.player.webtorrent().on('autoResolutionUpdate', () => this.loadWebTorrentResolutions())
       this.embed.player.webtorrent().on('videoFileUpdate', () => this.loadWebTorrentResolutions())
+
+      this.loadWebTorrentResolutions()
     } else {
       this.embed.player.p2pMediaLoader().on('resolutionChange', () => this.loadP2PMediaLoaderResolutions())
+      this.embed.player.p2pMediaLoader().on('resolutionsLoaded', () => this.loadP2PMediaLoaderResolutions())
     }
 
     this.embed.player.on('volumechange', () => {
@@ -207,6 +209,6 @@ export class PeerTubeEmbedApi {
   }
 
   private isWebtorrent () {
-    return this.embed.player.webtorrent
+    return !!this.embed.player.webtorrent
   }
 }