var isAppExpired = true; //This app is expired and cant var housepartyactive = 0; var endImageThumb = ''; var endImgLoaded = 0; var bgImagesRec = 0; var bgImagesArr = []; var runningProgress = 0; var resumeAt = 0; var topCreateContainer; var oldDataUrl; var api = null; var copyVideo = true; var playingVideoElement; var videoAsset = { maskShowing: false }; var env = "-d"; var hasLowRes = true; var setAutoPlay = false; var getVideoList = {}; var headImages = []; var isFullScreen = false; var transYMouth = []; var isVideocompleted = 0; var socialImage = "https://host-d.oddcast.com/elfyourself2019/images/poster_image_elves.jpg"; var IsPlayeInterrupted = 0; var IsPlayerAI = 0; var arrJsonVideoGlobal = ""; var selectedAIOptionJs = 0; var innerAIOptionJs = 0; var styleAIData = []; var arrayAIData = {}; var setNewVideo = []; var checkNewVideo = 1; videoAsset = { 'hatImages': '', 'headImages': '', 'noOfHeads': '', 'greetings': '', 'headScale': '', 'scale': 2, "mouthTransY": '', 'trackingXML': '', 'videoId': '', 'videoIndex': '', 'videoURL': '', 'videoURLHighRes': '', 'videoURLLowRes': "", 'bgImages': [] } function getHeadImages(res, greeting, mouthPoints) { console.log('22222222'); headImages = []; transYMouth = []; var headImg = res.data; if (headImg.length > 0) { for (i = 0; i < headImg.length; i++) { var imgUrl = headImg[i]['url']; headImages.push(imgUrl); transYMouth.push(40); } } //InitAndSpeedDetect(function (res) { // console.log('changeVideo Video1',videoNumber) changeVideoAIStyle(videoNumber,selectedAIOptionJs,0,1); //}); setNoOfHeads(headImg.length); videoAsset.mouthTransY = mouthPoints; if (api != null) { api.closeVideo(); updateGreeting(greeting); } var scrollTo = document.querySelector('.video-list-main'); if(scrollTo !== null){ scrollTo.scrollTop = 0; } var countPositionVideo = 0; var scrollInt = setInterval(function(){ if(countPositionVideo > 10){ clearInterval(scrollInt); } var positionVideo = $(".video-list[list-index='" + videoNumber + "']").position(); $('.video-list').removeClass('videodance-activeclass'); $(".video-list[list-index='" + videoNumber + "']").addClass('videodance-activeclass'); if (positionVideo && positionVideo !== undefined) { clearInterval(scrollInt); if (positionVideo.top < 0) { positionVideo.top = positionVideo.top * -1 } scrollTo.scrollTop = positionVideo.top - 440; } countPositionVideo++; },500) } function elf_insertVideoPlayerHtml() { //var cWidth = $("#background-video-section").width(); var cWidth = $(".background-video-section").width(); var cHeight = cWidth / 1.78; var vidMainH = cHeight + 7; $('.preview-overlay').css({ 'height': cHeight, 'width': cWidth, 'margin': '3px', 'border-radius': '6px' }) $("#video-frame").css({ "border": "3px solid white", "height": vidMainH, "background-color": '#000', 'width': cWidth + 6, "padding": "0" }); $(".video-content.inner-main-div").css({ "height": vidMainH }); var insertVidhtml = '
\n\
';
aiVideoCheck = 1;
}
if (data[i]['is_new_dance'] === '1') {
newImage = '
';
var p_tag = $(this).parents('.single-section-inline').find('p').html();
p_tag = p_tag.substring(0, 13); // Get the first 13 characters
$(this).parents('.single-section-inline').append(html_append_style);
$('.ai-inner-image .inner-btn-text .inner-section-img').attr('src',$(this).parents('.single-section-inline').find('img').attr('src'));
$('.ai-inner-image .inner-btn-text p').html(p_tag);
// changeVideoAIStyle(getListId,0);
// callback("success");
}
});
$(".uploadImages").unbind('click');
$('.uploadImages').on('click', () => {
$('#holdOnSec').show();
$('.elf_saveImages').show();
videoClickingEvent();
})
$(".openFiles").unbind('click');
$('.openFiles').on('click', () => {
$('.uploadImg').click();
})
$(".danceBtnEffect .noImages").unbind('click');
$('.danceBtnEffect .noImages').on('click', () => {
$('.add-photo').hide();
$('.video-list').removeClass('videodance-activeclass');
//$('.video-list img').removeAttr("style");
bgImagesRec = 1;
var listIndex = $('.video-list.houseparty').attr("list-index");
setVideoObj(listIndex);
$('.video-list.houseparty').addClass('videodance-activeclass');
})
$('.video-list').unbind("click");
$('.video-list').on("click", function () {
var getAICheck = $(this).attr('list-ai');
IsPlayerAI = parseInt(getAICheck)
selectedAIOptionJs = 0;
if ($(this).hasClass('houseparty')) {
if (api != null) {
api.closeVideo();
}
housepartyactive = 1;
if(document.getElementById('video-loading') !== null)
{
document.getElementById("video-loading").style.display = "none";
}
$('#sharepopeventstop,#downloadPopEventstop,#getnftModal,#elfai-logo-main').addClass('sharingdisable');
isVideocompleted = 0;
if (videoAsset.bgImages.length == 0) {
$('.add-photo').show();
$('.download-photo').css('display', 'none')
if (api != null) {
api.closeVideo();
}
if(document.getElementById('video-frame') !== null && document.getElementById('VideoDiv') !== null)
{
document.getElementById("VideoDiv").style.display = 'none';
document.getElementById("video-frame").style.backgroundColor = '#000';
}
} else {
$('.dance-photo').show();
$('.download-photo').css('display', 'none')
if (api != null) {
api.closeVideo();
}
if(document.getElementById('video-frame') !== null && document.getElementById('VideoDiv') !== null)
{
document.getElementById("VideoDiv").style.display = 'none';
document.getElementById("video-frame").style.backgroundColor = '#000';
}
}
} else {
housepartyactive = 0;
$('.add-photo').hide();
$('.video-list').removeClass('videodance-activeclass');
//$('.video-list img').removeAttr("style");
var listIndex = $(this).attr("list-index");
setVideoObj(listIndex);
$(this).addClass('videodance-activeclass');
//$(this).find("img").css("border-color", "#fff");
$('.list-image').removeClass('videodance-activeclass');
$(".list-image[list-index='" + listIndex + "']").addClass('videodance-activeclass');
}
})
$('.list-image').unbind("click");
$('.list-image').on("click", function () {
var scrollTo = document.querySelector('.video-list-main');
scrollTo.scrollTop = 0;
selectedAIOptionJs = 0;
if ($(this).hasClass('houseparty')) {
$('#VideoDiv').css('display', 'none');
$('#sharepopeventstop,#downloadPopEventstop,#getnftModal,#elfai-logo-main').addClass('sharingdisable');
housepartyactive = 1;
if(document.getElementById('video-loading') !== null)
{
document.getElementById("video-loading").style.display = "none";
}
if (api != null) {
api.closeVideo();
}
$('#sharepopeventstop,#downloadPopEventstop,#getnftModal,#elfai-logo-main').addClass('sharingdisable');
isVideocompleted = 0;
if (videoAsset.bgImages.length == 0) {
$('.add-photo').show();
$('.download-photo').css('display', 'none')
if (api != null) {
api.closeVideo();
}
var listIndex = $(this).attr("list-index");
if(document.getElementById('video-frame') !== null && document.getElementById('VideoDiv') !== null)
{
document.getElementById("VideoDiv").style.display = 'none';
document.getElementById("video-frame").style.backgroundColor = '#000';
}
$('#background-video-full-list').removeClass('slider-expand');
$('#background-video-full-list').css('overflow', 'hidden');
var positionVideo = $(".video-list[list-index='" + listIndex + "']").position();
if (positionVideo.top < 0) {
positionVideo.top = positionVideo.top * -1
}
scrollTo.scrollTop = positionVideo.top - 300;
} else {
$('.dance-photo').show();
$('.download-photo').css('display', 'none')
if (api != null) {
api.closeVideo();
}
var listIndex = $(this).attr("list-index");
if(document.getElementById('video-frame') !== null && document.getElementById('VideoDiv') !== null)
{
document.getElementById("video-frame").style.backgroundColor = '#000';
document.getElementById("VideoDiv").style.display = 'none';
}
$('#background-video-full-list').removeClass('slider-expand');
$('#background-video-full-list').css('overflow', 'hidden');
var positionVideo = $(".video-list[list-index='" + listIndex + "']").position();
if (positionVideo.top < 0) {
positionVideo.top = positionVideo.top * -1
}
scrollTo.scrollTop = positionVideo.top - 300;
}
} else {
housepartyactive = 0;
$('.add-photo').hide();
$('.list-image').removeClass('videodance-activeclass');
//$('.list-image img').removeAttr("style");
var listIndex = $(this).attr("list-index");
setVideoObj(listIndex);
//$(this).find("img").css("border-color", "#fff");
$(this).addClass('videodance-activeclass');
$('#background-video-full-list').removeClass('slider-expand');
$('#background-video-full-list').css('overflow', 'hidden');
var positionVideo = $(".video-list[list-index='" + listIndex + "']").position();
$('.video-list').removeClass('videodance-activeclass');
$(".video-list[list-index='" + listIndex + "']").addClass('videodance-activeclass');
if (positionVideo.top < 0) {
positionVideo.top = positionVideo.top * -1
}
scrollTo.scrollTop = positionVideo.top - 300;
}
});
$('#progressBar').unbind("click");
$('#progressBar').on("click", function (e) {
var barW = $(this).width();
var persentage = e.originalEvent.offsetX * 100 / barW;
var forwardVideo = api.videoElement.duration * persentage / 100;
if (forwardVideo < 1) {
forwardVideo++;
}
goToByTime(forwardVideo);
if(document.getElementById('timeBar') !== null)
{
document.getElementById("timeBar").style.width = persentage + "%";
}
if (!playingVideoElement.paused) {
playingVideoElement.play();
if(document.getElementById('pauseOrPlay') !== null && document.getElementById("playOrPause") !== null)
{
document.getElementById("pauseOrPlay").style.display = "none";
document.getElementById("playOrPause").style.display = "block";
}
}
});
$('#logo_image').unbind("click");
$('#logo_image').on("click", function (e) {
if (api != null)
{
api.closeVideo();
}
});
var isOnMouse = 1;
var setIn = '';
$('#VideoDiv').unbind("mousemove");
$("#VideoDiv").on("mousemove", function (e) {
if (setIn != "") {
clearInterval(setIn);
}
$("#buttonDiv").show();
setIn = setInterval(function () {
isOnMouse = 0;
$("#buttonDiv").fadeOut(1000);
clearInterval(setIn);
}, 3000);
}).mouseleave(function () {
$("#buttonDiv").fadeOut("slow");
});
var cWidth = $("#video-frame").width();
var controlW = cWidth * 60 / 100;
var marginLeftRight = cWidth * 20 / 100;
// $("#buttonDiv").css({ "width": controlW, "margin-left": marginLeftRight, "margin-right": marginLeftRight });
}
function setVideoObj(videoId) {
isVideocompleted = 0;
$('#VideoDiv').css('display', 'none');
$('.download-photo').css('display', 'none');
$('#sharepopeventstop,#downloadPopEventstop,#getnftModal,#elfai-logo-main').addClass('sharingdisable');
if (document.getElementById("video-frame"))
document.getElementById("video-frame").style.backgroundColor = '#000';
if (document.getElementById("video-loading"))
document.getElementById("video-loading").style.verticalAlign = 'middle';
if (document.getElementById("video-frame"))
document.getElementById("video-frame").style.display = 'table';
if (document.getElementById("video-loading"))
document.getElementById("video-loading").style.display = 'table-cell';
// console.log('changeVideo Video2',videoNumber)
videoNumber = videoId;
changeVideoAIStyle(videoId,0);
}
function readyToPlayCallback() {
//sdocument.getElementById("buttonDiv").style.display="block";
//pauseOrPlay();
}
function startVideo() {
if (api != null && IsPlayeInterrupted == 0) {
hasLowRes = false;
var filterString = (videoAsset.videoId == 5) ? "charleston" : null;
videoAsset.videoURL = hasLowRes ? videoAsset.videoURLLowRes : videoAsset.videoURLHighRes;
api.loadVideoURL(
videoAsset.videoURL,
function (videoElement) { // needs to be on gui thread on mobile?
api.loadTrackingData(
videoAsset.trackingXML, //"House_Party_5h_2Ddata.xml",
function () {
//todo - loading of heads, hats, background, greeting text, offsets and scale, will go in here
playingVideoElement = videoElement;
api.useOnscreenTimeCode(32);
//mouthImage = videoAsset.videoId == 7 ? ["http://host"+ env +".oddcast.com/ccs6/customhost/1342/misc/mouths_spritesheet.png"] : null;
mouthImage = videoAsset.videoId == 7 ? ["//host" + env +
".oddcast.com/ccs6/customhost/1384/misc/mouths_spritesheet.png"
] : null;
fineTuneHeads();
api.setImageUrls( //load heads
"head",
//["images/head-1.png","images/head-2.png","images/head-3.png","images/head-4.png","images/head-5.png"],
videoAsset.headImages,
function () {
videoAssetBgImages = videoAsset.videoId == 14 ? videoAsset.bgImages :
[];
api.setImageUrls( //load backgrounds
"image",
//["images/background-1.png","images/background-2.png","images/background-1.png","images/background-2.png","images/background-1.png","images/background-2.png"],
videoAssetBgImages,
function () {
api.setImageUrls( //load hats
"hat",
//["images/hats/hat_elf.png"],
videoAsset.hatImages,
function () {
api.setImageUrls( //load mouth
"mouth",
mouthImage,
function () {
api.setGreetingMessage(videoAsset
.greetings, 4.0, 0.065,
"font=Open Sans;fontEffect=bold;textAlign=center;textColor=#ffffff;xPercent=0.5;yPercent=0.90;bgColor=#000000;bgAlpha=0.5;bgWidth=10.0;bgHeight=1.5;bgHeightShift=1.4"
);
api.setVideoFrameOffset(videoAsset
.offset);
api.setScale("heads", videoAsset
.headScale
); //default scale of head
api.setTransY("heads", videoAsset
.headTransY
); //raise head with a negative value, lower with a positive value - in pixels relative to the 1024 wide video.
if (mouthImage != null) {
for (i = 0; i < videoAsset
.headImages.length; i++) {
//api.setScale("mouth1", 0.5); //default scale of mouth images
api.setTransY("mouth" + (i +1), videoAsset.mouthTransY[i]); //raise head with a negative value
}
}
if (window.readyToPlayCallback !=
null)
readyToPlayCallback();
var imgloaded = setInterval(() => {
if(endImgLoaded === 1 && housepartyactive !== 1){
clearInterval(imgloaded);
$('#sharepopeventstop,#downloadPopEventstop,#getnftModal,#elfai-logo-main').removeClass('sharingdisable');
if(document.getElementById('VideoDiv') !== null && document.getElementById('video-loading') !== null)
{
document.getElementById("VideoDiv").style.display = 'block';
document.getElementById("video-loading").style.display = 'none';
}
}
}, 100);
// if(!mobileAndTabletcheck() && setAutoPlay) {
if (setAutoPlay) {
//playingVideoElement.play();
if (videoAsset.videoId === "1" || videoAsset.videoId === "5")
skip(1);
else
skip(0);
if( housepartyactive !== 1){
var promise = playingVideoElement.play();
}
if (promise !== undefined) {
promise.then(function (_) {
// Autoplay started!
document
.getElementById(
"video-loading"
).style
.display =
'none';
try {
document
.getElementById(
"video-external-play"
)
.style
.display =
'none';
} catch (e) { }
}).catch(function (
error) {
// Autoplay was prevented.
// Show a "Play" button so that user can start playback.
if(document.getElementById('poster-outer') !== null && document.getElementById('buttonDiv') !== null){ document.getElementById('poster-outer').style.display = "block"; document.getElementById('buttonDiv').style.visibility = "hidden"; }
if(document.getElementById('video-loading') !== null)
{
document.getElementById("video-loading").style.display ='none';
}
try {
if(document.getElementById('video-external-play') !== null)
{
document.getElementById("video-external-play").style.display ='block';
}
pauseOrPlay();
} catch (e) { }
//pauseOrPlay();
try {
let image = document.createElement("img");
image.src = socialImage;
image.style.width = "100%";
image.style.position = "absolute";
image.style.zIndex = "1";
let buttonDiv = document.getElementById("buttonDiv");
//buttonDiv.after(image);
} catch (e) {
if (window.console) { console.log(
'Failed to show poster image'
); }
}
});
}
}
if (!setAutoPlay) {
if (videoAsset.videoId === "1" || videoAsset.videoId === "5")
skip(1);
else
skip(0);
}
if(housepartyactive === 0)
pauseOrPlay();
},
function (url, error) {
if (window.console) { console.log(url + " " + error); }
},
filterString
);
},
function (url, error) {
if (window.console) { console.log(url + " " + error); }
}, filterString
);
},
function (url, error) {
if (window.console) { console.log(url + " " + error); }
}, filterString
);
},
function (url, error) {
if (window.console) { console.log(url + " " + error); }
}, filterString
);
},
function (url, error) {
if (window.console) { console.log(error); }
}
);
},
function (url, error) {
if (window.console) { console.log(error); }
}
);
}
}
var incDigit = 0
// video controls
function pauseOrPlay() {
if (playingVideoElement != null) {
if (playingVideoElement.paused) {
try {
if(document.getElementById('pauseOrPlay') !== null && document.getElementById("playOrPause") !== null)
{
document.getElementById("pauseOrPlay").style.display = "block";
document.getElementById("playOrPause").style.display = "none";
}
} catch (e) { }
var promise1 = playingVideoElement.play();
if (promise1 !== undefined) {
promise1.then(function (_) {
$('#playButton').hide();
if(document.getElementById('pauseOrPlay') !== null && document.getElementById("playOrPause") !== null)
{
document.getElementById("pauseOrPlay").style.display = "none";
document.getElementById("playOrPause").style.display = "block";
}
}).catch(function (error) {
// Autoplay was prevented.
// Show a "Play" button so that user can start playback.
$('#playButton').show();
if(document.getElementById('poster-outer') !== null && document.getElementById('buttonDiv') !== null){ document.getElementById('poster-outer').style.display = "block"; document.getElementById('buttonDiv').style.visibility = "hidden";}
try {
//embed code function called.
pauseorPlay();
} catch (e) {
if (window.console) { console.log("Error: ", e.message); }
}
});
}
} else {
try {
if(document.getElementById('pauseOrPlay') !== null && document.getElementById("playOrPause") !== null)
{
document.getElementById("pauseOrPlay").style.display = "block";
document.getElementById("playOrPause").style.display = "none";
}
} catch (e) { }
playingVideoElement.pause();
}
}
}
var maskShowing = 0;
function showMask2() {
maskShowing = api.debug_showMask2(maskShowing + 1);
}
function incMaxEdges(inc) {
api.debug_incMaxEdges(inc);
}
function incMaxShapes(inc) {
api.debug_incMaxShapes(inc);
}
function nextMaskFrame(inc) {
api.debug_getNextMaskFrame(inc);
}
function fullScreen() {
if (playingVideoElement != null) {
}
}
//1 fullscreen, 2 fullbrowser, 0 regular brwoser
function isFullScreen() {
if (api == null) return 0;
return api.isFullScreen();
}
function toggleCopyVideo() {
copyVideo = !copyVideo;
api.setCopyVideo(copyVideo);
}
function launchIntoFullscreenE() {
var isFull = $("#fullscreen").attr("is-full");
if (isFull == 1) {
$("#VideoDiv").css({
"width": '680px',
"height": '382px'
});
isFullScreen = true;
api.toFullScreen(0);
$("#fullscreen").attr("is-full", 0)
} else {
$("#fullscreen").attr("is-full", 1)
closeFullscreen();
isFullScreen = false;
}
}
function GoInFullscreen() {
if($(window).width() < $(window).height()){
var cWidth = $(window).width();
cWidth = (cWidth*98)/100;
var cHeight = cWidth / 1.78;
}
else{
var cHeight = $(window).height();
cHeight = (cHeight*98)/100;
var cWidth = cHeight * 1.78;
$('.replace_video_here').css({
'top':'0'
})
}
$('#custom-footer').hide();
$('.replace_video_here').css({
'position':'fixed',
'left':'0.5%',
'width':cWidth,
'height':cHeight,
'z-index':'9'
})
$(".forCreateYourOwn").css({
"width": cWidth,
"height": cHeight
});
}
function enterIosSafariFullScreen(){
if($(window).width() < $(window).height()){
var cWidth = $(window).width();
var cHeight = cWidth / 1.78;
var laftCss = '0';
}
else{
var cHeight = $(window).height();
var cWidth = cHeight * 1.78;
$('.replace_video_here').css({
'top':'1%'
})
var laftCss = ($(window).width()-cWidth)/2+'px'
}
$('#custom-footer').hide();
$('.replace_video_here').css({
'position':'fixed',
'left':laftCss,
'width':cWidth,
'height':cHeight,
'z-index':'9',
"border":'unset'
})
$(".forCreateYourOwn").css({
"width": cWidth,
"height": cHeight,
});
}
function exitIosSafariFullScreen(){
if($(window).width() > $(window).height()){
$('.replace_video_here').css({
'position':'relative',
'left':'unset',
'width':'unset',
'height':'unset',
'z-index':'unset',
'top':'unset',
"border":'3px solid #fff'
})
$('#custom-footer').show();
$(".forCreateYourOwn").css({
"width": $('.create-own-video-content').width()-6,
"height": ($('.create-own-video-content').width()-6)/1.78
});
}
else{
$('.replace_video_here').css({
'position':'relative',
'left':'unset',
'width':'unset',
'height':'unset',
'z-index':'unset',
'top':'unset',
"border":'3px solid #fff'
})
$('#custom-footer').show();
$(".forCreateYourOwn").css({
"width": $(window).width()*0.927,
"height": ($(window).width()*0.927)/1.78
});
}
}
function launchIntoFullscreen() {
var isFull = $("#fullscreen").attr("is-full");
if (isFull == 1) {
topCreateContainer = $('.createyourowncontainer').css('top');
var btnControlW = $("#buttonDiv").width();
isFullScreen = true;
if(/iPhone/.test(navigator.platform)){
//enterIosSafariFullScreen();
$("#fullscreen").css("pointer-events","none");
setTimeout(() => {
enterIosSafariFullScreen();
$("#fullscreen").css("pointer-events","unset");
},1100);
}
else{
api.toFullScreen(0);
}
$("#fullscreen").attr("is-full", 0)
} else {
setTimeout(() => {
$('.createyourowncontainer').css('top', topCreateContainer);
if (typeof resizing == "function") {
resizing();
}
}, 300);
$("#fullscreen").attr("is-full", 1)
if(/iPhone/.test(navigator.platform)){
exitIosSafariFullScreen();
}
else{
closeFullscreen();
}
isFullScreen = false;
}
}
window.addEventListener("orientationchange", function(event) {
if (typeof resizing == "function")
resizing();
if (isFullScreen) {
if(/iPhone|iPod|iPad/.test(navigator.platform)){
enterIosSafariFullScreen();
setTimeout(() => {
enterIosSafariFullScreen();
resizing();
},1100);
}
} else {
if(/iPhone|iPod|iPad/.test(navigator.platform)){
exitIosSafariFullScreen();
resizing();
}
}
});
function closeFullscreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
}
function launchIntoFullBrowser() {
api.toFullScreen(2)
}
function exitFull() {
api.toFullScreen(-1);
}
function muteAudio() {
if (api.videoElement.muted) {
api.videoElement.muted = false;
$("#vol").attr("src", "../images/volume.png");
} else {
api.videoElement.muted = true;
$("#vol").attr("src", "../images/mute.png");
}
}
function closeVideo() {
if (api != null) {
api.closeVideo();
}
playingVideoElement = null;
}
function dispose() {
if (api != null) {
api.dispose();
}
api = null;
}
function setNoOfHeads(num) {
videoAsset.noOfHeads = num;
}
function skip(value) {
api.videoElement.currentTime += value;
}
function updateGreeting(greetings) {
videoAsset.greetings = greetings;
api.setGreetingMessage(videoAsset.greetings, 4.0, 0.065,
"font=Open Sans;fontEffect=bold;textAlign=center;textColor=#ffffff;xPercent=0.5;yPercent=0.90;bgColor=#000000;bgAlpha=0.5;bgWidth=10.0;bgHeight=1.5;bgHeightShift=1.4"
);
}
function goToByTime(t) {
api.videoElement.currentTime = t;
}
function restart() {
if (playingVideoElement.paused) {
if (videoAsset.videoId === "1")
// skip(1);
goToByTime(1);
else
// skip(0);
goToByTime(0);
playingVideoElement.play();
if(document.getElementById('pauseOrPlay') !== null && document.getElementById("playOrPause") !== null)
{
document.getElementById("pauseOrPlay").style.display = "none";
document.getElementById("playOrPause").style.display = "block";
}
} else {
goToByTime(1);
}
}
function fineTuneHeads() {
switch (parseInt(videoAsset.videoId)) {
//80s
case 9:
switch (headImages.length) {
case 1:
videoAsset.headImages = [headImages[0], headImages[0], headImages[0], headImages[0], headImages[
0]];
break;
case 2:
// videoAsset.headImages = [headImages[0], headImages[0], headImages[0], headImages[1], headImages[1]];
videoAsset.headImages = [headImages[0], headImages[1], headImages[0], headImages[0], headImages[
1]];
break;
case 3:
// videoAsset.headImages = [headImages[0], headImages[1], headImages[0], headImages[1], headImages[2]];
videoAsset.headImages = [headImages[0], headImages[1], headImages[2], headImages[2], headImages[
1]];
break;
case 4:
videoAsset.headImages = [headImages[0], headImages[1], headImages[2], headImages[3], headImages[
0]];
break;
}
break;
//Hanukka
case 13:
switch (headImages.length) {
case 1:
videoAsset.headImages = [headImages[0], headImages[0], headImages[0], headImages[0], headImages[
0]];
break;
case 2:
videoAsset.headImages = [headImages[0], headImages[1], headImages[0], headImages[0], headImages[
1]];
break;
case 3:
videoAsset.headImages = [headImages[0], headImages[1], headImages[2], headImages[2], headImages[
1]];
break;
case 4:
videoAsset.headImages = [headImages[0], headImages[1], headImages[2], headImages[3], headImages[
0]];
break;
}
break;
//mashup
case 16:
switch (headImages.length) {
case 1:
videoAsset.headImages = [headImages[0], headImages[0]];
break;
}
break;
//Secret Santa
case 17:
switch (headImages.length) {
case 1:
videoAsset.headImages = [headImages[0], headImages[0]];
break;
}
break;
}
//videoAsset.noOfHeads = videoAsset.headImages.length;
}
function showExpired() {
if(document.getElementById('VideoDiv') !== null)
{
document.getElementById("VideoDiv").innerHTML =
"
";
}
try {
if(document.getElementById('video-loading') !== null)
{
document.getElementById("video-loading").visibility = "hidden";
document.getElementById("video-loading").style.display = "none";
}
} catch (e) {
if (window.console) { console.log(e.message); }
}
setTimeout(removeButtonDiv(), 1000);
}
function removeButtonDiv() {
var elementButtonDiv = document.getElementById("buttonDiv");
try {
elementButtonDiv.removeAttribute("style");
} catch (e) {
if (window.console) { console.log(e.message); }
}
try {
elementButtonDiv.innerHTML = '';
} catch (e) {
if (window.console) { console.log(e.message); }
}
try {
elementButtonDiv.removeAttribute("id");
} catch (e) {
if (window.console) { console.log(e.message); }
}
}
function init() {
dispose();
api = new com.oddcast.app.videoOverlay.VideoOverlayEngine().getAPI();
api.init2("VideoDiv", copyVideo);
// startVideo(); //only for desktop?
var inProgressTime = -1;
api.videoElement.ontimeupdate = function () { // video playing
runningProgress = api.videoElement.currentTime * 100 / api.videoElement.duration;
if (inProgressTime > 0) {
if(document.getElementById('timeBar') !== null)
{
document.getElementById("timeBar").style.width = runningProgress + "%";
}
}
if (runningProgress > 99) {
if(document.getElementById('pauseOrPlay') !== null && document.getElementById("playOrPause") !== null)
{
document.getElementById("pauseOrPlay").style.display = "block";
document.getElementById("playOrPause").style.display = "none";
}
}
if (runningProgress == 100) { // when video finishes.
isVideocompleted = 1;
setTimeout(function () {
if(isVideocompleted == 1){ $('.download-photo').css('display', 'block'); }
}, 2000)
}
inProgressTime++;
try {
if(document.getElementById('currentTime') !== null && document.getElementById('totalTime') !== null)
{
document.getElementById("currentTime").innerHTML = api.videoElement.currentTime;
document.getElementById("totalTime").innerHTML = api.videoElement.duration;
}
} catch (e) {
}
};
}
function InitAndSpeedDetect(callback) {
// var imageAddr = "//content.oddcast.com/ccs6/customhost/1384/misc/bandwidth_test_image.jpg";
// var imageAddr = "//content-vd.oddcast.com/ccs6/customhost/1384/misc/bandwidth_test_image2.jpg";
var imageAddr = "../images/bandwidth_test_image2.jpg"
var downloadSize = 32159; //bytes
// var downloadSize = 223941 ;
var limitToDecide = 2500; //2000 kbps
MeasureConnectionSpeed();
function MeasureConnectionSpeed() {
var startTime, endTime;
var download = new Image();
download.onload = function () {
endTime = (new Date()).getTime();
var duration = (endTime - startTime) / 1000;
var bitsLoaded = downloadSize * 8;
var speedBps = (bitsLoaded / duration).toFixed(2);
var speedKbps = (speedBps / 1024).toFixed(2);
if (speedKbps < limitToDecide) {
hasLowRes = true;
}
else {
hasLowRes = false;
}
callback("success");
}
download.onerror = function (err, msg) {
//hasLowRes = true;
}
startTime = (new Date()).getTime();
var cacheBuster = "?nnn=" + startTime;
download.src = imageAddr + cacheBuster;
}
};
function changeVideoAIStyle(index,index_style = 0,changeI = 0, firstload = 0) {
index = parseInt(index);
index_style = parseInt(index_style);
changeI = parseInt(changeI);
firstload = parseInt(firstload);
// console.log('changeVideoAIStyle',index)
// console.log('index_style',index_style)
// console.log('changeI',changeI)
// console.log('firstload',firstload)
if (api != null && IsPlayeInterrupted == 0)
{
if( (index_style != 0) && (firstload == 1) ){
console.log('edit back')
var checkAIIndex = index_style;
}else{
var checkAIIndex = 0;
$.each(arrayAIData, (ind_ss, val_ss) => {
if( ind_ss == index ){
index_style = val_ss;
checkAIIndex = val_ss;
selectedAIOptionJs = val_ss;
}
});
}
api.closeVideo();
endImgLoaded = 0;
housepartyactive = 0;
isVideocompleted = 0;
// endImageThumb = '';
styleAIData = [];
setNewVideo = [];
$('#VideoDiv').css('display', 'none');
$('.download-photo').css('display', 'none');
$('#sharepopeventstop,#downloadPopEventstop,#getnftModal,#elfai-logo-main,#elfai-logo-main').addClass('sharingdisable');
if (document.getElementById("video-frame"))
document.getElementById("video-frame").style.backgroundColor = '#000';
if (document.getElementById("video-loading"))
document.getElementById("video-loading").style.verticalAlign = 'middle';
if (document.getElementById("video-frame"))
document.getElementById("video-frame").style.display = 'table';
if (document.getElementById("video-loading"))
document.getElementById("video-loading").style.display = 'table-cell';
videoAsset.videoId = index;
var headCount = headImages.length;
var loadList = setInterval(function () {
if (Object.keys(getVideoList).length !== 0) {
if ( checkNewVideo == 1 ) {
var data = getVideoList.data;
if(Array.isArray(getVideoList.data)){
var dataLength = data.length;
}
else{
var dataLength = Object.keys(getVideoList.data).length
}
for (i = 0; i <= dataLength; i++) {
if(data[i] && data[i]['is_ar'] == 0){
if (data[i]['is_new_dance'] === '1') {
setNewVideo.push(data[i]['index']);
}
}
}
var randomIndex = Math.floor(Math.random() * setNewVideo.length);
var randomElement = setNewVideo[randomIndex];
index = parseInt(randomElement);
videoAsset.videoId = index;
checkNewVideo = 2;
videoNumber = index;
setTimeout(function () {
// console.log('videoAsset.setNewVideo',setNewVideo)
// console.log('videoAsset.randomIndex',randomIndex)
// console.log('videoAsset.videoId',index)
$('.video-list').removeClass('videodance-activeclass');
$(".video-list[list-index='" + index + "']").addClass('videodance-activeclass');
if ($(".video-list[list-index='" + index + "']").position().top > 180) {
// Calculate the new scroll position relative to the current scroll position
var scrollToPosition =
$(".video-list[list-index='" + index + "']").position().top +
$(".video-list-main").scrollTop() - $(".video-list-main").height() / 2 + 80;
console.log('manish work', scrollToPosition);
// Animate the scroll within the parent div
$(".video-list-main").animate({
scrollTop: scrollToPosition
}, 2000);
}
}, 500);
}
var get_video_list_ai = getVideoList.data[index].videos;
for( q_ai in get_video_list_ai ){
var innerget_video_list_ai = get_video_list_ai[q_ai];
for( innerq_ai in innerget_video_list_ai ){
styleAIData.push(innerget_video_list_ai[innerq_ai].style);
var setstylevar = innerget_video_list_ai[innerq_ai].style.id;
if( setstylevar == '' || setstylevar == undefined ){
setstylevar = 0;
}
var setnoOfHeads = parseInt(innerget_video_list_ai[innerq_ai].noOfHeads);
var setstyletype = parseInt(setstylevar);
if( (setnoOfHeads == headCount) && (setstyletype == index_style) ){
clearInterval(loadList);
var arrJsonVideo = innerget_video_list_ai;
for (key in arrJsonVideo) {
arrJsonVideo[key].videoId = index;
if (arrJsonVideo[key].videoId == videoAsset.videoId) {
videoAsset.videoIndex = key;
videoAsset.videoURLLowRes = arrJsonVideo[videoAsset.videoIndex].videoURLLowRes;
arrJsonVideoGlobal = arrJsonVideo[videoAsset.videoIndex];
videoAsset.videoURLHighRes = arrJsonVideo[videoAsset.videoIndex].videoURL;
videoAsset.videoURL = hasLowRes ? arrJsonVideo[videoAsset.videoIndex].videoURLLowRes :
arrJsonVideo[
videoAsset.videoIndex].videoURL;
videoAsset.trackingXML = arrJsonVideo[videoAsset.videoIndex].trackingXml;
videoAsset.offset = arrJsonVideo[videoAsset.videoIndex].offset;
videoAsset.headScale = arrJsonVideo[videoAsset.videoIndex].scale;
videoAsset.headImages = headImages;
if (arrJsonVideo[videoAsset.videoIndex].poster_image == "" || arrJsonVideo[videoAsset.videoIndex].poster_image == null) {
endImgLoaded = 1;
}
else{
endImgLoaded = 1;
}
videoAsset.hatImages = [];
if (arrJsonVideo[videoAsset.videoIndex].hatUrl1.length > 0) {
var hatImg = arrJsonVideo[videoAsset.videoIndex].hatUrl1;
hatImg = hatImg.replace("http://", "https://");
videoAsset.hatImages.push(hatImg);
}
if (arrJsonVideo[videoAsset.videoIndex].hatUrl2.length > 0) {
var hatImg = arrJsonVideo[videoAsset.videoIndex].hatUrl2;
hatImg = hatImg.replace("http://", "https://");
videoAsset.hatImages.push(hatImg);
}
var videoURLLowRes = videoAsset.videoURLLowRes;
var videoURLHighRes = videoAsset.videoURLHighRes;
var videoURL = videoAsset.videoURL;
var trackingXML = videoAsset.trackingXML;
videoAsset.videoURLLowRes = videoURLLowRes.replace("http://", "https://");
videoAsset.videoURLHighRes = videoURLHighRes.replace("http://", "https://");
videoAsset.videoURL = videoURL.replace("http://", "https://");
videoAsset.trackingXML = trackingXML.replace("http://", "https://");
}
}
// console.log('videoAsset',videoAsset)
startVideo();
}
}
}
if( changeI == 0 ){
styleAIData = [...new Map(styleAIData.map(entry => [JSON.stringify(entry), entry])).values()];
var html_append_style = '';
var errorImg = base_url+'/images/square_ai_img.png';
$.each(styleAIData, (ind_s, val_s) => {
html_append_style += ''+val_s.name+'
'; if( (index_style != 0) && (firstload == 1) ){ if( val_s.id == checkAIIndex ){ var text_ai_select = val_s.name.substring(0, 13); html_append_style += '
';
$('.ai-inner-image .inner-btn-text .inner-section-img').attr('src',val_s.thumb);
$('.ai-inner-image .inner-btn-text p').html(text_ai_select);
}
}else{
if( ind_s == checkAIIndex ){
var text_ai_select = val_s.name.substring(0, 13);
html_append_style += '
';
$('.ai-inner-image .inner-btn-text .inner-section-img').attr('src',val_s.thumb);
$('.ai-inner-image .inner-btn-text p').html(text_ai_select);
}
}
html_append_style += '