aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone/videos/embed.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/standalone/videos/embed.ts')
-rw-r--r--client/src/standalone/videos/embed.ts54
1 files changed, 30 insertions, 24 deletions
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index 7372c80c6..a7fb087b1 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -211,6 +211,36 @@ export class PeerTubeEmbed {
211 return params.has(name) ? params.get(name) : defaultValue 211 return params.has(name) ? params.get(name) : defaultValue
212 } 212 }
213 213
214 async playNextVideo () {
215 const next = this.getNextPlaylistElement()
216 if (!next) {
217 console.log('Next element not found in playlist.')
218 return
219 }
220
221 this.currentPlaylistElement = next
222
223 return this.loadVideoAndBuildPlayer(this.currentPlaylistElement.video.uuid)
224 }
225
226 async playPreviousVideo () {
227 const previous = this.getPreviousPlaylistElement()
228 if (!previous) {
229 console.log('Previous element not found in playlist.')
230 return
231 }
232
233 this.currentPlaylistElement = previous
234
235 await this.loadVideoAndBuildPlayer(this.currentPlaylistElement.video.uuid)
236 }
237
238 getCurrentPosition () {
239 if (!this.currentPlaylistElement) return -1
240
241 return this.currentPlaylistElement.position
242 }
243
214 async init () { 244 async init () {
215 try { 245 try {
216 this.userTokens = Tokens.load() 246 this.userTokens = Tokens.load()
@@ -342,30 +372,6 @@ export class PeerTubeEmbed {
342 }) 372 })
343 } 373 }
344 374
345 private async playNextVideo () {
346 const next = this.getNextPlaylistElement()
347 if (!next) {
348 console.log('Next element not found in playlist.')
349 return
350 }
351
352 this.currentPlaylistElement = next
353
354 return this.loadVideoAndBuildPlayer(this.currentPlaylistElement.video.uuid)
355 }
356
357 private async playPreviousVideo () {
358 const previous = this.getPreviousPlaylistElement()
359 if (!previous) {
360 console.log('Previous element not found in playlist.')
361 return
362 }
363
364 this.currentPlaylistElement = previous
365
366 return this.loadVideoAndBuildPlayer(this.currentPlaylistElement.video.uuid)
367 }
368
369 private async loadVideoAndBuildPlayer (uuid: string) { 375 private async loadVideoAndBuildPlayer (uuid: string) {
370 const res = await this.loadVideo(uuid) 376 const res = await this.loadVideo(uuid)
371 if (res === undefined) return 377 if (res === undefined) return