aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-player-manager.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-05 11:02:14 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-08-07 08:58:29 +0200
commita950e4c82bd458e924b00698a77c06275a64a46c (patch)
tree11bdeecb8950e6854eee79205823bcbb1e5a437c /client/src/assets/player/peertube-player-manager.ts
parent4572c3d0d92f5b1b79b34dbe2c7b6557a8a5b7e4 (diff)
downloadPeerTube-a950e4c82bd458e924b00698a77c06275a64a46c.tar.gz
PeerTube-a950e4c82bd458e924b00698a77c06275a64a46c.tar.zst
PeerTube-a950e4c82bd458e924b00698a77c06275a64a46c.zip
Add previous button
Diffstat (limited to 'client/src/assets/player/peertube-player-manager.ts')
-rw-r--r--client/src/assets/player/peertube-player-manager.ts60
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'
6import './upnext/upnext-plugin' 6import './upnext/upnext-plugin'
7import './bezels/bezels-plugin' 7import './bezels/bezels-plugin'
8import './peertube-plugin' 8import './peertube-plugin'
9import './videojs-components/next-video-button' 9import './videojs-components/next-previous-video-button'
10import './videojs-components/p2p-info-button' 10import './videojs-components/p2p-info-button'
11import './videojs-components/peertube-link-button' 11import './videojs-components/peertube-link-button'
12import './videojs-components/peertube-load-progress-bar' 12import './videojs-components/peertube-load-progress-bar'
@@ -27,6 +27,7 @@ import { segmentUrlBuilderFactory } from './p2p-media-loader/segment-url-builder
27import { segmentValidatorFactory } from './p2p-media-loader/segment-validator' 27import { segmentValidatorFactory } from './p2p-media-loader/segment-validator'
28import { getStoredP2PEnabled } from './peertube-player-local-storage' 28import { getStoredP2PEnabled } from './peertube-player-local-storage'
29import { 29import {
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