1 import { HTMLServerConfig, Video, VideoPrivacy } from '@shared/models'
3 function buildVideoOrPlaylistEmbed (options: {
8 const { embedUrl, embedTitle, responsive = false } = options
10 const iframe = document.createElement('iframe')
12 iframe.title = embedTitle
13 iframe.width = responsive ? '100%' : '560'
14 iframe.height = responsive ? '100%' : '315'
16 iframe.frameBorder = '0'
17 iframe.allowFullscreen = true
18 iframe.sandbox.add('allow-same-origin', 'allow-scripts', 'allow-popups')
21 const wrapper = document.createElement('div')
23 wrapper.style.position = 'relative'
24 wrapper.style.paddingTop = '56.25%'
26 iframe.style.position = 'absolute'
27 iframe.style.inset = '0'
29 wrapper.appendChild(iframe)
31 return wrapper.outerHTML
34 return iframe.outerHTML
37 function isP2PEnabled (video: Video, config: HTMLServerConfig, userP2PEnabled: boolean) {
38 if (video.isLocal && config.tracker.enabled === false) return false
39 if (isWebRTCDisabled()) return false
44 function videoRequiresAuth (video: Video) {
45 return new Set([ VideoPrivacy.PRIVATE, VideoPrivacy.INTERNAL ]).has(video.privacy.id)
49 buildVideoOrPlaylistEmbed,
54 // ---------------------------------------------------------------------------
56 function isWebRTCDisabled () {
57 return !!((window as any).RTCPeerConnection || (window as any).mozRTCPeerConnection || (window as any).webkitRTCPeerConnection) === false