diff options
author | Chocobozzz <me@florianbigard.com> | 2020-08-05 09:44:58 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-08-07 08:58:29 +0200 |
commit | 4572c3d0d92f5b1b79b34dbe2c7b6557a8a5b7e4 (patch) | |
tree | 2c1aa81a536b50d6da0181aba6fce1db972f6191 /client/src/standalone/videos/embed.ts | |
parent | 5abc96fca2496f33075796db208fccc3543e0f65 (diff) | |
download | PeerTube-4572c3d0d92f5b1b79b34dbe2c7b6557a8a5b7e4.tar.gz PeerTube-4572c3d0d92f5b1b79b34dbe2c7b6557a8a5b7e4.tar.zst PeerTube-4572c3d0d92f5b1b79b34dbe2c7b6557a8a5b7e4.zip |
Handle basic playlist in embed
Diffstat (limited to 'client/src/standalone/videos/embed.ts')
-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 }) { |