- private static addWebTorrentOptions (plugins: VideoJSPluginOptions, options: PeertubePlayerManagerOptions) {
- const commonOptions = options.common
- const webtorrentOptions = options.webtorrent
- const p2pMediaLoaderOptions = options.p2pMediaLoader
-
- const autoplay = this.getAutoPlayValue(commonOptions.autoplay) === 'play'
- ? true
- : false
-
- const webtorrent = {
- autoplay,
- videoDuration: commonOptions.videoDuration,
- playerElement: commonOptions.playerElement,
- videoFiles: webtorrentOptions.videoFiles.length !== 0
- ? webtorrentOptions.videoFiles
- // The WebTorrent plugin won't be able to play these files, but it will fallback to HTTP mode
- : p2pMediaLoaderOptions.videoFiles,
- fallbackVideoFiles: p2pMediaLoaderOptions.videoFiles,
- startTime: commonOptions.startTime
- }
-
- Object.assign(plugins, { webtorrent })
- }
-
- private static getControlBarChildren (mode: PlayerMode, options: {
- peertubeLink: boolean
- theaterButton: boolean
- captions: boolean
-
- nextVideo?: Function
- hasNextVideo?: () => boolean
-
- previousVideo?: Function
- hasPreviousVideo?: () => boolean
- }) {
- const settingEntries = []
- const loadProgressBar = mode === 'webtorrent' ? 'peerTubeLoadProgressBar' : 'loadProgressBar'
-
- // Keep an order
- settingEntries.push('playbackRateMenuButton')
- if (options.captions === true) settingEntries.push('captionsButton')
- settingEntries.push('resolutionMenuButton')
-
- const children = {}
-
- if (options.previousVideo) {
- const buttonOptions: NextPreviousVideoButtonOptions = {
- type: 'previous',
- handler: options.previousVideo,
- isDisabled: () => {
- if (!options.hasPreviousVideo) return false
-
- return !options.hasPreviousVideo()
- }
- }
-
- Object.assign(children, {
- 'previousVideoButton': buttonOptions
- })
- }
-
- Object.assign(children, { playToggle: {} })
-
- if (options.nextVideo) {
- const buttonOptions: NextPreviousVideoButtonOptions = {
- type: 'next',
- handler: options.nextVideo,
- isDisabled: () => {
- if (!options.hasNextVideo) return false
-
- return !options.hasNextVideo()
- }
- }
-
- Object.assign(children, {
- 'nextVideoButton': buttonOptions
- })