aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone/videos/embed.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-10 09:23:18 +0200
committerChocobozzz <me@florianbigard.com>2019-04-10 09:23:18 +0200
commit31b6ddf86652502e0c96d77fa10861ce4af11aa4 (patch)
treeb94402972945699134b2a504af5d551124f0bf54 /client/src/standalone/videos/embed.ts
parent22834691abb6e74d31654ffd2ebeaaaa8ef3ac7b (diff)
downloadPeerTube-31b6ddf86652502e0c96d77fa10861ce4af11aa4.tar.gz
PeerTube-31b6ddf86652502e0c96d77fa10861ce4af11aa4.tar.zst
PeerTube-31b6ddf86652502e0c96d77fa10861ce4af11aa4.zip
Add ability to disable tracker
Diffstat (limited to 'client/src/standalone/videos/embed.ts')
-rw-r--r--client/src/standalone/videos/embed.ts26
1 files changed, 18 insertions, 8 deletions
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'
2 2
3import * as Channel from 'jschannel' 3import * as Channel from 'jschannel'
4 4
5import { peertubeTranslate, ResultList, VideoDetails } from '../../../../shared' 5import { peertubeTranslate, ResultList, ServerConfig, VideoDetails } from '../../../../shared'
6import { PeerTubeResolution } from '../player/definitions' 6import { PeerTubeResolution } from '../player/definitions'
7import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings' 7import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings'
8import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model' 8import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model'
@@ -177,6 +177,10 @@ class PeerTubeEmbed {
177 return fetch(this.getVideoUrl(videoId) + '/captions') 177 return fetch(this.getVideoUrl(videoId) + '/captions')
178 } 178 }
179 179
180 loadConfig (): Promise<Response> {
181 return fetch('/api/v1/config')
182 }
183
180 removeElement (element: HTMLElement) { 184 removeElement (element: HTMLElement) {
181 element.parentElement.removeChild(element) 185 element.parentElement.removeChild(element)
182 } 186 }
@@ -237,10 +241,10 @@ class PeerTubeEmbed {
237 try { 241 try {
238 const params = new URL(window.location.toString()).searchParams 242 const params = new URL(window.location.toString()).searchParams
239 243
240 this.autoplay = this.getParamToggle(params, 'autoplay') 244 this.autoplay = this.getParamToggle(params, 'autoplay', false)
241 this.controls = this.getParamToggle(params, 'controls') 245 this.controls = this.getParamToggle(params, 'controls', true)
242 this.muted = this.getParamToggle(params, 'muted') 246 this.muted = this.getParamToggle(params, 'muted', false)
243 this.loop = this.getParamToggle(params, 'loop') 247 this.loop = this.getParamToggle(params, 'loop', false)
244 this.enableApi = this.getParamToggle(params, 'api', this.enableApi) 248 this.enableApi = this.getParamToggle(params, 'api', this.enableApi)
245 249
246 this.scope = this.getParamString(params, 'scope', this.scope) 250 this.scope = this.getParamString(params, 'scope', this.scope)
@@ -258,10 +262,11 @@ class PeerTubeEmbed {
258 const urlParts = window.location.pathname.split('/') 262 const urlParts = window.location.pathname.split('/')
259 const videoId = urlParts[ urlParts.length - 1 ] 263 const videoId = urlParts[ urlParts.length - 1 ]
260 264
261 const [ serverTranslations, videoResponse, captionsResponse ] = await Promise.all([ 265 const [ serverTranslations, videoResponse, captionsResponse, configResponse ] = await Promise.all([
262 PeertubePlayerManager.getServerTranslations(window.location.origin, navigator.language), 266 PeertubePlayerManager.getServerTranslations(window.location.origin, navigator.language),
263 this.loadVideoInfo(videoId), 267 this.loadVideoInfo(videoId),
264 this.loadVideoCaptions(videoId) 268 this.loadVideoCaptions(videoId),
269 this.loadConfig()
265 ]) 270 ])
266 271
267 if (!videoResponse.ok) { 272 if (!videoResponse.ok) {
@@ -338,9 +343,14 @@ class PeerTubeEmbed {
338 window[ 'videojsPlayer' ] = this.player 343 window[ 'videojsPlayer' ] = this.player
339 344
340 if (this.controls) { 345 if (this.controls) {
346 const config: ServerConfig = await configResponse.json()
347 const description = config.tracker.enabled
348 ? '<span class="text">' + this.player.localize('Uses P2P, others may know your IP is downloading this video.') + '</span>'
349 : undefined
350
341 this.player.dock({ 351 this.player.dock({
342 title: videoInfo.name, 352 title: videoInfo.name,
343 description: this.player.localize('Uses P2P, others may know your IP is downloading this video.') 353 description
344 }) 354 })
345 } 355 }
346 356