aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone/videos/shared
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/standalone/videos/shared')
-rw-r--r--client/src/standalone/videos/shared/player-options-builder.ts18
-rw-r--r--client/src/standalone/videos/shared/video-fetcher.ts7
2 files changed, 21 insertions, 4 deletions
diff --git a/client/src/standalone/videos/shared/player-options-builder.ts b/client/src/standalone/videos/shared/player-options-builder.ts
index 3437ef421..dec859409 100644
--- a/client/src/standalone/videos/shared/player-options-builder.ts
+++ b/client/src/standalone/videos/shared/player-options-builder.ts
@@ -5,6 +5,7 @@ import {
5 Storyboard, 5 Storyboard,
6 Video, 6 Video,
7 VideoCaption, 7 VideoCaption,
8 VideoChapter,
8 VideoDetails, 9 VideoDetails,
9 VideoPlaylistElement, 10 VideoPlaylistElement,
10 VideoState, 11 VideoState,
@@ -199,6 +200,8 @@ export class PlayerOptionsBuilder {
199 200
200 storyboardsResponse: Response 201 storyboardsResponse: Response
201 202
203 chaptersResponse: Response
204
202 live?: LiveVideo 205 live?: LiveVideo
203 206
204 alreadyPlayed: boolean 207 alreadyPlayed: boolean
@@ -229,12 +232,14 @@ export class PlayerOptionsBuilder {
229 forceAutoplay, 232 forceAutoplay,
230 playlist, 233 playlist,
231 live, 234 live,
232 storyboardsResponse 235 storyboardsResponse,
236 chaptersResponse
233 } = options 237 } = options
234 238
235 const [ videoCaptions, storyboard ] = await Promise.all([ 239 const [ videoCaptions, storyboard, chapters ] = await Promise.all([
236 this.buildCaptions(captionsResponse, translations), 240 this.buildCaptions(captionsResponse, translations),
237 this.buildStoryboard(storyboardsResponse) 241 this.buildStoryboard(storyboardsResponse),
242 this.buildChapters(chaptersResponse)
238 ]) 243 ])
239 244
240 return { 245 return {
@@ -248,6 +253,7 @@ export class PlayerOptionsBuilder {
248 subtitle: this.subtitle, 253 subtitle: this.subtitle,
249 254
250 storyboard, 255 storyboard,
256 videoChapters: chapters,
251 257
252 startTime: playlist 258 startTime: playlist
253 ? playlist.playlistTracker.getCurrentElement().startTimestamp 259 ? playlist.playlistTracker.getCurrentElement().startTimestamp
@@ -312,6 +318,12 @@ export class PlayerOptionsBuilder {
312 } 318 }
313 } 319 }
314 320
321 private async buildChapters (chaptersResponse: Response) {
322 const { chapters } = await chaptersResponse.json() as { chapters: VideoChapter[] }
323
324 return chapters
325 }
326
315 private buildPlaylistOptions (options?: { 327 private buildPlaylistOptions (options?: {
316 playlistTracker: PlaylistTracker 328 playlistTracker: PlaylistTracker
317 playNext: () => any 329 playNext: () => any
diff --git a/client/src/standalone/videos/shared/video-fetcher.ts b/client/src/standalone/videos/shared/video-fetcher.ts
index 9149d946e..c52861189 100644
--- a/client/src/standalone/videos/shared/video-fetcher.ts
+++ b/client/src/standalone/videos/shared/video-fetcher.ts
@@ -36,9 +36,10 @@ export class VideoFetcher {
36 } 36 }
37 37
38 const captionsPromise = this.loadVideoCaptions({ videoId, videoPassword }) 38 const captionsPromise = this.loadVideoCaptions({ videoId, videoPassword })
39 const chaptersPromise = this.loadVideoChapters({ videoId, videoPassword })
39 const storyboardsPromise = this.loadStoryboards(videoId) 40 const storyboardsPromise = this.loadStoryboards(videoId)
40 41
41 return { captionsPromise, storyboardsPromise, videoResponse } 42 return { captionsPromise, chaptersPromise, storyboardsPromise, videoResponse }
42 } 43 }
43 44
44 loadLive (video: VideoDetails) { 45 loadLive (video: VideoDetails) {
@@ -64,6 +65,10 @@ export class VideoFetcher {
64 return this.http.fetch(this.getVideoUrl(videoId) + '/captions', { optionalAuth: true }, videoPassword) 65 return this.http.fetch(this.getVideoUrl(videoId) + '/captions', { optionalAuth: true }, videoPassword)
65 } 66 }
66 67
68 private loadVideoChapters ({ videoId, videoPassword }: { videoId: string, videoPassword?: string }): Promise<Response> {
69 return this.http.fetch(this.getVideoUrl(videoId) + '/chapters', { optionalAuth: true }, videoPassword)
70 }
71
67 private getVideoUrl (id: string) { 72 private getVideoUrl (id: string) {
68 return window.location.origin + '/api/v1/videos/' + id 73 return window.location.origin + '/api/v1/videos/' + id
69 } 74 }