]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/root-helpers/video.ts
Translated using Weblate (Dutch)
[github/Chocobozzz/PeerTube.git] / client / src / root-helpers / video.ts
CommitLineData
57d65032
C
1import { HTMLServerConfig, Video } from '@shared/models'
2
de615445
C
3function buildVideoOrPlaylistEmbed (options: {
4 embedUrl: string
5 embedTitle: string
6}) {
7 const { embedUrl, embedTitle } = options
8
57d65032
C
9 const iframe = document.createElement('iframe')
10
11 iframe.title = embedTitle
12 iframe.width = '560'
13 iframe.height = '315'
14 iframe.src = embedUrl
15 iframe.frameBorder = '0'
16 iframe.allowFullscreen = true
17 iframe.sandbox.add('allow-same-origin', 'allow-scripts', 'allow-popups')
18
19 return iframe.outerHTML
20}
21
22function isP2PEnabled (video: Video, config: HTMLServerConfig, userP2PEnabled: boolean) {
23 if (video.isLocal && config.tracker.enabled === false) return false
24 if (isWebRTCDisabled()) return false
25
26 return userP2PEnabled
27}
28
29export {
30 buildVideoOrPlaylistEmbed,
31 isP2PEnabled
32}
33
34// ---------------------------------------------------------------------------
35
36function isWebRTCDisabled () {
37 return !!((window as any).RTCPeerConnection || (window as any).mozRTCPeerConnection || (window as any).webkitRTCPeerConnection) === false
38}