var CoviEmbedHtml =
'
' +
'
' +
' ' +
'
' +
'
' +
'
' +
'
' +
'
![]()
' +
'
' +
'
' +
'
' +
'
' +
'
' +
'';
var CoviNativeItemsMapping = {
};
var CoviNativeElements = {
covi_player: {
className: 'covi_player',
},
covi_playback: {
className: 'covi_playback',
},
covi_playback_muteunmute: {
className: 'covi_playback_muteunmute',
eventFunc: 'onMuteUnmute',
},
'covi_playback_mute-img': {
className: 'covi_playback_mute-img',
src: 'mute_30x29.png',
},
'covi_playback_unmute-img': {
className: 'covi_playback_unmute-img',
src: 'unmute_28x28.png',
},
covi_playback_seek: {
className: 'covi_playback_seek',
eventFunc: 'onSeek',
},
covi_playback_currenttime: {
className: 'covi_playback_currenttime',
},
covi_playback_durationtime: {
className: 'covi_playback_durationtime',
},
covi_playback_adclose: {
className: 'covi_playback_adclose',
eventFunc: 'onAdClose',
},
'covi_adidentity-container': {
className: 'covi_adidentity-container',
},
covi_adidentity: {
type: 'p',
className: 'covi_adidentity',
},
covi_title: {
type: 'p',
className: 'covi_title',
},
covi_playback_bi: {
className: 'covi_playback_bi',
eventFunc: 'onCoviBi',
},
'covi_playback_bi-img': {
className: 'covi_playback_bi-img',
src: 'covi_bi.svg',
},
covi_playback_replay: {
className: 'covi_playback_replay',
eventFunc: 'onReplay',
},
'covi_playback_replay-img': {
className: 'covi_playback_replay-img',
src: 'replay_72x72.png',
},
};
var CoviIndex = 0;
var CoviPlayers = new Array();
function createCoviMain(coviConfig) {
var coviElem = document.getElementsByClassName('covi')[CoviIndex];
if (!coviElem) {
return;
}
coviElem.setAttribute('covi-index', CoviIndex);
var coviOpts = {
containerClassName: 'covi,' + CoviIndex,
style: 'auditorium',
type: 'dev',
pcode: '',
category: '',
videoPlayType: 'autoplay',
idx: CoviIndex,
rootElem: coviElem,
adIdentifier: '',
gender: '',
age: '',
};
const userAgent = window.navigator.userAgent;
const browserValue = getBrowserValue(userAgent);
switch (browserValue) {
case 2:
coviConfig['pcode'] = 'auditorium_aos';
break;
case 3:
coviConfig['pcode'] = 'auditorium_ios';
break;
default:
return;
}
if (coviConfig) {
var allowedKeys = [
'pcode',
'category',
'adIdentifier', 'gender', 'age',
'videoPlayCallback',
'videoPauseCallback',
'videoEndedCallback',
'noAdsCallback',
'videoLoadedCallback',
];
if (typeof coviConfig === 'string') {
coviOpts['adIdentifier'] = coviConfig;
}
if (typeof coviConfig === 'object' && Array.isArray(coviConfig) === false) {
for (var key in coviConfig) {
if (allowedKeys.indexOf(key) !== -1) {
coviOpts[key] = coviConfig[key];
}
}
}
}
var coviEventHandler = function (event) {
switch (event) {
case 'PLAYER_VIDEO_LOADEDMETADATA':
if (typeof coviConfig['videoLoadedCallback'] === 'function') {
coviConfig['videoLoadedCallback']();
}
break;
case 'PLAYER_VIDEO_PLAY':
if (typeof coviConfig['videoPlayCallback'] === 'function') {
coviConfig['videoPlayCallback']();
}
break;
case 'PLAYER_VIDEO_PAUSE':
if (typeof coviConfig['videoPauseCallback'] === 'function') {
coviConfig['videoPauseCallback']();
}
break;
case 'PLAYER_VIDEO_ENDED':
if (typeof coviConfig['videoEndedCallback'] === 'function') {
coviConfig['videoEndedCallback']();
}
break;
case 'PLAYER_NO_ADS':
console.log('[covi] no ads');
coviElem.style.display = 'block';
coviElem.style.textAlign = 'center';
coviElem.style.width = '100%';
if (typeof coviConfig['noAdsCallback'] === 'function') {
coviConfig['noAdsCallback']();
}
break;
}
};
var coviplayer = new CoviPlayer(coviOpts, coviEventHandler);
coviplayer.run();
CoviPlayers[CoviIndex] = coviplayer;
++CoviIndex;
}
function coviClickLandingButton(coviIndex) {
var coviplayer = CoviPlayers[coviIndex];
if (coviplayer) {
var landingUrl;
coviplayer.onClickLandingButton(function (url) {
landingUrl = url;
}, true);
var timer = window.setInterval(function () {
if (landingUrl !== 'undefined') {
window.clearInterval(timer);
window.open(landingUrl, '_blank');
}
}, 200);
}
}
function createCovi(coviConfig) {
window.setTimeout(function () {
createCoviMain(coviConfig);
}, 500);
}
function checkCoviTag(coviConfig) {
var elem = document.querySelector('.covi');
if (elem) {
createCovi(coviConfig);
}
}
function coviAdClose() {
var coviElem = document.getElementsByClassName('covi')[0];
if (!coviElem) {
return;
}
var parent = coviElem.parentElement;
parent.removeChild(coviElem);
}
function disposeCoviplayers() {
for (var player of CoviPlayers) {
player.dispose();
}
CoviPlayers = [];
CoviIndex = 0;
}
function runCoviplayer(coviConfig) {
if (coviConfig !== undefined) {
window.setTimeout(checkCoviTag(coviConfig), 0);
} else {
window.setTimeout(checkCoviTag(), 0);
}
}
function playVideo() {
var player = CoviPlayers[0];
if (player) {
player.playVideo();
}
}
function pauseVideo() {
var player = CoviPlayers[0];
if (player) {
player.stopVideo();
}
}
function getBrowserValue(userAgent) {
if (typeof userAgent === 'undefined') {
userAgent = window.navigator.userAgent;
}
userAgent = userAgent.toLowerCase();
if (userAgent.indexOf('android') >= 0) {
return 2;
} else if (userAgent.indexOf('iphone') >= 0) {
return 3;
} else if (userAgent.indexOf('ipad') >= 0) {
return 3;
} else if (userAgent.indexOf('ipod') >= 0) {
return 3;
} else if (userAgent.indexOf('windows') >= 0) {
return 1;
} else if (userAgent.indexOf('mac') >= 0) {
return 1;
}
}