aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-11 09:37:30 +0200
committerChocobozzz <me@florianbigard.com>2021-10-11 09:37:30 +0200
commitd00e9c54f341547f0874015953f203da90846fa7 (patch)
tree40d6f8dda05ac192bfba2859e34ba443e8428d33 /client/src/standalone
parenteecd7ac359178698142717d96a086e511f3363e5 (diff)
parent89ac282e0437ae839e3d71566f25321f9b9384e9 (diff)
downloadPeerTube-d00e9c54f341547f0874015953f203da90846fa7.tar.gz
PeerTube-d00e9c54f341547f0874015953f203da90846fa7.tar.zst
PeerTube-d00e9c54f341547f0874015953f203da90846fa7.zip
Merge branch 'next' into develop
Diffstat (limited to 'client/src/standalone')
-rw-r--r--client/src/standalone/videos/embed-api.ts74
-rw-r--r--client/src/standalone/videos/test-embed.ts2
2 files changed, 14 insertions, 62 deletions
diff --git a/client/src/standalone/videos/embed-api.ts b/client/src/standalone/videos/embed-api.ts
index b5c9da431..a28aeeaef 100644
--- a/client/src/standalone/videos/embed-api.ts
+++ b/client/src/standalone/videos/embed-api.ts
@@ -64,19 +64,12 @@ export class PeerTubeEmbedApi {
64 if (this.isWebtorrent()) { 64 if (this.isWebtorrent()) {
65 if (resolutionId === -1 && this.embed.player.webtorrent().isAutoResolutionPossible() === false) return 65 if (resolutionId === -1 && this.embed.player.webtorrent().isAutoResolutionPossible() === false) return
66 66
67 // Auto resolution 67 this.embed.player.webtorrent().changeQuality(resolutionId)
68 if (resolutionId === -1) {
69 this.embed.player.webtorrent().enableAutoResolution()
70 return
71 }
72
73 this.embed.player.webtorrent().disableAutoResolution()
74 this.embed.player.webtorrent().updateResolution(resolutionId)
75 68
76 return 69 return
77 } 70 }
78 71
79 this.embed.player.p2pMediaLoader().getHLSJS().nextLevel = resolutionId 72 this.embed.player.p2pMediaLoader().getHLSJS().currentLevel = resolutionId
80 } 73 }
81 74
82 private getCaptions (): PeerTubeTextTrack[] { 75 private getCaptions (): PeerTubeTextTrack[] {
@@ -139,15 +132,10 @@ export class PeerTubeEmbedApi {
139 }) 132 })
140 133
141 // PeerTube specific capabilities 134 // PeerTube specific capabilities
142 if (this.isWebtorrent()) { 135 this.embed.player.peertubeResolutions().on('resolutionsAdded', () => this.loadResolutions())
143 this.embed.player.webtorrent().on('autoResolutionUpdate', () => this.loadWebTorrentResolutions()) 136 this.embed.player.peertubeResolutions().on('resolutionChanged', () => this.loadResolutions())
144 this.embed.player.webtorrent().on('videoFileUpdate', () => this.loadWebTorrentResolutions())
145 137
146 this.loadWebTorrentResolutions() 138 this.loadResolutions()
147 } else {
148 this.embed.player.p2pMediaLoader().on('resolutionChange', () => this.loadP2PMediaLoaderResolutions())
149 this.embed.player.p2pMediaLoader().on('resolutionsLoaded', () => this.loadP2PMediaLoaderResolutions())
150 }
151 139
152 this.embed.player.on('volumechange', () => { 140 this.embed.player.on('volumechange', () => {
153 this.channel.notify({ 141 this.channel.notify({
@@ -157,49 +145,15 @@ export class PeerTubeEmbedApi {
157 }) 145 })
158 } 146 }
159 147
160 private loadWebTorrentResolutions () { 148 private loadResolutions () {
161 this.resolutions = [] 149 this.resolutions = this.embed.player.peertubeResolutions().getResolutions()
162 150 .map(r => ({
163 const currentResolutionId = this.embed.player.webtorrent().getCurrentResolutionId() 151 id: r.id,
164 152 label: r.label,
165 for (const videoFile of this.embed.player.webtorrent().videoFiles) { 153 active: r.selected,
166 let label = videoFile.resolution.label 154 width: r.width,
167 if (videoFile.fps && videoFile.fps >= 50) { 155 height: r.height
168 label += videoFile.fps 156 }))
169 }
170
171 this.resolutions.push({
172 id: videoFile.resolution.id,
173 label,
174 src: videoFile.magnetUri,
175 active: videoFile.resolution.id === currentResolutionId,
176 height: videoFile.resolution.id
177 })
178 }
179
180 this.channel.notify({
181 method: 'resolutionUpdate',
182 params: this.resolutions
183 })
184 }
185
186 private loadP2PMediaLoaderResolutions () {
187 this.resolutions = []
188
189 const qualityLevels = this.embed.player.qualityLevels()
190 const currentResolutionId = this.embed.player.qualityLevels().selectedIndex
191
192 for (let i = 0; i < qualityLevels.length; i++) {
193 const level = qualityLevels[i]
194
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 157
204 this.channel.notify({ 158 this.channel.notify({
205 method: 'resolutionUpdate', 159 method: 'resolutionUpdate',
diff --git a/client/src/standalone/videos/test-embed.ts b/client/src/standalone/videos/test-embed.ts
index a28a83cc1..18c338a2d 100644
--- a/client/src/standalone/videos/test-embed.ts
+++ b/client/src/standalone/videos/test-embed.ts
@@ -86,8 +86,6 @@ window.addEventListener('load', async () => {
86 captionEl.innerHTML = '' 86 captionEl.innerHTML = ''
87 87
88 captions.forEach(c => { 88 captions.forEach(c => {
89 console.log(c)
90
91 if (c.mode === 'showing') { 89 if (c.mode === 'showing') {
92 const itemEl = document.createElement('strong') 90 const itemEl = document.createElement('strong')
93 itemEl.innerText = `${c.label} (active)` 91 itemEl.innerText = `${c.label} (active)`