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