X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fassets%2Fplayer%2Futils.ts;h=cc303b80bb8f9791d4aec39c2eac02194bd1dd01;hb=d0fbc9fd0a29c37f3ff9b99030351e90b276fe7d;hp=cbca1065f9131cbdf8d738dcf5d9001b6cf45ecc;hpb=10ef089102f2225c5ec3ed426bc612e4f2bc8655;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/assets/player/utils.ts b/client/src/assets/player/utils.ts index cbca1065f..cc303b80b 100644 --- a/client/src/assets/player/utils.ts +++ b/client/src/assets/player/utils.ts @@ -1,4 +1,4 @@ -import { VideoFile } from '@shared/models' +import { HTMLServerConfig, Video, VideoFile } from '@shared/models' function toTitleCase (str: string) { return str.charAt(0).toUpperCase() + str.slice(1) @@ -8,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 @@ -25,7 +32,7 @@ function isSafari () { // https://github.com/danrevah/ngx-pipes/blob/master/src/pipes/math/bytes.ts // Don't import all Angular stuff, just copy the code with shame -const dictionaryBytes: Array<{max: number, type: string}> = [ +const dictionaryBytes: { max: number, type: string }[] = [ { max: 1024, type: 'B' }, { max: 1048576, type: 'KB' }, { max: 1073741824, type: 'MB' }, @@ -46,6 +53,8 @@ function buildVideoOrPlaylistEmbed (embedUrl: string, embedTitle: string) { const iframe = document.createElement('iframe') iframe.title = embedTitle + iframe.width = '560' + iframe.height = '315' iframe.src = embedUrl iframe.frameBorder = '0' iframe.allowFullscreen = true @@ -95,6 +104,7 @@ export { getRtcConfig, toTitleCase, isWebRTCDisabled, + isP2PEnabled, buildVideoOrPlaylistEmbed, videoFileMaxByResolution,