diff options
Diffstat (limited to 'client/src/standalone/videos')
-rw-r--r-- | client/src/standalone/videos/embed.ts | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 7daa03f23..3a09f285e 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts | |||
@@ -157,10 +157,11 @@ class PeerTubeEmbed { | |||
157 | player: any | 157 | player: any |
158 | playerOptions: any | 158 | playerOptions: any |
159 | api: PeerTubeEmbedApi = null | 159 | api: PeerTubeEmbedApi = null |
160 | autoplay = false | 160 | autoplay: boolean |
161 | controls = true | 161 | controls: boolean |
162 | muted = false | 162 | muted: boolean |
163 | loop = false | 163 | loop: boolean |
164 | subtitle: string | ||
164 | enableApi = false | 165 | enableApi = false |
165 | startTime: number | string = 0 | 166 | startTime: number | string = 0 |
166 | scope = 'peertube' | 167 | scope = 'peertube' |
@@ -214,11 +215,11 @@ class PeerTubeEmbed { | |||
214 | this.displayError(text) | 215 | this.displayError(text) |
215 | } | 216 | } |
216 | 217 | ||
217 | getParamToggle (params: URLSearchParams, name: string, defaultValue: boolean) { | 218 | getParamToggle (params: URLSearchParams, name: string, defaultValue?: boolean) { |
218 | return params.has(name) ? (params.get(name) === '1' || params.get(name) === 'true') : defaultValue | 219 | return params.has(name) ? (params.get(name) === '1' || params.get(name) === 'true') : defaultValue |
219 | } | 220 | } |
220 | 221 | ||
221 | getParamString (params: URLSearchParams, name: string, defaultValue: string) { | 222 | getParamString (params: URLSearchParams, name: string, defaultValue?: string) { |
222 | return params.has(name) ? params.get(name) : defaultValue | 223 | return params.has(name) ? params.get(name) : defaultValue |
223 | } | 224 | } |
224 | 225 | ||
@@ -241,15 +242,15 @@ class PeerTubeEmbed { | |||
241 | try { | 242 | try { |
242 | let params = new URL(window.location.toString()).searchParams | 243 | let params = new URL(window.location.toString()).searchParams |
243 | 244 | ||
244 | this.autoplay = this.getParamToggle(params, 'autoplay', this.autoplay) | 245 | this.autoplay = this.getParamToggle(params, 'autoplay') |
245 | this.controls = this.getParamToggle(params, 'controls', this.controls) | 246 | this.controls = this.getParamToggle(params, 'controls') |
246 | this.muted = this.getParamToggle(params, 'muted', this.muted) | 247 | this.muted = this.getParamToggle(params, 'muted') |
247 | this.loop = this.getParamToggle(params, 'loop', this.loop) | 248 | this.loop = this.getParamToggle(params, 'loop') |
248 | this.enableApi = this.getParamToggle(params, 'api', this.enableApi) | 249 | this.enableApi = this.getParamToggle(params, 'api', this.enableApi) |
249 | this.scope = this.getParamString(params, 'scope', this.scope) | ||
250 | 250 | ||
251 | const startTimeParamString = params.get('start') | 251 | this.scope = this.getParamString(params, 'scope', this.scope) |
252 | if (startTimeParamString) this.startTime = startTimeParamString | 252 | this.subtitle = this.getParamString(params, 'subtitle') |
253 | this.startTime = this.getParamString(params, 'start') | ||
253 | } catch (err) { | 254 | } catch (err) { |
254 | console.error('Cannot get params from URL.', err) | 255 | console.error('Cannot get params from URL.', err) |
255 | } | 256 | } |
@@ -291,6 +292,7 @@ class PeerTubeEmbed { | |||
291 | muted: this.muted, | 292 | muted: this.muted, |
292 | loop: this.loop, | 293 | loop: this.loop, |
293 | startTime: this.startTime, | 294 | startTime: this.startTime, |
295 | subtitle: this.subtitle, | ||
294 | 296 | ||
295 | videoCaptions, | 297 | videoCaptions, |
296 | inactivityTimeout: 1500, | 298 | inactivityTimeout: 1500, |