diff options
author | Chocobozzz <me@florianbigard.com> | 2023-06-05 11:13:38 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-06-29 10:17:59 +0200 |
commit | 638a2950215af1f11be8e8bdd136ca12e5176c32 (patch) | |
tree | 0bbbd3759ab0af38bc002c9397b5b18e79e6ef8d /client/src/standalone/videos/shared/player-manager-options.ts | |
parent | 52807a075fdc4933d20e882844f7835e9c38afeb (diff) | |
download | PeerTube-638a2950215af1f11be8e8bdd136ca12e5176c32.tar.gz PeerTube-638a2950215af1f11be8e8bdd136ca12e5176c32.tar.zst PeerTube-638a2950215af1f11be8e8bdd136ca12e5176c32.zip |
Support storyboards in embed
Diffstat (limited to 'client/src/standalone/videos/shared/player-manager-options.ts')
-rw-r--r-- | client/src/standalone/videos/shared/player-manager-options.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/client/src/standalone/videos/shared/player-manager-options.ts b/client/src/standalone/videos/shared/player-manager-options.ts index 587516410..3c7521bc2 100644 --- a/client/src/standalone/videos/shared/player-manager-options.ts +++ b/client/src/standalone/videos/shared/player-manager-options.ts | |||
@@ -2,6 +2,7 @@ import { peertubeTranslate } from '../../../../../shared/core-utils/i18n' | |||
2 | import { | 2 | import { |
3 | HTMLServerConfig, | 3 | HTMLServerConfig, |
4 | LiveVideo, | 4 | LiveVideo, |
5 | Storyboard, | ||
5 | Video, | 6 | Video, |
6 | VideoCaption, | 7 | VideoCaption, |
7 | VideoDetails, | 8 | VideoDetails, |
@@ -155,6 +156,9 @@ export class PlayerManagerOptions { | |||
155 | async getPlayerOptions (options: { | 156 | async getPlayerOptions (options: { |
156 | video: VideoDetails | 157 | video: VideoDetails |
157 | captionsResponse: Response | 158 | captionsResponse: Response |
159 | |||
160 | storyboardsResponse: Response | ||
161 | |||
158 | live?: LiveVideo | 162 | live?: LiveVideo |
159 | 163 | ||
160 | forceAutoplay: boolean | 164 | forceAutoplay: boolean |
@@ -187,11 +191,15 @@ export class PlayerManagerOptions { | |||
187 | forceAutoplay, | 191 | forceAutoplay, |
188 | playlistTracker, | 192 | playlistTracker, |
189 | live, | 193 | live, |
194 | storyboardsResponse, | ||
190 | authorizationHeader, | 195 | authorizationHeader, |
191 | serverConfig | 196 | serverConfig |
192 | } = options | 197 | } = options |
193 | 198 | ||
194 | const videoCaptions = await this.buildCaptions(captionsResponse, translations) | 199 | const [ videoCaptions, storyboard ] = await Promise.all([ |
200 | this.buildCaptions(captionsResponse, translations), | ||
201 | this.buildStoryboard(storyboardsResponse) | ||
202 | ]) | ||
195 | 203 | ||
196 | const playerOptions: PeertubePlayerManagerOptions = { | 204 | const playerOptions: PeertubePlayerManagerOptions = { |
197 | common: { | 205 | common: { |
@@ -210,6 +218,8 @@ export class PlayerManagerOptions { | |||
210 | captions: videoCaptions.length !== 0, | 218 | captions: videoCaptions.length !== 0, |
211 | subtitle: this.subtitle, | 219 | subtitle: this.subtitle, |
212 | 220 | ||
221 | storyboard, | ||
222 | |||
213 | startTime: playlistTracker | 223 | startTime: playlistTracker |
214 | ? playlistTracker.getCurrentElement().startTimestamp | 224 | ? playlistTracker.getCurrentElement().startTimestamp |
215 | : this.startTime, | 225 | : this.startTime, |
@@ -286,6 +296,18 @@ export class PlayerManagerOptions { | |||
286 | } | 296 | } |
287 | } | 297 | } |
288 | 298 | ||
299 | private async buildStoryboard (storyboardsResponse: Response) { | ||
300 | const { storyboards } = await storyboardsResponse.json() as { storyboards: Storyboard[] } | ||
301 | if (!storyboards || storyboards.length === 0) return undefined | ||
302 | |||
303 | return { | ||
304 | url: window.location.origin + storyboards[0].storyboardPath, | ||
305 | height: storyboards[0].spriteHeight, | ||
306 | width: storyboards[0].spriteWidth, | ||
307 | interval: storyboards[0].spriteDuration | ||
308 | } | ||
309 | } | ||
310 | |||
289 | private buildPlaylistOptions (options: { | 311 | private buildPlaylistOptions (options: { |
290 | playlistTracker?: PlaylistTracker | 312 | playlistTracker?: PlaylistTracker |
291 | playNextPlaylistVideo?: () => any | 313 | playNextPlaylistVideo?: () => any |