diff options
Diffstat (limited to 'client/src/assets/player/peertube-player-manager.ts')
-rw-r--r-- | client/src/assets/player/peertube-player-manager.ts | 60 |
1 files changed, 50 insertions, 10 deletions
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts index dcfa3a593..c71b43415 100644 --- a/client/src/assets/player/peertube-player-manager.ts +++ b/client/src/assets/player/peertube-player-manager.ts | |||
@@ -6,7 +6,7 @@ import './upnext/end-card' | |||
6 | import './upnext/upnext-plugin' | 6 | import './upnext/upnext-plugin' |
7 | import './bezels/bezels-plugin' | 7 | import './bezels/bezels-plugin' |
8 | import './peertube-plugin' | 8 | import './peertube-plugin' |
9 | import './videojs-components/next-video-button' | 9 | import './videojs-components/next-previous-video-button' |
10 | import './videojs-components/p2p-info-button' | 10 | import './videojs-components/p2p-info-button' |
11 | import './videojs-components/peertube-link-button' | 11 | import './videojs-components/peertube-link-button' |
12 | import './videojs-components/peertube-load-progress-bar' | 12 | import './videojs-components/peertube-load-progress-bar' |
@@ -27,6 +27,7 @@ import { segmentUrlBuilderFactory } from './p2p-media-loader/segment-url-builder | |||
27 | import { segmentValidatorFactory } from './p2p-media-loader/segment-validator' | 27 | import { segmentValidatorFactory } from './p2p-media-loader/segment-validator' |
28 | import { getStoredP2PEnabled } from './peertube-player-local-storage' | 28 | import { getStoredP2PEnabled } from './peertube-player-local-storage' |
29 | import { | 29 | import { |
30 | NextPreviousVideoButtonOptions, | ||
30 | P2PMediaLoaderPluginOptions, | 31 | P2PMediaLoaderPluginOptions, |
31 | PlaylistPluginOptions, | 32 | PlaylistPluginOptions, |
32 | UserWatching, | 33 | UserWatching, |
@@ -77,7 +78,12 @@ export interface CommonOptions extends CustomizationOptions { | |||
77 | onPlayerElementChange: (element: HTMLVideoElement) => void | 78 | onPlayerElementChange: (element: HTMLVideoElement) => void |
78 | 79 | ||
79 | autoplay: boolean | 80 | autoplay: boolean |
80 | nextVideo?: Function | 81 | |
82 | nextVideo?: () => void | ||
83 | hasNextVideo?: () => boolean | ||
84 | |||
85 | previousVideo?: () => void | ||
86 | hasPreviousVideo?: () => boolean | ||
81 | 87 | ||
82 | playlist?: PlaylistPluginOptions | 88 | playlist?: PlaylistPluginOptions |
83 | 89 | ||
@@ -259,7 +265,12 @@ export class PeertubePlayerManager { | |||
259 | captions: commonOptions.captions, | 265 | captions: commonOptions.captions, |
260 | peertubeLink: commonOptions.peertubeLink, | 266 | peertubeLink: commonOptions.peertubeLink, |
261 | theaterButton: commonOptions.theaterButton, | 267 | theaterButton: commonOptions.theaterButton, |
262 | nextVideo: commonOptions.nextVideo | 268 | |
269 | nextVideo: commonOptions.nextVideo, | ||
270 | hasNextVideo: commonOptions.hasNextVideo, | ||
271 | |||
272 | previousVideo: commonOptions.previousVideo, | ||
273 | hasPreviousVideo: commonOptions.hasPreviousVideo | ||
263 | }) as any // FIXME: typings | 274 | }) as any // FIXME: typings |
264 | } | 275 | } |
265 | } | 276 | } |
@@ -360,9 +371,14 @@ export class PeertubePlayerManager { | |||
360 | 371 | ||
361 | private static getControlBarChildren (mode: PlayerMode, options: { | 372 | private static getControlBarChildren (mode: PlayerMode, options: { |
362 | peertubeLink: boolean | 373 | peertubeLink: boolean |
363 | theaterButton: boolean, | 374 | theaterButton: boolean |
364 | captions: boolean, | 375 | captions: boolean |
376 | |||
365 | nextVideo?: Function | 377 | nextVideo?: Function |
378 | hasNextVideo?: () => boolean | ||
379 | |||
380 | previousVideo?: Function | ||
381 | hasPreviousVideo?: () => boolean | ||
366 | }) { | 382 | }) { |
367 | const settingEntries = [] | 383 | const settingEntries = [] |
368 | const loadProgressBar = mode === 'webtorrent' ? 'peerTubeLoadProgressBar' : 'loadProgressBar' | 384 | const loadProgressBar = mode === 'webtorrent' ? 'peerTubeLoadProgressBar' : 'loadProgressBar' |
@@ -372,15 +388,39 @@ export class PeertubePlayerManager { | |||
372 | if (options.captions === true) settingEntries.push('captionsButton') | 388 | if (options.captions === true) settingEntries.push('captionsButton') |
373 | settingEntries.push('resolutionMenuButton') | 389 | settingEntries.push('resolutionMenuButton') |
374 | 390 | ||
375 | const children = { | 391 | const children = {} |
376 | 'playToggle': {} | 392 | |
393 | if (options.previousVideo) { | ||
394 | const buttonOptions: NextPreviousVideoButtonOptions = { | ||
395 | type: 'previous', | ||
396 | handler: options.previousVideo, | ||
397 | isDisabled: () => { | ||
398 | if (!options.hasPreviousVideo) return false | ||
399 | |||
400 | return !options.hasPreviousVideo() | ||
401 | } | ||
402 | } | ||
403 | |||
404 | Object.assign(children, { | ||
405 | 'previousVideoButton': buttonOptions | ||
406 | }) | ||
377 | } | 407 | } |
378 | 408 | ||
409 | Object.assign(children, { playToggle: {} }) | ||
410 | |||
379 | if (options.nextVideo) { | 411 | if (options.nextVideo) { |
380 | Object.assign(children, { | 412 | const buttonOptions: NextPreviousVideoButtonOptions = { |
381 | 'nextVideoButton': { | 413 | type: 'next', |
382 | handler: options.nextVideo | 414 | handler: options.nextVideo, |
415 | isDisabled: () => { | ||
416 | if (!options.hasNextVideo) return false | ||
417 | |||
418 | return !options.hasNextVideo() | ||
383 | } | 419 | } |
420 | } | ||
421 | |||
422 | Object.assign(children, { | ||
423 | 'nextVideoButton': buttonOptions | ||
384 | }) | 424 | }) |
385 | } | 425 | } |
386 | 426 | ||