]>
Commit | Line | Data |
---|---|---|
57d65032 C |
1 | import { HTMLServerConfig, Video } from '@shared/models' |
2 | ||
de615445 C |
3 | function 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 | ||
22 | function 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 | ||
29 | export { | |
30 | buildVideoOrPlaylistEmbed, | |
31 | isP2PEnabled | |
32 | } | |
33 | ||
34 | // --------------------------------------------------------------------------- | |
35 | ||
36 | function isWebRTCDisabled () { | |
37 | return !!((window as any).RTCPeerConnection || (window as any).mozRTCPeerConnection || (window as any).webkitRTCPeerConnection) === false | |
38 | } |