aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-05 14:00:36 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-08-07 08:58:29 +0200
commit2a71d286cec31964e0b70b5a7c53bfad401af554 (patch)
tree7468eaddc22df34fcfba1b90b65df6cb90963a2a /client
parentfb13852d30766961f7bcc2e9d1edd2393d0b5731 (diff)
downloadPeerTube-2a71d286cec31964e0b70b5a7c53bfad401af554.tar.gz
PeerTube-2a71d286cec31964e0b70b5a7c53bfad401af554.tar.zst
PeerTube-2a71d286cec31964e0b70b5a7c53bfad401af554.zip
Handle playlist position in URL
Diffstat (limited to 'client')
-rw-r--r--client/src/standalone/videos/embed.ts27
1 files changed, 25 insertions, 2 deletions
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index a2902ce58..7372c80c6 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -179,6 +179,8 @@ export class PeerTubeEmbed {
179 179
180 const errorText = document.getElementById('error-content') 180 const errorText = document.getElementById('error-content')
181 errorText.innerHTML = translatedText 181 errorText.innerHTML = translatedText
182
183 this.wrapperElement.style.display = 'none'
182 } 184 }
183 185
184 videoNotFound (translations?: Translations) { 186 videoNotFound (translations?: Translations) {
@@ -395,7 +397,7 @@ export class PeerTubeEmbed {
395 } 397 }
396 398
397 private getPreviousPlaylistElement (position?: number): VideoPlaylistElement { 399 private getPreviousPlaylistElement (position?: number): VideoPlaylistElement {
398 if (!position) position = this.currentPlaylistElement.position -1 400 if (!position) position = this.currentPlaylistElement.position - 1
399 401
400 if (position < 1) { 402 if (position < 1) {
401 return undefined 403 return undefined
@@ -561,7 +563,28 @@ export class PeerTubeEmbed {
561 const playlistElementResult = await res.videosResponse.json() 563 const playlistElementResult = await res.videosResponse.json()
562 this.playlistElements = await this.loadAllPlaylistVideos(playlistId, playlistElementResult) 564 this.playlistElements = await this.loadAllPlaylistVideos(playlistId, playlistElementResult)
563 565
564 this.currentPlaylistElement = this.playlistElements[0] 566 const params = new URL(window.location.toString()).searchParams
567 const playlistPositionParam = this.getParamString(params, 'playlistPosition')
568
569 let position = 1
570
571 if (playlistPositionParam) {
572 position = parseInt(playlistPositionParam + '', 10)
573 }
574
575 this.currentPlaylistElement = this.playlistElements.find(e => e.position === position)
576 if (!this.currentPlaylistElement || !this.currentPlaylistElement.video) {
577 console.error('Current playlist element is not valid.', this.currentPlaylistElement)
578 this.currentPlaylistElement = this.getNextPlaylistElement()
579 }
580
581 if (!this.currentPlaylistElement) {
582 console.error('This playlist does not have any valid element.')
583 const serverTranslations = await this.translationsPromise
584 this.playlistFetchError(serverTranslations)
585 return
586 }
587
565 videoId = this.currentPlaylistElement.video.uuid 588 videoId = this.currentPlaylistElement.video.uuid
566 } else { 589 } else {
567 videoId = this.getResourceId() 590 videoId = this.getResourceId()