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, {
54 peerTubeLinkButton: { shortUUID: this.options.videoShortUUID } 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 getProgressControl () {
91 const loadProgressBar = this.mode === 'webtorrent'
92 ? 'peerTubeLoadProgressBar'
100 [loadProgressBar]: {},
101 mouseTimeDisplay: {},
110 private getPreviousVideo () {
111 const buttonOptions: NextPreviousVideoButtonOptions = {
113 handler: this.options.previousVideo,
115 if (!this.options.hasPreviousVideo) return false
117 return !this.options.hasPreviousVideo()
121 return { previousVideoButton: buttonOptions }
124 private getNextVideo () {
125 const buttonOptions: NextPreviousVideoButtonOptions = {
127 handler: this.options.nextVideo,
129 if (!this.options.hasNextVideo) return false
131 return !this.options.hasNextVideo()
135 return { nextVideoButton: buttonOptions }