diff options
Diffstat (limited to 'client/src/standalone')
-rw-r--r-- | client/src/standalone/videos/embed.ts | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 71bd04e76..17b0ee9ef 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts | |||
@@ -324,7 +324,11 @@ export class PeerTubeEmbed { | |||
324 | 324 | ||
325 | this.currentPlaylistElement = next | 325 | this.currentPlaylistElement = next |
326 | 326 | ||
327 | const res = await this.loadVideo(this.currentPlaylistElement.video.uuid) | 327 | return this.loadVideoAndBuildPlayer(this.currentPlaylistElement.video.uuid) |
328 | } | ||
329 | |||
330 | private async loadVideoAndBuildPlayer (uuid: string) { | ||
331 | const res = await this.loadVideo(uuid) | ||
328 | if (res === undefined) return | 332 | if (res === undefined) return |
329 | 333 | ||
330 | return this.buildVideoPlayer(res.videoResponse, res.captionsPromise) | 334 | return this.buildVideoPlayer(res.videoResponse, res.captionsPromise) |
@@ -386,6 +390,22 @@ export class PeerTubeEmbed { | |||
386 | 390 | ||
387 | this.loadParams(videoInfo) | 391 | this.loadParams(videoInfo) |
388 | 392 | ||
393 | const playlistPlugin = this.currentPlaylistElement | ||
394 | ? { | ||
395 | elements: this.playlistElements, | ||
396 | playlist: this.playlist, | ||
397 | |||
398 | getCurrentPosition: () => this.currentPlaylistElement.position, | ||
399 | |||
400 | onItemClicked: (videoPlaylistElement: VideoPlaylistElement) => { | ||
401 | this.currentPlaylistElement = videoPlaylistElement | ||
402 | |||
403 | this.loadVideoAndBuildPlayer(this.currentPlaylistElement.video.uuid) | ||
404 | .catch(err => console.error(err)) | ||
405 | } | ||
406 | } | ||
407 | : undefined | ||
408 | |||
389 | const options: PeertubePlayerManagerOptions = { | 409 | const options: PeertubePlayerManagerOptions = { |
390 | common: { | 410 | common: { |
391 | // Autoplay in playlist mode | 411 | // Autoplay in playlist mode |
@@ -399,6 +419,7 @@ export class PeerTubeEmbed { | |||
399 | subtitle: this.subtitle, | 419 | subtitle: this.subtitle, |
400 | 420 | ||
401 | nextVideo: () => this.autoplayNext(), | 421 | nextVideo: () => this.autoplayNext(), |
422 | playlist: playlistPlugin, | ||
402 | 423 | ||
403 | videoCaptions, | 424 | videoCaptions, |
404 | inactivityTimeout: 2500, | 425 | inactivityTimeout: 2500, |
@@ -452,6 +473,7 @@ export class PeerTubeEmbed { | |||
452 | 473 | ||
453 | if (this.isPlaylistEmbed()) { | 474 | if (this.isPlaylistEmbed()) { |
454 | await this.buildPlaylistManager() | 475 | await this.buildPlaylistManager() |
476 | this.player.playlist().updateSelected() | ||
455 | } | 477 | } |
456 | } | 478 | } |
457 | 479 | ||
@@ -480,10 +502,7 @@ export class PeerTubeEmbed { | |||
480 | videoId = this.getResourceId() | 502 | videoId = this.getResourceId() |
481 | } | 503 | } |
482 | 504 | ||
483 | const res = await this.loadVideo(videoId) | 505 | return this.loadVideoAndBuildPlayer(videoId) |
484 | if (res === undefined) return | ||
485 | |||
486 | return this.buildVideoPlayer(res.videoResponse, res.captionsPromise) | ||
487 | } | 506 | } |
488 | 507 | ||
489 | private handleError (err: Error, translations?: { [ id: string ]: string }) { | 508 | private handleError (err: Error, translations?: { [ id: string ]: string }) { |