1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 19:42:38 +02:00
DanielnetoDotCom 2020-11-09 10:18:22 -03:00
parent 717da90159
commit 286c9f77c2

View file

@ -123,7 +123,7 @@ function clean_name(str) {
return str.replace(/[!#$&'()*+,/:;=?@[\] ]+/g, "-");
}
function lazyImage() {
try {
if ($(".thumbsJPG").length) {
$('.thumbsJPG').lazy({
@ -132,11 +132,19 @@ try {
// called after an element was successfully handled
afterLoad: function (element) {
element.removeClass('blur');
element.parent().find('.thumbsGIF').lazy({
effect: 'fadeIn'
});
}
});
mouseEffect();
}
} catch (e) {
}
}
lazyImage();
var pleaseWaitIsINUse = false;
function setPlayerListners() {
@ -152,6 +160,13 @@ function setPlayerListners() {
console.log("setPlayerListners: play");
//userIsControling = true;
});
$("#mainVideo .vjs-mute-control").click(function(){
Cookies.set('muted', player.muted(), {
path: '/',
expires: 365
});
});
} else {
setTimeout(function () {
setPlayerListners();
@ -396,7 +411,6 @@ function playerPlay(currentTime) {
}
promisePlaytry--;
if (typeof player !== 'undefined') {
promisePlayTimeoutTime += 1000;
if (currentTime) {
player.currentTime(currentTime);
}
@ -404,10 +418,7 @@ function playerPlay(currentTime) {
console.log("playerPlay: Trying to play");
promisePlay = player.play();
if (promisePlay !== undefined) {
promisePlayTimeout = setTimeout(function () {
console.log("playerPlay: Promise is Pending, try again");
playerPlay(currentTime);
}, promisePlayTimeoutTime);
tryToPlay(currentTime);
console.log("playerPlay: promise found");
promisePlay.then(function () {
console.log("playerPlay: Autoplay started");
@ -416,8 +427,7 @@ function playerPlay(currentTime) {
setTimeout(function () {
if (player.paused()) {
console.log("The video still paused, trying to mute and play");
player.muted(true);
playerPlay(currentTime);
playMuted(currentTime);
} else {
//player.muted(false);
if (player.muted() && !inIframe()) {
@ -464,28 +474,53 @@ function playerPlay(currentTime) {
}, 1000);
}).catch(function (error) {
console.log("playerPlay: Autoplay was prevented, trying to mute and play ***");
player.muted(true);
playerPlay(currentTime);
playMuted(currentTime);
});
} else {
promisePlayTimeout = setTimeout(function () {
if (player.paused()) {
console.log("playerPlay: promise Undefined");
playerPlay(currentTime);
}
}, promisePlayTimeoutTime);
tryToPlay(currentTime);
}
} catch (e) {
console.log("playerPlay: We could not autoplay, trying again in 1 second");
promisePlayTimeout = setTimeout(function () {
playerPlay(currentTime);
}, promisePlayTimeoutTime);
tryToPlay(currentTime);
}
} else {
console.log("playerPlay: Player is Undefined");
}
}
function tryToPlay(currentTime){
clearTimeout(promisePlayTimeout);
promisePlayTimeoutTime += 200;
if(promisePlayTimeoutTime>1000){
$.toast("Your browser prevent autoplay");
return false;
}
promisePlayTimeout = setTimeout(function () {
if (player.paused()) {
playerPlay(currentTime);
}
}, promisePlayTimeoutTime);
}
function muteIfNotAudio(){
if(!player.isAudio()){
player.muted(true);
return true;
}
return false;
}
function playMuted(currentTime){
var mute = Cookies.get('muted');
if(typeof mute === 'undefined' || mute){
if(muteIfNotAudio()){
playerPlay(currentTime);
return true;
}
}
return false;
}
function showMuteTooltip() {
if ($("#mainVideo .vjs-volume-panel").length) {
if (!$("#mainVideo .vjs-volume-panel").is(":visible")) {
@ -879,16 +914,8 @@ $(document).ready(function () {
$(".thumbsImage").on("mouseleave", function () {
$(this).find(".thumbsGIF").stop(true, true).fadeOut();
});
if ($(".thumbsJPG").length) {
$('.thumbsJPG').lazy({
effect: 'fadeIn',
visibleOnly: true,
// called after an element was successfully handled
afterLoad: function (element) {
element.removeClass('blur');
}
});
}
lazyImage();
$("a").each(function () {
var location = window.location.toString()
@ -964,3 +991,27 @@ function validURL(str) {
'(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
return !!pattern.test(str);
}
function startTimer(duration, selector) {
var timer = duration;
var startTimerInterval = setInterval(function () {
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(duration / (60 * 60 * 24));
var hours = Math.floor((duration % (60 * 60 * 24)) / (60 * 60));
var minutes = Math.floor((duration % (60 * 60)) / (60));
var seconds = Math.floor((duration % (60)));
// Display the result in the element with id="demo"
var text = days + "d " + hours + "h "
+ minutes + "m " + seconds + "s ";
$(selector).text(text);
duration--;
// If the count down is finished, write some text
if (duration < 0) {
clearInterval(startTimerInterval);
$(selector).text("EXPIRED");
}
}, 1000);
}