return str.charAt(0).toUpperCase() + str.slice(1)
}
+function isWebRTCDisabled () {
+ return !!((window as any).RTCPeerConnection || (window as any).mozRTCPeerConnection || (window as any).webkitRTCPeerConnection) === false
+}
+
// 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}> = [
if (!time) return 0
if (typeof time === 'number') return time
- const reg = /^((\d+)h)?((\d+)m)?((\d+)s?)?$/
+ const reg = /^((\d+)[h:])?((\d+)[m:])?((\d+)s?)?$/
const matches = time.match(reg)
if (!matches) return 0
return hours * 3600 + minutes * 60 + seconds
}
-function secondsToTime (seconds: number) {
+function secondsToTime (seconds: number, full = false, symbol?: string) {
let time = ''
- let hours = Math.floor(seconds / 3600)
- if (hours >= 1) time = hours + 'h'
+ const hourSymbol = (symbol || 'h')
+ const minuteSymbol = (symbol || 'm')
+ const secondsSymbol = full ? '' : 's'
+
+ const hours = Math.floor(seconds / 3600)
+ if (hours >= 1) time = hours + hourSymbol
+ else if (full) time = '0' + hourSymbol
seconds %= 3600
- let minutes = Math.floor(seconds / 60)
- if (minutes >= 1) time += minutes + 'm'
+ const minutes = Math.floor(seconds / 60)
+ if (minutes >= 1 && minutes < 10 && full) time += '0' + minutes + minuteSymbol
+ else if (minutes >= 1) time += minutes + minuteSymbol
+ else if (full) time += '00' + minuteSymbol
seconds %= 60
- if (seconds >= 1) time += seconds + 's'
+ if (seconds >= 1 && seconds < 10 && full) time += '0' + seconds + secondsSymbol
+ else if (seconds >= 1) time += seconds + secondsSymbol
+ else if (full) time += '00'
return time
}
getRtcConfig,
toTitleCase,
timeToInt,
+ secondsToTime,
+ isWebRTCDisabled,
buildVideoLink,
buildVideoEmbed,
videoFileMaxByResolution,