- private static async getVideojsOptions (
- mode: PlayerMode,
- options: PeertubePlayerManagerOptions,
- p2pMediaLoaderModule?: any
- ): Promise<videojs.PlayerOptions> {
- const commonOptions = options.common
- const isHLS = mode === 'p2p-media-loader'
-
- let autoplay = this.getAutoPlayValue(commonOptions.autoplay)
- const html5 = {
- preloadTextTracks: false
- }
-
- const plugins: VideoJSPluginOptions = {
- peertube: {
- mode,
- autoplay, // Use peertube plugin autoplay because we could get the file by webtorrent
- videoViewUrl: commonOptions.videoViewUrl,
- videoDuration: commonOptions.videoDuration,
- userWatching: commonOptions.userWatching,
- subtitle: commonOptions.subtitle,
- videoCaptions: commonOptions.videoCaptions,
- stopTime: commonOptions.stopTime,
- isLive: commonOptions.isLive,
- videoUUID: commonOptions.videoUUID
- }
- }
-
- if (commonOptions.playlist) {
- plugins.playlist = commonOptions.playlist
- }
-
- if (commonOptions.enableHotkeys === true) {
- PeertubePlayerManager.addHotkeysOptions(plugins)
- }
-
- if (isHLS) {
- const { hlsjs } = PeertubePlayerManager.addP2PMediaLoaderOptions(plugins, options, p2pMediaLoaderModule)
-
- Object.assign(html5, hlsjs.html5)
- }
-
- if (mode === 'webtorrent') {
- PeertubePlayerManager.addWebTorrentOptions(plugins, options)
-
- // WebTorrent plugin handles autoplay, because we do some hackish stuff in there
- autoplay = false
- }
-
- const videojsOptions = {
- html5,
-
- // We don't use text track settings for now
- textTrackSettings: false as any, // FIXME: typings
- controls: commonOptions.controls !== undefined ? commonOptions.controls : true,
- loop: commonOptions.loop !== undefined ? commonOptions.loop : false,
-
- muted: commonOptions.muted !== undefined
- ? commonOptions.muted
- : undefined, // Undefined so the player knows it has to check the local storage
-
- autoplay: this.getAutoPlayValue(autoplay),
-
- poster: commonOptions.poster,
- inactivityTimeout: commonOptions.inactivityTimeout,
- playbackRates: [ 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2 ],
-
- plugins,
-
- controlBar: {
- children: this.getControlBarChildren(mode, {
- videoShortUUID: commonOptions.videoShortUUID,
-
- captions: commonOptions.captions,
- peertubeLink: commonOptions.peertubeLink,
- theaterButton: commonOptions.theaterButton,
-
- nextVideo: commonOptions.nextVideo,
- hasNextVideo: commonOptions.hasNextVideo,
-
- previousVideo: commonOptions.previousVideo,
- hasPreviousVideo: commonOptions.hasPreviousVideo
- }) as any // FIXME: typings
- }
- }
-
- if (commonOptions.language && !isDefaultLocale(commonOptions.language)) {
- Object.assign(videojsOptions, { language: commonOptions.language })
- }
-
- return this.pluginsManager.runHook('filter:internal.player.videojs.options.result', videojsOptions)
- }
-
- private static addP2PMediaLoaderOptions (
- plugins: VideoJSPluginOptions,
- options: PeertubePlayerManagerOptions,
- p2pMediaLoaderModule: any
- ) {
- const p2pMediaLoaderOptions = options.p2pMediaLoader
- const commonOptions = options.common
-
- const trackerAnnounce = p2pMediaLoaderOptions.trackerAnnounce
- .filter(t => t.startsWith('ws'))