/********************************************
* REVOLUTION 5.2.5.1 EXTENSION - VIDEO FUNCTIONS
* @version: 2.0.2 (25.11.2016)
* @requires jquery.themepunch.revolution.js
* @author ThemePunch
*********************************************/
! function(a) {
"use strict";
function e(a) {
return void 0 == a ? -1 : jQuery.isNumeric(a) ? a : a.split(":").length > 1 ? 60 * parseInt(a.split(":")[0], 0) + parseInt(a.split(":")[1], 0) : a
}
var b = jQuery.fn.revolution,
c = b.is_mobile(),
d = {
alias: "Video Min JS",
name: "revolution.extensions.video.min.js",
min_core: "5.3",
version: "2.0.2"
};
jQuery.extend(!0, b, {
preLoadAudio: function(a, c) {
return "stop" !== b.compare_version(d).check && void a.find(".tp-audiolayer").each(function() {
var a = jQuery(this),
d = {};
0 === a.find("audio").length && (d.src = void 0 != a.data("videomp4") ? a.data("videomp4") : "", d.pre = a.data("videopreload") || "", void 0 === a.attr("id") && a.attr("audio-layer-" + Math.round(199999 * Math.random())), d.id = a.attr("id"), d.status = "prepared", d.start = jQuery.now(), d.waittime = 1e3 * a.data("videopreloadwait") || 5e3, "auto" != d.pre && "canplaythrough" != d.pre && "canplay" != d.pre && "progress" != d.pre || (void 0 === c.audioqueue && (c.audioqueue = []), c.audioqueue.push(d), b.manageVideoLayer(a, c)))
})
},
preLoadAudioDone: function(a, b, c) {
b.audioqueue && b.audioqueue.length > 0 && jQuery.each(b.audioqueue, function(b, d) {
a.data("videomp4") !== d.src || d.pre !== c && "auto" !== d.pre || (d.status = "loaded")
})
},
resetVideo: function(a, d, f) {
var g = a.data();
switch (g.videotype) {
case "youtube":
g.player;
try {
if ("on" == g.forcerewind) {
var i = e(a.data("videostartat")),
j = i == -1,
k = 1 === g.bgvideo || a.find(".tp-videoposter").length > 0;
i = i == -1 ? 0 : i, void 0 != g.player && (0 !== i && !j || k) && (g.player.seekTo(i), g.player.pauseVideo())
}
} catch (a) {}
0 == a.find(".tp-videoposter").length && 1 !== g.bgvideo && f !== !0 && punchgs.TweenLite.to(a.find("iframe"), .3, {
autoAlpha: 1,
display: "block",
ease: punchgs.Power3.easeInOut
});
break;
case "vimeo":
var l = $f(a.find("iframe").attr("id"));
try {
if ("on" == g.forcerewind) {
var i = e(g.videostartat),
j = i == -1,
k = 1 === g.bgvideo || a.find(".tp-videoposter").length > 0;
i = i == -1 ? 0 : i, (0 !== i && !j || k) && (l.api("seekTo", i), l.api("pause"))
}
} catch (a) {}
0 == a.find(".tp-videoposter").length && 1 !== g.bgvideo && f !== !0 && punchgs.TweenLite.to(a.find("iframe"), .3, {
autoAlpha: 1,
display: "block",
ease: punchgs.Power3.easeInOut
});
break;
case "html5":
if (c && 1 == g.disablevideoonmobile) return !1;
var n = "html5" == g.audio ? "audio" : "video",
o = a.find(n),
p = o[0];
if (punchgs.TweenLite.to(o, .3, {
autoAlpha: 1,
display: "block",
ease: punchgs.Power3.easeInOut
}), "on" == g.forcerewind && !a.hasClass("videoisplaying")) try {
var i = e(g.videostartat);
p.currentTime = i == -1 ? 0 : i
} catch (a) {}("mute" == g.volume || b.lastToggleState(a.videomutetoggledby) || d.globalmute === !0) && (p.muted = !0)
}
},
isVideoMuted: function(a, b) {
var c = !1,
d = a.data();
switch (d.videotype) {
case "youtube":
try {
var e = d.player;
c = e.isMuted()
} catch (a) {}
break;
case "vimeo":
try {
$f(a.find("iframe").attr("id"));
"mute" == d.volume && (c = !0)
} catch (a) {}
break;
case "html5":
var g = "html5" == d.audio ? "audio" : "video",
h = a.find(g),
i = h[0];
i.muted && (c = !0)
}
return c
},
muteVideo: function(a, b) {
var c = a.data();
switch (c.videotype) {
case "youtube":
try {
var d = c.player;
d.mute()
} catch (a) {}
break;
case "vimeo":
try {
var e = $f(a.find("iframe").attr("id"));
a.data("volume", "mute"), e.api("setVolume", 0)
} catch (a) {}
break;
case "html5":
var f = "html5" == c.audio ? "audio" : "video",
g = a.find(f),
h = g[0];
h.muted = !0
}
},
unMuteVideo: function(a, b) {
if (b.globalmute !== !0) {
var c = a.data();
switch (c.videotype) {
case "youtube":
try {
var d = c.player;
d.unMute()
} catch (a) {}
break;
case "vimeo":
try {
var e = $f(a.find("iframe").attr("id"));
a.data("volume", "1"), e.api("setVolume", 1)
} catch (a) {}
break;
case "html5":
var f = "html5" == c.audio ? "audio" : "video",
g = a.find(f),
h = g[0];
h.muted = !1
}
}
},
stopVideo: function(a, b) {
var c = a.data();
switch (b.leaveViewPortBasedStop || (b.lastplayedvideos = []), b.leaveViewPortBasedStop = !1, c.videotype) {
case "youtube":
try {
var d = c.player;
if (2 === d.getPlayerState() || 5 === d.getPlayerState()) return;
d.pauseVideo(), c.youtubepausecalled = !0, setTimeout(function() {
c.youtubepausecalled = !1
}, 80)
} catch (a) {
console.log("Issue at YouTube Video Pause:"), console.log(a)
}
break;
case "vimeo":
try {
var e = $f(a.find("iframe").attr("id"));
e.api("pause"), c.vimeopausecalled = !0, setTimeout(function() {
c.vimeopausecalled = !1
}, 80)
} catch (a) {
console.log("Issue at Vimeo Video Pause:"), console.log(a)
}
break;
case "html5":
var f = "html5" == c.audio ? "audio" : "video",
g = a.find(f),
h = g[0];
void 0 != g && void 0 != h && h.pause()
}
},
playVideo: function(a, d) {
clearTimeout(a.data("videoplaywait"));
var g = a.data();
switch (g.videotype) {
case "youtube":
if (0 == a.find("iframe").length) a.append(a.data("videomarkup")), h(a, d, !0);
else if (void 0 != g.player.playVideo) {
var i = e(a.data("videostartat")),
j = g.player.getCurrentTime();
1 == a.data("nextslideatend-triggered") && (j = -1, a.data("nextslideatend-triggered", 0)), i != -1 && i > j && g.player.seekTo(i), g.youtubepausecalled !== !0 && g.player.playVideo()
} else a.data("videoplaywait", setTimeout(function() {
g.youtubepausecalled !== !0 && b.playVideo(a, d)
}, 50));
break;
case "vimeo":
if (0 == a.find("iframe").length) a.append(a.data("videomarkup")), h(a, d, !0);
else if (a.hasClass("rs-apiready")) {
var k = a.find("iframe").attr("id"),
l = $f(k);
void 0 == l.api("play") ? a.data("videoplaywait", setTimeout(function() {
g.vimeopausecalled !== !0 && b.playVideo(a, d)
}, 50)) : setTimeout(function() {
l.api("play");
var b = e(a.data("videostartat")),
c = a.data("currenttime");
1 == a.data("nextslideatend-triggered") && (c = -1, a.data("nextslideatend-triggered", 0)), b != -1 && b > c && l.api("seekTo", b)
}, 510)
} else a.data("videoplaywait", setTimeout(function() {
g.vimeopausecalled !== !0 && b.playVideo(a, d)
}, 50));
break;
case "html5":
if (c && 1 == a.data("disablevideoonmobile")) return !1;
var m = "html5" == g.audio ? "audio" : "video",
n = a.find(m),
o = n[0],
p = n.parent();
if (1 != p.data("metaloaded")) f(o, "loadedmetadata", function(a) {
b.resetVideo(a, d), o.play();
var c = e(a.data("videostartat")),
f = o.currentTime;
1 == a.data("nextslideatend-triggered") && (f = -1, a.data("nextslideatend-triggered", 0)), c != -1 && c > f && (o.currentTime = c)
}(a));
else {
o.play();
var i = e(a.data("videostartat")),
j = o.currentTime;
1 == a.data("nextslideatend-triggered") && (j = -1, a.data("nextslideatend-triggered", 0)), i != -1 && i > j && (o.currentTime = i)
}
}
},
isVideoPlaying: function(a, b) {
var c = !1;
return void 0 != b.playingvideos && jQuery.each(b.playingvideos, function(b, d) {
a.attr("id") == d.attr("id") && (c = !0)
}), c
},
removeMediaFromList: function(a, b) {
m(a, b)
},
prepareCoveredVideo: function(a, c, d) {
var e = d.find("iframe, video"),
f = a.split(":")[0],
g = a.split(":")[1],
h = d.closest(".tp-revslider-slidesli"),
i = h.width() / h.height(),
j = f / g,
k = i / j * 100,
l = j / i * 100;
i > j ? punchgs.TweenLite.to(e, .001, {
height: k + "%",
width: "100%",
top: -(k - 100) / 2 + "%",
left: "0px",
position: "absolute"
}) : punchgs.TweenLite.to(e, .001, {
width: l + "%",
height: "100%",
left: -(l - 100) / 2 + "%",
top: "0px",
position: "absolute"
}), e.hasClass("resizelistener") || (e.addClass("resizelistener"), jQuery(window).resize(function() {
clearTimeout(e.data("resizelistener")), e.data("resizelistener", setTimeout(function() {
b.prepareCoveredVideo(a, c, d)
}, 30))
}))
},
checkVideoApis: function(a, b, c) {
"https:" === location.protocol ? "https" : "http";
if ((void 0 != a.data("ytid") || a.find("iframe").length > 0 && a.find("iframe").attr("src").toLowerCase().indexOf("youtube") > 0) && (b.youtubeapineeded = !0), (void 0 != a.data("ytid") || a.find("iframe").length > 0 && a.find("iframe").attr("src").toLowerCase().indexOf("youtube") > 0) && 0 == c.addedyt) {
b.youtubestarttime = jQuery.now(), c.addedyt = 1;
var e = document.createElement("script");
e.src = "https://www.youtube.com/iframe_api";
var f = document.getElementsByTagName("script")[0],
g = !0;
jQuery("head").find("*").each(function() {
"https://www.youtube.com/iframe_api" == jQuery(this).attr("src") && (g = !1)
}), g && f.parentNode.insertBefore(e, f)
}
if ((void 0 != a.data("vimeoid") || a.find("iframe").length > 0 && a.find("iframe").attr("src").toLowerCase().indexOf("vimeo") > 0) && (b.vimeoapineeded = !0), (void 0 != a.data("vimeoid") || a.find("iframe").length > 0 && a.find("iframe").attr("src").toLowerCase().indexOf("vimeo") > 0) && 0 == c.addedvim) {
b.vimeostarttime = jQuery.now(), c.addedvim = 1;
var h = document.createElement("script"),
f = document.getElementsByTagName("script")[0],
g = !0;
h.src = "../secure-a.vimeocdn.com/js/froogaloop2.min.html", jQuery("head").find("*").each(function() {
"https://secure-a.vimeocdn.com/js/froogaloop2.min.js" == jQuery(this).attr("src") && (g = !1)
}), g && f.parentNode.insertBefore(h, f)
}
return c
},
manageVideoLayer: function(a, g, i, j) {
if ("stop" === b.compare_version(d).check) return !1;
var l = a.data(),
m = l.videoattributes,
n = l.ytid,
o = l.vimeoid,
p = "auto" === l.videopreload || "canplay" === l.videopreload || "canplaythrough" === l.videopreload || "progress" === l.videopreload ? "auto" : l.videopreload,
q = l.videomp4,
r = l.videowebm,
s = l.videoogv,
t = l.allowfullscreenvideo,
u = l.videocontrols,
v = "http",
w = "loop" == l.videoloop ? "loop" : "loopandnoslidestop" == l.videoloop ? "loop" : "",
x = void 0 != q || void 0 != r ? "html5" : void 0 != n && String(n).length > 1 ? "youtube" : void 0 != o && String(o).length > 1 ? "vimeo" : "none",
y = "html5" == l.audio ? "audio" : "video",
z = "html5" == x && 0 == a.find(y).length ? "html5" : "youtube" == x && 0 == a.find("iframe").length ? "youtube" : "vimeo" == x && 0 == a.find("iframe").length ? "vimeo" : "none";
switch (w = l.nextslideatend === !0 ? "" : w, l.videotype = x, z) {
case "html5":
"controls" != u && (u = "");
var y = "video";
"html5" == l.audio && (y = "audio", a.addClass("tp-audio-html5"));
var A = "<" + y + ' style="object-fit:cover;background-size:cover;visible:hidden;width:100%; height:100%" class="" ' + w + ' preload="' + p + '">';
"auto" == p && (g.mediapreload = !0), void 0 != r && "firefox" == b.get_browser().toLowerCase() && (A = A + '