1 import { addQueryParams } from '../../../../../../shared/core-utils'
2 import { PeertubePlayerManagerOptions, WebtorrentPluginOptions } from '../../types'
4 export class WebTorrentOptionsBuilder {
7 private options: PeertubePlayerManagerOptions,
8 private autoPlayValue: any
14 const commonOptions = this.options.common
15 const webtorrentOptions = this.options.webtorrent
16 const p2pMediaLoaderOptions = this.options.p2pMediaLoader
18 const autoplay = this.autoPlayValue === 'play'
20 const webtorrent: WebtorrentPluginOptions = {
23 playerRefusedP2P: commonOptions.p2pEnabled === false,
24 videoDuration: commonOptions.videoDuration,
25 playerElement: commonOptions.playerElement,
27 videoFileToken: commonOptions.videoFileToken,
29 requiresAuth: commonOptions.requiresAuth,
31 buildWebSeedUrls: file => {
32 if (!commonOptions.requiresAuth) return []
34 return [ addQueryParams(file.fileUrl, { videoFileToken: commonOptions.videoFileToken() }) ]
37 videoFiles: webtorrentOptions.videoFiles.length !== 0
38 ? webtorrentOptions.videoFiles
39 // The WebTorrent plugin won't be able to play these files, but it will fallback to HTTP mode
40 : p2pMediaLoaderOptions?.videoFiles || [],
42 startTime: commonOptions.startTime