Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function getEnv(config: Config): Promise {
const userAgent: string = navigator.userAgent;
const canAutoplay: boolean = (await canAutoplayLib.video({
muted: config.volume === 0,
})).result;
const isSafari: boolean =
/safari/i.test(userAgent) && userAgent.indexOf('Chrome') === -1;
const isEdge: boolean = /edge/i.test(userAgent);
const isIE: boolean =
Boolean((window as any).ActiveXObject) ||
/trident.*rv:1\d/i.test(userAgent);
const isChrome: boolean = /chrome/i.test(userAgent) && !isEdge;
const isMobile: boolean = /Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone|IEMobile|Opera Mini/i.test(
userAgent,
constructor (videoId, args = {}) {
super()
this.id = videoId
this.selectedQuality = args.quality || VideoQuality.auto
this.muted = typeof args.muted !== 'undefined' ? args.muted : false
this.autoplay = typeof args.autoplay !== 'undefined' ? args.autoplay : true
this.loop = typeof args.loop !== 'undefined' ? args.loop : true
if (this.autoplay) {
canAutoPlay.video({ muted: this.muted, timeout: 1000 }).then(({ result, error }) => {
if (result === false) {
console.warn('[Vimeo] Autoplay not available on this browser', error)
this.autoplay = false
window.addEventListener('click', this.onClickAutoplayFix.bind(this))
}
})
}
}
return new Promise((resolve, reject) => {
canautoplay
.video({ inline: true, muted: false })
.then(({ result, error }) => {
if (result === true)
resolve({
autoplayAllowed: true,
autoplayRequiresMute: false
});
else
resolve({
autoplayAllowed: true,
autoplayRequiresMute: true
});
});
});
}