Verified Commit ffacd78f authored by Chocobozzz's avatar Chocobozzz
Browse files

Load embed api resolutions on init

parent a13df19d
...@@ -124,6 +124,10 @@ class P2pMediaLoaderPlugin extends Plugin { ...@@ -124,6 +124,10 @@ class P2pMediaLoaderPlugin extends Plugin {
this.trigger('resolutionChange', { auto: this.hlsjs.autoLevelEnabled, resolutionId: data.height }) 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) => { this.p2pEngine.on(Events.SegmentError, (segment: Segment, err) => {
console.error('Segment error.', segment, err) console.error('Segment error.', segment, err)
......
...@@ -140,12 +140,14 @@ export class PeerTubeEmbedApi { ...@@ -140,12 +140,14 @@ export class PeerTubeEmbedApi {
}) })
// PeerTube specific capabilities // PeerTube specific capabilities
if (this.isWebtorrent()) { if (this.isWebtorrent()) {
this.embed.player.webtorrent().on('autoResolutionUpdate', () => this.loadWebTorrentResolutions()) this.embed.player.webtorrent().on('autoResolutionUpdate', () => this.loadWebTorrentResolutions())
this.embed.player.webtorrent().on('videoFileUpdate', () => this.loadWebTorrentResolutions()) this.embed.player.webtorrent().on('videoFileUpdate', () => this.loadWebTorrentResolutions())
this.loadWebTorrentResolutions()
} else { } else {
this.embed.player.p2pMediaLoader().on('resolutionChange', () => this.loadP2PMediaLoaderResolutions()) this.embed.player.p2pMediaLoader().on('resolutionChange', () => this.loadP2PMediaLoaderResolutions())
this.embed.player.p2pMediaLoader().on('resolutionsLoaded', () => this.loadP2PMediaLoaderResolutions())
} }
this.embed.player.on('volumechange', () => { this.embed.player.on('volumechange', () => {
...@@ -207,6 +209,6 @@ export class PeerTubeEmbedApi { ...@@ -207,6 +209,6 @@ export class PeerTubeEmbedApi {
} }
private isWebtorrent () { private isWebtorrent () {
return this.embed.player.webtorrent return !!this.embed.player.webtorrent
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment