aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-09-06 16:08:59 +0200
committerChocobozzz <me@florianbigard.com>2021-09-10 15:06:57 +0200
commite367da949bb97c3db8c2f9a28ea09eef93abb2f5 (patch)
tree49efec8135840525eedeee45fd914b77542534f9 /client/src/standalone
parent4d3e611dd2764d1d5d0a7e777312631e1e7005d4 (diff)
downloadPeerTube-e367da949bb97c3db8c2f9a28ea09eef93abb2f5.tar.gz
PeerTube-e367da949bb97c3db8c2f9a28ea09eef93abb2f5.tar.zst
PeerTube-e367da949bb97c3db8c2f9a28ea09eef93abb2f5.zip
Cleanup player quality change
Diffstat (limited to 'client/src/standalone')
-rw-r--r--client/src/standalone/videos/embed-api.ts37
1 files changed, 11 insertions, 26 deletions
diff --git a/client/src/standalone/videos/embed-api.ts b/client/src/standalone/videos/embed-api.ts
index b5c9da431..8443cb7e9 100644
--- a/client/src/standalone/videos/embed-api.ts
+++ b/client/src/standalone/videos/embed-api.ts
@@ -139,15 +139,8 @@ export class PeerTubeEmbedApi {
139 }) 139 })
140 140
141 // PeerTube specific capabilities 141 // PeerTube specific capabilities
142 if (this.isWebtorrent()) { 142 this.embed.player.peertubeResolutions().on('resolutionsAdded', () => this.loadResolutions())
143 this.embed.player.webtorrent().on('autoResolutionUpdate', () => this.loadWebTorrentResolutions()) 143 this.embed.player.peertubeResolutions().on('resolutionChanged', () => this.loadResolutions())
144 this.embed.player.webtorrent().on('videoFileUpdate', () => this.loadWebTorrentResolutions())
145
146 this.loadWebTorrentResolutions()
147 } else {
148 this.embed.player.p2pMediaLoader().on('resolutionChange', () => this.loadP2PMediaLoaderResolutions())
149 this.embed.player.p2pMediaLoader().on('resolutionsLoaded', () => this.loadP2PMediaLoaderResolutions())
150 }
151 144
152 this.embed.player.on('volumechange', () => { 145 this.embed.player.on('volumechange', () => {
153 this.channel.notify({ 146 this.channel.notify({
@@ -183,23 +176,15 @@ export class PeerTubeEmbedApi {
183 }) 176 })
184 } 177 }
185 178
186 private loadP2PMediaLoaderResolutions () { 179 private loadResolutions () {
187 this.resolutions = [] 180 this.resolutions = this.embed.player.peertubeResolutions().getResolutions()
188 181 .map(r => ({
189 const qualityLevels = this.embed.player.qualityLevels() 182 id: r.id,
190 const currentResolutionId = this.embed.player.qualityLevels().selectedIndex 183 label: r.height + 'p',
191 184 active: r.selected,
192 for (let i = 0; i < qualityLevels.length; i++) { 185 width: r.width,
193 const level = qualityLevels[i] 186 height: r.height
194 187 }))
195 this.resolutions.push({
196 id: level.id,
197 label: level.height + 'p',
198 active: level.id === currentResolutionId,
199 width: level.width,
200 height: level.height
201 })
202 }
203 188
204 this.channel.notify({ 189 this.channel.notify({
205 method: 'resolutionUpdate', 190 method: 'resolutionUpdate',