mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-12-08 20:48:48 +00:00
Added gulp, and started using the file being built by gulp. Fixed some issues with remote control changing. Implemented clients being able to change password
This commit is contained in:
@@ -1,264 +1,193 @@
|
||||
function initYoutubeControls(player)
|
||||
{
|
||||
fitToScreen();
|
||||
setInterval(durationSetter, 1000);
|
||||
initControls();
|
||||
$(window).resize(function(){
|
||||
fitToScreen();
|
||||
});
|
||||
}
|
||||
var Playercontrols = {
|
||||
|
||||
function initControls()
|
||||
{
|
||||
document.getElementById("volume-button").addEventListener("click", mute_video);
|
||||
document.getElementById("playpause").addEventListener("click", play_pause);
|
||||
document.getElementById("fullscreen").addEventListener("click", fullscreen);
|
||||
}
|
||||
initYoutubeControls: function(player)
|
||||
{
|
||||
setInterval(Playercontrols.durationSetter, 1000);
|
||||
Playercontrols.initControls();
|
||||
},
|
||||
|
||||
function fitToScreen()
|
||||
{
|
||||
if(peis)
|
||||
player_name = "#jplayer";
|
||||
else
|
||||
player_name = "#player";
|
||||
}
|
||||
initControls: function()
|
||||
{
|
||||
document.getElementById("volume-button").addEventListener("click", Playercontrols.mute_video);
|
||||
document.getElementById("playpause").addEventListener("click", Playercontrols.play_pause);
|
||||
document.getElementById("fullscreen").addEventListener("click", Playercontrols.fullscreen);
|
||||
},
|
||||
|
||||
function initSlider()
|
||||
{
|
||||
if(localStorage.volume)
|
||||
{
|
||||
vol = localStorage.getItem("volume");
|
||||
}else{
|
||||
vol = 100;
|
||||
localStorage.setItem("volume", vol);
|
||||
}
|
||||
$("#volume").slider({
|
||||
min: 0,
|
||||
max: 100,
|
||||
value: vol,
|
||||
range: "min",
|
||||
animate: true,
|
||||
slide: function(event, ui) {
|
||||
setVolume(ui.value);
|
||||
localStorage.setItem("volume", ui.value);
|
||||
}
|
||||
});
|
||||
choose_button(vol, false);
|
||||
//$("#volume").slider("value", ytplayer.getVolume());
|
||||
}
|
||||
initSlider: function()
|
||||
{
|
||||
if(localStorage.volume)
|
||||
{
|
||||
vol = localStorage.getItem("volume");
|
||||
}else{
|
||||
vol = 100;
|
||||
localStorage.setItem("volume", vol);
|
||||
}
|
||||
$("#volume").slider({
|
||||
min: 0,
|
||||
max: 100,
|
||||
value: vol,
|
||||
range: "min",
|
||||
animate: true,
|
||||
slide: function(event, ui) {
|
||||
Playercontrols.setVolume(ui.value);
|
||||
localStorage.setItem("volume", ui.value);
|
||||
}
|
||||
});
|
||||
Playercontrols.choose_button(vol, false);
|
||||
//$("#volume").slider("value", ytplayer.getVolume());
|
||||
},
|
||||
|
||||
function fullscreen()
|
||||
{
|
||||
var playerElement = document.getElementById("player");
|
||||
var requestFullScreen = playerElement.requestFullScreen || playerElement.mozRequestFullScreen || playerElement.webkitRequestFullScreen;
|
||||
if (requestFullScreen) {
|
||||
requestFullScreen.bind(playerElement)();
|
||||
}
|
||||
}
|
||||
fullscreen: function()
|
||||
{
|
||||
var playerElement = document.getElementById("player");
|
||||
var requestFullScreen = playerElement.requestFullScreen || playerElement.mozRequestFullScreen || playerElement.webkitRequestFullScreen;
|
||||
if (requestFullScreen) {
|
||||
requestFullScreen.bind(playerElement)();
|
||||
}
|
||||
},
|
||||
|
||||
function play_pause()
|
||||
{
|
||||
if(ytplayer.getPlayerState() == 1)
|
||||
{
|
||||
ytplayer.pauseVideo();
|
||||
}else if(ytplayer.getPlayerState() == 2 || ytplayer.getPlayerState() == 0)
|
||||
{
|
||||
ytplayer.playVideo();
|
||||
}
|
||||
}
|
||||
play_pause: function()
|
||||
{
|
||||
if(ytplayer.getPlayerState() == 1)
|
||||
{
|
||||
ytplayer.pauseVideo();
|
||||
}else if(ytplayer.getPlayerState() == 2 || ytplayer.getPlayerState() == 0)
|
||||
{
|
||||
ytplayer.playVideo();
|
||||
}
|
||||
},
|
||||
|
||||
function settings()
|
||||
{
|
||||
$("#qS").toggleClass("hide");
|
||||
}
|
||||
settings: function()
|
||||
{
|
||||
$("#qS").toggleClass("hide");
|
||||
},
|
||||
|
||||
function changeQuality(wantedQ)
|
||||
{
|
||||
//wantedQ = this.getAttribute("name");
|
||||
//console.log("Change quality");
|
||||
//console.log(wantedQ);
|
||||
if(ytplayer.getPlaybackQuality != wantedQ)
|
||||
{
|
||||
ytplayer.setPlaybackQuality(wantedQ);
|
||||
ytplayer.getPlaybackQuality();
|
||||
}
|
||||
$("#qS").toggleClass("hide");
|
||||
}
|
||||
changeQuality: function(wantedQ)
|
||||
{
|
||||
if(ytplayer.getPlaybackQuality != wantedQ)
|
||||
{
|
||||
ytplayer.setPlaybackQuality(wantedQ);
|
||||
ytplayer.getPlaybackQuality();
|
||||
}
|
||||
$("#qS").toggleClass("hide");
|
||||
},
|
||||
|
||||
function mute_video()
|
||||
{
|
||||
if(!ytplayer.isMuted())
|
||||
{
|
||||
choose_button(0, true);
|
||||
ytplayer.mute();
|
||||
}else
|
||||
{
|
||||
ytplayer.unMute();
|
||||
choose_button(ytplayer.getVolume(), false);
|
||||
}
|
||||
}
|
||||
mute_video: function()
|
||||
{
|
||||
if(!ytplayer.isMuted())
|
||||
{
|
||||
Playercontrols.choose_button(0, true);
|
||||
ytplayer.mute();
|
||||
}else
|
||||
{
|
||||
ytplayer.unMute();
|
||||
Playercontrols.choose_button(ytplayer.getVolume(), false);
|
||||
}
|
||||
},
|
||||
|
||||
function setVolume(vol)
|
||||
{
|
||||
ytplayer.setVolume(vol);
|
||||
choose_button(vol, false);
|
||||
//console.log(vol); //NO LOGS FOR U LOL
|
||||
if(ytplayer.isMuted())
|
||||
ytplayer.unMute();
|
||||
/*if(vol == 0){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -403px");
|
||||
}else if(vol < 33){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1457px");
|
||||
}else if(vol > 33 && vol < 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -806px");
|
||||
}else if(vol > 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1829px");
|
||||
}*/
|
||||
}
|
||||
setVolume: function(vol)
|
||||
{
|
||||
ytplayer.setVolume(vol);
|
||||
Playercontrols.choose_button(vol, false);
|
||||
if(ytplayer.isMuted())
|
||||
ytplayer.unMute();
|
||||
},
|
||||
|
||||
function choose_button(vol, mute)
|
||||
{
|
||||
if(!mute){
|
||||
if(vol >= 0 && vol <= 33){
|
||||
if(document.getElementById("v-full").className.split(" ").length == 1)
|
||||
$("#v-full").toggleClass("hide");
|
||||
if(document.getElementById("v-medium").className.split(" ").length == 1)
|
||||
$("#v-medium").toggleClass("hide");
|
||||
if(document.getElementById("v-low").className.split(" ").length == 2)
|
||||
$("#v-low").toggleClass("hide");
|
||||
if(document.getElementById("v-mute").className.split(" ").length == 1)
|
||||
$("#v-mute").toggleClass("hide");
|
||||
}else if(vol >= 34 && vol <= 66){
|
||||
if(document.getElementById("v-full").className.split(" ").length == 1)
|
||||
$("#v-full").toggleClass("hide");
|
||||
if(document.getElementById("v-medium").className.split(" ").length == 2)
|
||||
$("#v-medium").toggleClass("hide");
|
||||
if(document.getElementById("v-low").className.split(" ").length == 1)
|
||||
$("#v-low").toggleClass("hide");
|
||||
if(document.getElementById("v-mute").className.split(" ").length == 1)
|
||||
$("#v-mute").toggleClass("hide");
|
||||
}else if(vol >= 67 && vol <= 100){
|
||||
if(document.getElementById("v-full").className.split(" ").length == 2)
|
||||
$("#v-full").toggleClass("hide");
|
||||
if(document.getElementById("v-medium").className.split(" ").length == 1)
|
||||
$("#v-medium").toggleClass("hide");
|
||||
if(document.getElementById("v-low").className.split(" ").length == 1)
|
||||
$("#v-low").toggleClass("hide");
|
||||
if(document.getElementById("v-mute").className.split(" ").length == 1)
|
||||
$("#v-mute").toggleClass("hide");
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(document.getElementById("v-full").className.split(" ").length == 1)
|
||||
$("#v-full").toggleClass("hide");
|
||||
if(document.getElementById("v-medium").className.split(" ").length == 1)
|
||||
$("#v-medium").toggleClass("hide");
|
||||
if(document.getElementById("v-low").className.split(" ").length == 1)
|
||||
$("#v-low").toggleClass("hide");
|
||||
if(document.getElementById("v-mute").className.split(" ").length == 2)
|
||||
$("#v-mute").toggleClass("hide");
|
||||
}
|
||||
}
|
||||
choose_button: function(vol, mute)
|
||||
{
|
||||
if(!mute){
|
||||
if(vol >= 0 && vol <= 33){
|
||||
if(document.getElementById("v-full").className.split(" ").length == 1)
|
||||
$("#v-full").toggleClass("hide");
|
||||
if(document.getElementById("v-medium").className.split(" ").length == 1)
|
||||
$("#v-medium").toggleClass("hide");
|
||||
if(document.getElementById("v-low").className.split(" ").length == 2)
|
||||
$("#v-low").toggleClass("hide");
|
||||
if(document.getElementById("v-mute").className.split(" ").length == 1)
|
||||
$("#v-mute").toggleClass("hide");
|
||||
}else if(vol >= 34 && vol <= 66){
|
||||
if(document.getElementById("v-full").className.split(" ").length == 1)
|
||||
$("#v-full").toggleClass("hide");
|
||||
if(document.getElementById("v-medium").className.split(" ").length == 2)
|
||||
$("#v-medium").toggleClass("hide");
|
||||
if(document.getElementById("v-low").className.split(" ").length == 1)
|
||||
$("#v-low").toggleClass("hide");
|
||||
if(document.getElementById("v-mute").className.split(" ").length == 1)
|
||||
$("#v-mute").toggleClass("hide");
|
||||
}else if(vol >= 67 && vol <= 100){
|
||||
if(document.getElementById("v-full").className.split(" ").length == 2)
|
||||
$("#v-full").toggleClass("hide");
|
||||
if(document.getElementById("v-medium").className.split(" ").length == 1)
|
||||
$("#v-medium").toggleClass("hide");
|
||||
if(document.getElementById("v-low").className.split(" ").length == 1)
|
||||
$("#v-low").toggleClass("hide");
|
||||
if(document.getElementById("v-mute").className.split(" ").length == 1)
|
||||
$("#v-mute").toggleClass("hide");
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(document.getElementById("v-full").className.split(" ").length == 1)
|
||||
$("#v-full").toggleClass("hide");
|
||||
if(document.getElementById("v-medium").className.split(" ").length == 1)
|
||||
$("#v-medium").toggleClass("hide");
|
||||
if(document.getElementById("v-low").className.split(" ").length == 1)
|
||||
$("#v-low").toggleClass("hide");
|
||||
if(document.getElementById("v-mute").className.split(" ").length == 2)
|
||||
$("#v-mute").toggleClass("hide");
|
||||
}
|
||||
},
|
||||
|
||||
function playPause()
|
||||
{
|
||||
console.log("playPause");
|
||||
state = ytplayer.getPlayerState();
|
||||
console.log("state: "+state);
|
||||
button = document.getElementById("playpause");
|
||||
if(state == 1)
|
||||
{
|
||||
ytplayer.pauseVideo();
|
||||
//button.innerHTML = "Resume";
|
||||
}else if(state == 2)
|
||||
{
|
||||
ytplayer.playVideo();
|
||||
//button.innerHTML = "Pause";
|
||||
}
|
||||
}
|
||||
playPause: function()
|
||||
{
|
||||
state = ytplayer.getPlayerState();
|
||||
button = document.getElementById("playpause");
|
||||
if(state == 1)
|
||||
{
|
||||
ytplayer.pauseVideo();
|
||||
}else if(state == 2)
|
||||
{
|
||||
ytplayer.playVideo();
|
||||
}
|
||||
},
|
||||
|
||||
function durationSetter()
|
||||
{
|
||||
duration = ytplayer.getDuration();
|
||||
dMinutes = Math.floor(duration / 60);
|
||||
dSeconds = duration - dMinutes * 60;
|
||||
currDurr = ytplayer.getCurrentTime();
|
||||
if(currDurr > duration)
|
||||
currDurr = duration;
|
||||
minutes = Math.floor(currDurr / 60);
|
||||
seconds = currDurr - minutes * 60;
|
||||
document.getElementById("duration").innerHTML = pad(minutes)+":"+pad(seconds)+" <span id='dash'>/</span> "+pad(dMinutes)+":"+pad(dSeconds);
|
||||
per = (100 / duration) * currDurr;
|
||||
if(per >= 100)
|
||||
per = 100;
|
||||
else if(duration == 0)
|
||||
per = 0;
|
||||
$("#bar").width(per+"%");
|
||||
}
|
||||
durationSetter: function()
|
||||
{
|
||||
duration = ytplayer.getDuration();
|
||||
dMinutes = Math.floor(duration / 60);
|
||||
dSeconds = duration - dMinutes * 60;
|
||||
currDurr = ytplayer.getCurrentTime();
|
||||
if(currDurr > duration)
|
||||
currDurr = duration;
|
||||
minutes = Math.floor(currDurr / 60);
|
||||
seconds = currDurr - minutes * 60;
|
||||
document.getElementById("duration").innerHTML = Helper.pad(minutes)+":"+Helper.pad(seconds)+" <span id='dash'>/</span> "+Helper.pad(dMinutes)+":"+Helper.pad(dSeconds);
|
||||
per = (100 / duration) * currDurr;
|
||||
if(per >= 100)
|
||||
per = 100;
|
||||
else if(duration == 0)
|
||||
per = 0;
|
||||
$("#bar").width(per+"%");
|
||||
},
|
||||
|
||||
function pad(n)
|
||||
{
|
||||
return n < 10 ? "0"+Math.floor(n) : Math.floor(n);
|
||||
}
|
||||
volumeOptions: function()
|
||||
{
|
||||
if(ytplayer.isMuted())
|
||||
{
|
||||
ytplayer.unMute();
|
||||
vol = ytplayer.getVolume();
|
||||
$("#volume").slider("value", ytplayer.getVolume());
|
||||
}
|
||||
else
|
||||
{
|
||||
ytplayer.mute();
|
||||
$("#volume").slider("value", 0);
|
||||
}
|
||||
},
|
||||
|
||||
function volumeOptions()
|
||||
{
|
||||
//console.log("volumeOptions");
|
||||
//button = document.getElementById("volume");
|
||||
if(ytplayer.isMuted())
|
||||
{
|
||||
ytplayer.unMute();
|
||||
vol = ytplayer.getVolume();
|
||||
$("#volume").slider("value", ytplayer.getVolume());
|
||||
/*if(vol == 0){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -93px");
|
||||
}else if(vol < 33){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1395px");
|
||||
}else if(vol > 33 && vol < 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1767px");
|
||||
}else if(vol > 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -2604px");
|
||||
}*/
|
||||
}
|
||||
else
|
||||
{
|
||||
ytplayer.mute();
|
||||
$("#volume").slider("value", 0);
|
||||
//$("#mute").css("background","no-repeat url(static/player.webp) -0px -93px");
|
||||
}
|
||||
}
|
||||
hoverMute: function(foo)
|
||||
{
|
||||
vol = ytplayer.getVolume();
|
||||
|
||||
function hoverMute(foo)
|
||||
{
|
||||
vol = ytplayer.getVolume();
|
||||
console.log(vol);
|
||||
/*if(foo)
|
||||
{
|
||||
if(vol == 0 || ytplayer.isMuted()){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -93px");
|
||||
}else if(vol < 33){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1395px");
|
||||
}else if(vol > 33 && vol < 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1767px");
|
||||
}else if(vol > 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -2604px");
|
||||
}
|
||||
}else
|
||||
{
|
||||
if(vol == 0 || ytplayer.isMuted()){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -403px");
|
||||
}else if(vol < 33){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1457px");
|
||||
}else if(vol > 33 && vol < 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -806px");
|
||||
}else if(vol > 66){
|
||||
$("#mute").css("background","no-repeat url(static/player.webp) -0px -1829px");
|
||||
}
|
||||
}*/
|
||||
}
|
||||
//url(http://localhost/Kasperrt/static/player.webp) 0px -94px no-repeat
|
||||
}
|
||||
|
||||
function logQ()
|
||||
{
|
||||
console.log(ytplayer.getPlaybackQuality());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user