1 import { NextPreviousVideoButtonOptions, PeerTubeLinkButtonOptions } from '../peertube-videojs-typings'
2 import { CommonOptions, PeertubePlayerManagerOptions, PlayerMode } from './manager-options.model'
4 export class ControlBarOptionsBuilder {
5 private options: CommonOptions
8 globalOptions: PeertubePlayerManagerOptions,
9 private mode: PlayerMode
11 this.options = globalOptions.common
14 getChildrenOptions () {
17 if (this.options.previousVideo) {
18 Object.assign(children, this.getPreviousVideo())
21 Object.assign(children, { playToggle: {} })
23 if (this.options.nextVideo) {
24 Object.assign(children, this.getNextVideo())
27 Object.assign(children, {
28 currentTimeDisplay: {},
33 flexibleWidthSpacer: {},
35 ...this.getProgressControl(),
38 p2pEnabled: this.options.p2pEnabled
44 settingsButton: this.getSettingsButton()
47 if (this.options.peertubeLink === true) {
48 Object.assign(children, {
49 peerTubeLinkButton: { shortUUID: this.options.videoShortUUID } as PeerTubeLinkButtonOptions
53 if (this.options.theaterButton === true) {
54 Object.assign(children, {
59 Object.assign(children, {
66 private getSettingsButton () {
67 const settingEntries: string[] = []
69 settingEntries.push('playbackRateMenuButton')
71 if (this.options.captions === true) settingEntries.push('captionsButton')
73 settingEntries.push('resolutionMenuButton')
80 entries: settingEntries
85 private getProgressControl () {
86 const loadProgressBar = this.mode === 'webtorrent'
87 ? 'peerTubeLoadProgressBar'
95 [loadProgressBar]: {},
105 private getPreviousVideo () {
106 const buttonOptions: NextPreviousVideoButtonOptions = {
108 handler: this.options.previousVideo,
110 if (!this.options.hasPreviousVideo) return false
112 return !this.options.hasPreviousVideo()
116 return { previousVideoButton: buttonOptions }
119 private getNextVideo () {
120 const buttonOptions: NextPreviousVideoButtonOptions = {
122 handler: this.options.nextVideo,
124 if (!this.options.hasNextVideo) return false
126 return !this.options.hasNextVideo()
130 return { nextVideoButton: buttonOptions }