aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/standalone')
-rw-r--r--client/src/standalone/videos/embed-api.ts41
-rw-r--r--client/src/standalone/videos/test-embed.ts2
2 files changed, 5 insertions, 38 deletions
diff --git a/client/src/standalone/videos/embed-api.ts b/client/src/standalone/videos/embed-api.ts
index 8443cb7e9..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[] {
@@ -142,6 +135,8 @@ export class PeerTubeEmbedApi {
142 this.embed.player.peertubeResolutions().on('resolutionsAdded', () => this.loadResolutions()) 135 this.embed.player.peertubeResolutions().on('resolutionsAdded', () => this.loadResolutions())
143 this.embed.player.peertubeResolutions().on('resolutionChanged', () => this.loadResolutions()) 136 this.embed.player.peertubeResolutions().on('resolutionChanged', () => this.loadResolutions())
144 137
138 this.loadResolutions()
139
145 this.embed.player.on('volumechange', () => { 140 this.embed.player.on('volumechange', () => {
146 this.channel.notify({ 141 this.channel.notify({
147 method: 'volumeChange', 142 method: 'volumeChange',
@@ -150,37 +145,11 @@ export class PeerTubeEmbedApi {
150 }) 145 })
151 } 146 }
152 147
153 private loadWebTorrentResolutions () {
154 this.resolutions = []
155
156 const currentResolutionId = this.embed.player.webtorrent().getCurrentResolutionId()
157
158 for (const videoFile of this.embed.player.webtorrent().videoFiles) {
159 let label = videoFile.resolution.label
160 if (videoFile.fps && videoFile.fps >= 50) {
161 label += videoFile.fps
162 }
163
164 this.resolutions.push({
165 id: videoFile.resolution.id,
166 label,
167 src: videoFile.magnetUri,
168 active: videoFile.resolution.id === currentResolutionId,
169 height: videoFile.resolution.id
170 })
171 }
172
173 this.channel.notify({
174 method: 'resolutionUpdate',
175 params: this.resolutions
176 })
177 }
178
179 private loadResolutions () { 148 private loadResolutions () {
180 this.resolutions = this.embed.player.peertubeResolutions().getResolutions() 149 this.resolutions = this.embed.player.peertubeResolutions().getResolutions()
181 .map(r => ({ 150 .map(r => ({
182 id: r.id, 151 id: r.id,
183 label: r.height + 'p', 152 label: r.label,
184 active: r.selected, 153 active: r.selected,
185 width: r.width, 154 width: r.width,
186 height: r.height 155 height: r.height
diff --git a/client/src/standalone/videos/test-embed.ts b/client/src/standalone/videos/test-embed.ts
index 301c95d7b..7213cbf8b 100644
--- a/client/src/standalone/videos/test-embed.ts
+++ b/client/src/standalone/videos/test-embed.ts
@@ -84,8 +84,6 @@ window.addEventListener('load', async () => {
84 captionEl.innerHTML = '' 84 captionEl.innerHTML = ''
85 85
86 captions.forEach(c => { 86 captions.forEach(c => {
87 console.log(c)
88
89 if (c.mode === 'showing') { 87 if (c.mode === 'showing') {
90 const itemEl = document.createElement('strong') 88 const itemEl = document.createElement('strong')
91 itemEl.innerText = `${c.label} (active)` 89 itemEl.innerText = `${c.label} (active)`