From 31b6ddf86652502e0c96d77fa10861ce4af11aa4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 10 Apr 2019 09:23:18 +0200 Subject: Add ability to disable tracker --- client/src/standalone/videos/embed.ts | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'client/src/standalone/videos') diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 626d55a7c..707f04253 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -2,7 +2,7 @@ import './embed.scss' import * as Channel from 'jschannel' -import { peertubeTranslate, ResultList, VideoDetails } from '../../../../shared' +import { peertubeTranslate, ResultList, ServerConfig, VideoDetails } from '../../../../shared' import { PeerTubeResolution } from '../player/definitions' import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings' import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model' @@ -177,6 +177,10 @@ class PeerTubeEmbed { return fetch(this.getVideoUrl(videoId) + '/captions') } + loadConfig (): Promise { + return fetch('/api/v1/config') + } + removeElement (element: HTMLElement) { element.parentElement.removeChild(element) } @@ -237,10 +241,10 @@ class PeerTubeEmbed { try { const params = new URL(window.location.toString()).searchParams - this.autoplay = this.getParamToggle(params, 'autoplay') - this.controls = this.getParamToggle(params, 'controls') - this.muted = this.getParamToggle(params, 'muted') - this.loop = this.getParamToggle(params, 'loop') + this.autoplay = this.getParamToggle(params, 'autoplay', false) + this.controls = this.getParamToggle(params, 'controls', true) + this.muted = this.getParamToggle(params, 'muted', false) + this.loop = this.getParamToggle(params, 'loop', false) this.enableApi = this.getParamToggle(params, 'api', this.enableApi) this.scope = this.getParamString(params, 'scope', this.scope) @@ -258,10 +262,11 @@ class PeerTubeEmbed { const urlParts = window.location.pathname.split('/') const videoId = urlParts[ urlParts.length - 1 ] - const [ serverTranslations, videoResponse, captionsResponse ] = await Promise.all([ + const [ serverTranslations, videoResponse, captionsResponse, configResponse ] = await Promise.all([ PeertubePlayerManager.getServerTranslations(window.location.origin, navigator.language), this.loadVideoInfo(videoId), - this.loadVideoCaptions(videoId) + this.loadVideoCaptions(videoId), + this.loadConfig() ]) if (!videoResponse.ok) { @@ -338,9 +343,14 @@ class PeerTubeEmbed { window[ 'videojsPlayer' ] = this.player if (this.controls) { + const config: ServerConfig = await configResponse.json() + const description = config.tracker.enabled + ? '' + this.player.localize('Uses P2P, others may know your IP is downloading this video.') + '' + : undefined + this.player.dock({ title: videoInfo.name, - description: this.player.localize('Uses P2P, others may know your IP is downloading this video.') + description }) } -- cgit v1.2.3