X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fassets%2Fplayer%2Futils.ts;h=7e25e3067d3ef9ba37357ff2daa59b0cd51d9187;hb=ba8a8367e7fde7915ae6633445bf46ebf4a9fe94;hp=f0a1b1aee246c7e5141a30a139e8560ad36d475e;hpb=9e8789497377cac5554a622da605f5b89587aa9c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/assets/player/utils.ts b/client/src/assets/player/utils.ts index f0a1b1aee..7e25e3067 100644 --- a/client/src/assets/player/utils.ts +++ b/client/src/assets/player/utils.ts @@ -1,5 +1,4 @@ -import { escapeHTML } from '@shared/core-utils/renderer' -import { VideoFile } from '@shared/models' +import { HTMLServerConfig, Video, VideoFile } from '@shared/models' function toTitleCase (str: string) { return str.charAt(0).toUpperCase() + str.slice(1) @@ -9,6 +8,13 @@ function isWebRTCDisabled () { return !!((window as any).RTCPeerConnection || (window as any).mozRTCPeerConnection || (window as any).webkitRTCPeerConnection) === false } +function isP2PEnabled (video: Video, config: HTMLServerConfig, userP2PEnabled: boolean) { + if (video.isLocal && config.tracker.enabled === false) return false + if (isWebRTCDisabled()) return false + + return userP2PEnabled +} + function isIOS () { if (/iPad|iPhone|iPod/.test(navigator.platform)) { return true @@ -17,7 +23,7 @@ function isIOS () { // Detect iPad Desktop mode return !!(navigator.maxTouchPoints && navigator.maxTouchPoints > 2 && - /MacIntel/.test(navigator.platform)) + navigator.platform.includes('MacIntel')) } function isSafari () { @@ -44,14 +50,17 @@ function isMobile () { } function buildVideoOrPlaylistEmbed (embedUrl: string, embedTitle: string) { - const title = escapeHTML(embedTitle) - - return '' + const iframe = document.createElement('iframe') + + iframe.title = embedTitle + iframe.width = '560' + iframe.height = '315' + iframe.src = embedUrl + iframe.frameBorder = '0' + iframe.allowFullscreen = true + iframe.sandbox.add('allow-same-origin', 'allow-scripts', 'allow-popups') + + return iframe.outerHTML } function videoFileMaxByResolution (files: VideoFile[]) { @@ -95,6 +104,7 @@ export { getRtcConfig, toTitleCase, isWebRTCDisabled, + isP2PEnabled, buildVideoOrPlaylistEmbed, videoFileMaxByResolution,