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 currentTimeDisplay: {},
38 flexibleWidthSpacer: {},
40 ...this.getProgressControl(),
43 p2pEnabled: this.options.p2pEnabled
49 ...this.getSettingsButton()
52 if (this.options.peertubeLink === true) {
53 Object.assign(children, {
55 shortUUID: this.options.videoShortUUID,
56 instanceName: this.options.instanceName
57 } as PeerTubeLinkButtonOptions
61 if (this.options.theaterButton === true) {
62 Object.assign(children, {
67 Object.assign(children, {
74 private getSettingsButton () {
75 const settingEntries: string[] = []
77 settingEntries.push('playbackRateMenuButton')
79 if (this.options.captions === true) settingEntries.push('captionsButton')
81 settingEntries.push('resolutionMenuButton')
88 entries: settingEntries
93 private getProgressControl () {
94 const loadProgressBar = this.mode === 'webtorrent'
95 ? 'peerTubeLoadProgressBar'
103 [loadProgressBar]: {},
104 mouseTimeDisplay: {},
113 private getPreviousVideo () {
114 const buttonOptions: NextPreviousVideoButtonOptions = {
116 handler: this.options.previousVideo,
118 if (!this.options.hasPreviousVideo) return false
120 return !this.options.hasPreviousVideo()
124 return { previousVideoButton: buttonOptions }
127 private getNextVideo () {
128 const buttonOptions: NextPreviousVideoButtonOptions = {
130 handler: this.options.nextVideo,
132 if (!this.options.hasNextVideo) return false
134 return !this.options.hasNextVideo()
138 return { nextVideoButton: buttonOptions }