]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/root-helpers/video.ts
Change bootstrap helpers and variables
[github/Chocobozzz/PeerTube.git] / client / src / root-helpers / video.ts
CommitLineData
3545e72c 1import { HTMLServerConfig, Video, VideoPrivacy } from '@shared/models'
57d65032 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
3545e72c
C
29function videoRequiresAuth (video: Video) {
30 return new Set([ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]).has(video.privacy.id)
31}
32
57d65032
C
33export {
34 buildVideoOrPlaylistEmbed,
3545e72c
C
35 isP2PEnabled,
36 videoRequiresAuth
57d65032
C
37}
38
39// ---------------------------------------------------------------------------
40
41function isWebRTCDisabled () {
42 return !!((window as any).RTCPeerConnection || (window as any).mozRTCPeerConnection || (window as any).webkitRTCPeerConnection) === false
43}