aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/standalone')
-rw-r--r--client/src/standalone/videos/embed.ts9
-rw-r--r--client/src/standalone/videos/shared/player-options-builder.ts18
-rw-r--r--client/src/standalone/videos/shared/video-fetcher.ts7
3 files changed, 28 insertions, 6 deletions
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index e4f723079..78c5e5592 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -195,10 +195,11 @@ export class PeerTubeEmbed {
195 const { 195 const {
196 videoResponse, 196 videoResponse,
197 captionsPromise, 197 captionsPromise,
198 chaptersPromise,
198 storyboardsPromise 199 storyboardsPromise
199 } = await this.videoFetcher.loadVideo({ videoId: uuid, videoPassword: this.videoPassword }) 200 } = await this.videoFetcher.loadVideo({ videoId: uuid, videoPassword: this.videoPassword })
200 201
201 return this.buildVideoPlayer({ videoResponse, captionsPromise, storyboardsPromise, forceAutoplay }) 202 return this.buildVideoPlayer({ videoResponse, captionsPromise, chaptersPromise, storyboardsPromise, forceAutoplay })
202 } catch (err) { 203 } catch (err) {
203 204
204 if (await this.handlePasswordError(err)) this.loadVideoAndBuildPlayer({ ...options }) 205 if (await this.handlePasswordError(err)) this.loadVideoAndBuildPlayer({ ...options })
@@ -210,9 +211,10 @@ export class PeerTubeEmbed {
210 videoResponse: Response 211 videoResponse: Response
211 storyboardsPromise: Promise<Response> 212 storyboardsPromise: Promise<Response>
212 captionsPromise: Promise<Response> 213 captionsPromise: Promise<Response>
214 chaptersPromise: Promise<Response>
213 forceAutoplay: boolean 215 forceAutoplay: boolean
214 }) { 216 }) {
215 const { videoResponse, captionsPromise, storyboardsPromise, forceAutoplay } = options 217 const { videoResponse, captionsPromise, chaptersPromise, storyboardsPromise, forceAutoplay } = options
216 218
217 const videoInfoPromise = videoResponse.json() 219 const videoInfoPromise = videoResponse.json()
218 .then(async (videoInfo: VideoDetails) => { 220 .then(async (videoInfo: VideoDetails) => {
@@ -233,11 +235,13 @@ export class PeerTubeEmbed {
233 { video, live, videoFileToken }, 235 { video, live, videoFileToken },
234 translations, 236 translations,
235 captionsResponse, 237 captionsResponse,
238 chaptersResponse,
236 storyboardsResponse 239 storyboardsResponse
237 ] = await Promise.all([ 240 ] = await Promise.all([
238 videoInfoPromise, 241 videoInfoPromise,
239 this.translationsPromise, 242 this.translationsPromise,
240 captionsPromise, 243 captionsPromise,
244 chaptersPromise,
241 storyboardsPromise, 245 storyboardsPromise,
242 this.buildPlayerIfNeeded() 246 this.buildPlayerIfNeeded()
243 ]) 247 ])
@@ -260,6 +264,7 @@ export class PeerTubeEmbed {
260 const loadOptions = await this.playerOptionsBuilder.getPlayerLoadOptions({ 264 const loadOptions = await this.playerOptionsBuilder.getPlayerLoadOptions({
261 video, 265 video,
262 captionsResponse, 266 captionsResponse,
267 chaptersResponse,
263 translations, 268 translations,
264 269
265 storyboardsResponse, 270 storyboardsResponse,
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 }