Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Api from '@/utils/api';
import {IStorage} from '@/types/types';
import loggerFactory from '@/utils/loggerFactory';
import sessionHolder from '@/utils/sessionHolder';
import {Logger} from 'lines-logger';
import {WS_API_URL} from '@/utils/consts';
import NotifierHandler from '@/utils/NotificationHandler';
import Vue from 'vue';
import Http from '@/utils/Http';
import WebRtcApi from '@/webrtc/WebRtcApi';
import {store} from '@/utils/storeHolder';
export const xhr: Http = /* window.fetch ? new Fetch(XHR_API_URL, sessionHolder) :*/ new Xhr(sessionHolder);
export const api: Api = new Api(xhr);
export const isMobile: boolean = mobile.isMobile();
export const messageBus = new Vue();
export const browserVersion: string = (function () {
let ua = navigator.userAgent, tem,
M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if (/trident/i.test(M[1])) {
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE ' + (tem[1] || '');
}
if (M[1] === 'Chrome') {
tem = ua.match(/\b(OPR|Edge)\/(\d+)/);
if (tem != undefined) { return tem.slice(1).join(' ').replace('OPR', 'Opera'); }
}
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
if ((tem = ua.match(/version\/(\d+)/i)) != undefined) { M.splice(1, 1, tem[1]); }
private playVideo(media: Media) {
if (!this.videoElement) {
console.warn('playVideo called before videoElement initialised');
return;
}
if (this.initialised) {
return;
} else {
this.initialised = true;
}
const autoPlay = !isMobile() && this.config && this.config.user.autoplayEnabled;
const lowQualityOnSeek =
this.config &&
(isMobile()
? this.config.user.lowQualityOnLoadEnabledForMobile
: this.config.user.lowQualityOnLoadEnabled);
console.debug('playing video', media.hash, lowQualityOnSeek, autoPlay);
this.hls = new Hls({
autoStartLoad: false,
capLevelToPlayerSize: true,
maxSeekHole: 5,
maxBufferHole: 5,
maxBufferLength: 20,
startLevel: lowQualityOnSeek ? 0 : -1,
});
this.syncVolume();
this.hls.on(Hls.Events.MANIFEST_PARSED, (event, data) => {
private playVideo(media: Media) {
if (!this.videoElement) {
console.warn('playVideo called before videoElement initialised');
return;
}
if (this.initialised) {
return;
} else {
this.initialised = true;
}
const autoPlay = !isMobile() && this.config && this.config.user.autoplayEnabled;
const lowQualityOnSeek =
this.config &&
(isMobile()
? this.config.user.lowQualityOnLoadEnabledForMobile
: this.config.user.lowQualityOnLoadEnabled);
console.debug('playing video', media.hash, lowQualityOnSeek, autoPlay);
this.hls = new Hls({
autoStartLoad: false,
capLevelToPlayerSize: true,
maxSeekHole: 5,
maxBufferHole: 5,
maxBufferLength: 20,
startLevel: lowQualityOnSeek ? 0 : -1,
});
const start = ascending ? min : max;
const end = ascending ? max + 1 : min - 1;
return range(start, end).map(year => {
const yearStr = String(year);
return (
<option value="{yearStr}">
{yearStr}
</option>
);
});
};
const currYear = new Date().getFullYear();
const renderNativeInput = isMobile({ tablet: true });
const customValueToString = ({ month, year }: MonthPickerValue) =>
month && year ? `${year}-${month < 10 ? '0' : ''}${month}` : undefined;
const stringToCustomValue = (value: string) => {
const [year, month] = value.split('-');
return {
month: parseInt(month, 10),
year: parseInt(year, 10),
};
};
const makeChangeHandler = <
Element extends HTMLSelectElement | HTMLInputElement
>(
navbarLinkClickHandler() {
if (isMobile()) {
this.setState({ navbarOpened: false })
}
}
public updatePlayerActivity(move = false) {
if (move && isMobile()) {
return;
}
if (this.videoPlayerState.active) {
this.videoPlayerState.active.unsubscribe();
this.videoPlayerState.active = undefined;
}
this.videoPlayerState.active = timer(PLAYER_CONTROLS_TIMEOUT).subscribe(() => {
if (this.videoPlayerState.active) {
this.videoPlayerState.active.unsubscribe();
this.videoPlayerState.active = undefined;
}
});
}