3 NextPreviousVideoButtonOptions,
4 PeerTubeLinkButtonOptions,
5 PeertubePlayerManagerOptions,
9 export class ControlBarOptionsBuilder {
10 private options: CommonOptions
13 globalOptions: PeertubePlayerManagerOptions,
14 private mode: PlayerMode
16 this.options = globalOptions.common
19 getChildrenOptions () {
22 if (this.options.previousVideo) {
23 Object.assign(children, this.getPreviousVideo())
26 Object.assign(children, { playToggle: {} })
28 if (this.options.nextVideo) {
29 Object.assign(children, this.getNextVideo())
32 Object.assign(children, {
33 ...this.getTimeControls(),
35 flexibleWidthSpacer: {},
37 ...this.getProgressControl(),
40 p2pEnabled: this.options.p2pEnabled
46 ...this.getSettingsButton()
49 if (this.options.peertubeLink === true) {
50 Object.assign(children, {
52 shortUUID: this.options.videoShortUUID,
53 instanceName: this.options.instanceName
54 } as PeerTubeLinkButtonOptions
58 if (this.options.theaterButton === true) {
59 Object.assign(children, {
64 Object.assign(children, {
71 private getSettingsButton () {
72 const settingEntries: string[] = []
74 settingEntries.push('playbackRateMenuButton')
76 if (this.options.captions === true) settingEntries.push('captionsButton')
78 settingEntries.push('resolutionMenuButton')
85 entries: settingEntries
90 private getTimeControls () {
91 if (this.options.isLive) {
93 peerTubeLiveDisplay: {}
98 currentTimeDisplay: {},
104 private getProgressControl () {
105 if (this.options.isLive) return {}
107 const loadProgressBar = this.mode === 'webtorrent'
108 ? 'peerTubeLoadProgressBar'
116 [loadProgressBar]: {},
117 mouseTimeDisplay: {},
126 private getPreviousVideo () {
127 const buttonOptions: NextPreviousVideoButtonOptions = {
129 handler: this.options.previousVideo,
131 if (!this.options.hasPreviousVideo) return false
133 return !this.options.hasPreviousVideo()
137 return { previousVideoButton: buttonOptions }
140 private getNextVideo () {
141 const buttonOptions: NextPreviousVideoButtonOptions = {
143 handler: this.options.nextVideo,
145 if (!this.options.hasNextVideo) return false
147 return !this.options.hasNextVideo()
151 return { nextVideoButton: buttonOptions }