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 if (!this.options.isLive) {
75 settingEntries.push('playbackRateMenuButton')
78 if (this.options.captions === true) settingEntries.push('captionsButton')
80 settingEntries.push('resolutionMenuButton')
87 entries: settingEntries
92 private getTimeControls () {
93 if (this.options.isLive) {
95 peerTubeLiveDisplay: {}
100 currentTimeDisplay: {},
106 private getProgressControl () {
107 if (this.options.isLive) return {}
109 const loadProgressBar = this.mode === 'webtorrent'
110 ? 'peerTubeLoadProgressBar'
118 [loadProgressBar]: {},
119 mouseTimeDisplay: {},
128 private getPreviousVideo () {
129 const buttonOptions: NextPreviousVideoButtonOptions = {
131 handler: this.options.previousVideo,
133 if (!this.options.hasPreviousVideo) return false
135 return !this.options.hasPreviousVideo()
139 return { previousVideoButton: buttonOptions }
142 private getNextVideo () {
143 const buttonOptions: NextPreviousVideoButtonOptions = {
145 handler: this.options.nextVideo,
147 if (!this.options.hasNextVideo) return false
149 return !this.options.hasNextVideo()
153 return { nextVideoButton: buttonOptions }