mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-06 03:50:04 +02:00
This commit is contained in:
parent
717da90159
commit
286c9f77c2
1 changed files with 103 additions and 52 deletions
|
@ -123,7 +123,7 @@ function clean_name(str) {
|
||||||
return str.replace(/[!#$&'()*+,/:;=?@[\] ]+/g, "-");
|
return str.replace(/[!#$&'()*+,/:;=?@[\] ]+/g, "-");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function lazyImage() {
|
||||||
try {
|
try {
|
||||||
if ($(".thumbsJPG").length) {
|
if ($(".thumbsJPG").length) {
|
||||||
$('.thumbsJPG').lazy({
|
$('.thumbsJPG').lazy({
|
||||||
|
@ -132,11 +132,19 @@ try {
|
||||||
// called after an element was successfully handled
|
// called after an element was successfully handled
|
||||||
afterLoad: function (element) {
|
afterLoad: function (element) {
|
||||||
element.removeClass('blur');
|
element.removeClass('blur');
|
||||||
|
element.parent().find('.thumbsGIF').lazy({
|
||||||
|
effect: 'fadeIn'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
mouseEffect();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lazyImage();
|
||||||
|
|
||||||
var pleaseWaitIsINUse = false;
|
var pleaseWaitIsINUse = false;
|
||||||
|
|
||||||
function setPlayerListners() {
|
function setPlayerListners() {
|
||||||
|
@ -152,6 +160,13 @@ function setPlayerListners() {
|
||||||
console.log("setPlayerListners: play");
|
console.log("setPlayerListners: play");
|
||||||
//userIsControling = true;
|
//userIsControling = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#mainVideo .vjs-mute-control").click(function(){
|
||||||
|
Cookies.set('muted', player.muted(), {
|
||||||
|
path: '/',
|
||||||
|
expires: 365
|
||||||
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
setPlayerListners();
|
setPlayerListners();
|
||||||
|
@ -396,7 +411,6 @@ function playerPlay(currentTime) {
|
||||||
}
|
}
|
||||||
promisePlaytry--;
|
promisePlaytry--;
|
||||||
if (typeof player !== 'undefined') {
|
if (typeof player !== 'undefined') {
|
||||||
promisePlayTimeoutTime += 1000;
|
|
||||||
if (currentTime) {
|
if (currentTime) {
|
||||||
player.currentTime(currentTime);
|
player.currentTime(currentTime);
|
||||||
}
|
}
|
||||||
|
@ -404,10 +418,7 @@ function playerPlay(currentTime) {
|
||||||
console.log("playerPlay: Trying to play");
|
console.log("playerPlay: Trying to play");
|
||||||
promisePlay = player.play();
|
promisePlay = player.play();
|
||||||
if (promisePlay !== undefined) {
|
if (promisePlay !== undefined) {
|
||||||
promisePlayTimeout = setTimeout(function () {
|
tryToPlay(currentTime);
|
||||||
console.log("playerPlay: Promise is Pending, try again");
|
|
||||||
playerPlay(currentTime);
|
|
||||||
}, promisePlayTimeoutTime);
|
|
||||||
console.log("playerPlay: promise found");
|
console.log("playerPlay: promise found");
|
||||||
promisePlay.then(function () {
|
promisePlay.then(function () {
|
||||||
console.log("playerPlay: Autoplay started");
|
console.log("playerPlay: Autoplay started");
|
||||||
|
@ -416,8 +427,7 @@ function playerPlay(currentTime) {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if (player.paused()) {
|
if (player.paused()) {
|
||||||
console.log("The video still paused, trying to mute and play");
|
console.log("The video still paused, trying to mute and play");
|
||||||
player.muted(true);
|
playMuted(currentTime);
|
||||||
playerPlay(currentTime);
|
|
||||||
} else {
|
} else {
|
||||||
//player.muted(false);
|
//player.muted(false);
|
||||||
if (player.muted() && !inIframe()) {
|
if (player.muted() && !inIframe()) {
|
||||||
|
@ -464,28 +474,53 @@ function playerPlay(currentTime) {
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
console.log("playerPlay: Autoplay was prevented, trying to mute and play ***");
|
console.log("playerPlay: Autoplay was prevented, trying to mute and play ***");
|
||||||
player.muted(true);
|
playMuted(currentTime);
|
||||||
playerPlay(currentTime);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
promisePlayTimeout = setTimeout(function () {
|
tryToPlay(currentTime);
|
||||||
if (player.paused()) {
|
|
||||||
console.log("playerPlay: promise Undefined");
|
|
||||||
playerPlay(currentTime);
|
|
||||||
}
|
|
||||||
}, promisePlayTimeoutTime);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("playerPlay: We could not autoplay, trying again in 1 second");
|
console.log("playerPlay: We could not autoplay, trying again in 1 second");
|
||||||
promisePlayTimeout = setTimeout(function () {
|
tryToPlay(currentTime);
|
||||||
playerPlay(currentTime);
|
|
||||||
}, promisePlayTimeoutTime);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log("playerPlay: Player is Undefined");
|
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() {
|
function showMuteTooltip() {
|
||||||
if ($("#mainVideo .vjs-volume-panel").length) {
|
if ($("#mainVideo .vjs-volume-panel").length) {
|
||||||
if (!$("#mainVideo .vjs-volume-panel").is(":visible")) {
|
if (!$("#mainVideo .vjs-volume-panel").is(":visible")) {
|
||||||
|
@ -879,16 +914,8 @@ $(document).ready(function () {
|
||||||
$(".thumbsImage").on("mouseleave", function () {
|
$(".thumbsImage").on("mouseleave", function () {
|
||||||
$(this).find(".thumbsGIF").stop(true, true).fadeOut();
|
$(this).find(".thumbsGIF").stop(true, true).fadeOut();
|
||||||
});
|
});
|
||||||
if ($(".thumbsJPG").length) {
|
|
||||||
$('.thumbsJPG').lazy({
|
lazyImage();
|
||||||
effect: 'fadeIn',
|
|
||||||
visibleOnly: true,
|
|
||||||
// called after an element was successfully handled
|
|
||||||
afterLoad: function (element) {
|
|
||||||
element.removeClass('blur');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$("a").each(function () {
|
$("a").each(function () {
|
||||||
var location = window.location.toString()
|
var location = window.location.toString()
|
||||||
|
@ -964,3 +991,27 @@ function validURL(str) {
|
||||||
'(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
|
'(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
|
||||||
return !!pattern.test(str);
|
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);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue