mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Fixed duration setter
This commit is contained in:
4
static/dist/main.min.js
vendored
4
static/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -223,7 +223,7 @@ $('input[class=conf]').change(function()
|
||||
});
|
||||
|
||||
$("#clickme").click(function(){
|
||||
ytplayer.playVideo();
|
||||
Youtube.ytplayer.playVideo();
|
||||
});
|
||||
|
||||
$('#listImport').on("submit", function(){
|
||||
@@ -365,13 +365,15 @@ function onepage_load(){
|
||||
$("#channel-load").css("display", "block");
|
||||
window.scrollTo(0, 0);
|
||||
|
||||
Playercontrols.stopInterval = true;
|
||||
|
||||
|
||||
var url_split = window.location.href.split("/");
|
||||
if(url_split[3] == "" || url_split[3].substring(0,1) == "#"){
|
||||
$.ajax({
|
||||
url: "php/nochan_content.php",
|
||||
success: function(e){
|
||||
ytplayer.destroy();
|
||||
Playercontrols.clearDurationInterval();
|
||||
Youtube.ytplayer.destroy();
|
||||
|
||||
socket.disconnect();
|
||||
|
||||
@@ -379,7 +381,6 @@ function onepage_load(){
|
||||
document.getElementById("playpause").removeEventListener("click", Playercontrols.play_pause);
|
||||
document.getElementById("fullscreen").removeEventListener("click", Playercontrols.fullscreen);
|
||||
|
||||
delete ytplayer
|
||||
delete Admin
|
||||
delete Chat
|
||||
delete Crypt
|
||||
@@ -421,7 +422,7 @@ function onepage_load(){
|
||||
delete blink_interval;
|
||||
delete tag;
|
||||
delete firstScriptTag;
|
||||
delete ytplayer;
|
||||
delete Youtube.ytplayer;
|
||||
delete title;
|
||||
delete viewers;
|
||||
delete video_id;
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
var Playercontrols = {
|
||||
|
||||
interval: null,
|
||||
stopInterval: false,
|
||||
|
||||
initYoutubeControls: function(player)
|
||||
{
|
||||
if(window.mobilecheck() && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream){
|
||||
$("#controls").appendTo("#playbar");
|
||||
}
|
||||
Playercontrols.interval = setInterval(Playercontrols.durationSetter, 1000);
|
||||
Playercontrols.initControls();
|
||||
Playercontrols.durationSetter();
|
||||
},
|
||||
|
||||
initControls: function()
|
||||
@@ -19,11 +18,6 @@ var Playercontrols = {
|
||||
|
||||
},
|
||||
|
||||
clearDurationInterval: function()
|
||||
{
|
||||
clearInterval(Playercontrols.interval);
|
||||
},
|
||||
|
||||
initSlider: function()
|
||||
{
|
||||
vol = (Crypt.get_volume());
|
||||
@@ -55,14 +49,14 @@ var Playercontrols = {
|
||||
|
||||
play_pause: function()
|
||||
{
|
||||
if(ytplayer.getPlayerState() == 1)
|
||||
if(Youtube.ytplayer.getPlayerState() == 1)
|
||||
{
|
||||
ytplayer.pauseVideo();
|
||||
Youtube.ytplayer.pauseVideo();
|
||||
if(window.mobilecheck() && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream)
|
||||
document.getElementById("player").style.display = "none";
|
||||
}else if(ytplayer.getPlayerState() == 2 || ytplayer.getPlayerState() == 0)
|
||||
}else if(Youtube.ytplayer.getPlayerState() == 2 || Youtube.ytplayer.getPlayerState() == 0)
|
||||
{
|
||||
ytplayer.playVideo();
|
||||
Youtube.ytplayer.playVideo();
|
||||
if(window.mobilecheck() && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream)
|
||||
document.getElementById("player").style.display = "block";
|
||||
}
|
||||
@@ -75,33 +69,33 @@ var Playercontrols = {
|
||||
|
||||
changeQuality: function(wantedQ)
|
||||
{
|
||||
if(ytplayer.getPlaybackQuality != wantedQ)
|
||||
if(Youtube.ytplayer.getPlaybackQuality != wantedQ)
|
||||
{
|
||||
ytplayer.setPlaybackQuality(wantedQ);
|
||||
ytplayer.getPlaybackQuality();
|
||||
Youtube.ytplayer.setPlaybackQuality(wantedQ);
|
||||
Youtube.ytplayer.getPlaybackQuality();
|
||||
}
|
||||
$("#qS").toggleClass("hide");
|
||||
},
|
||||
|
||||
mute_video: function()
|
||||
{
|
||||
if(!ytplayer.isMuted())
|
||||
if(!Youtube.ytplayer.isMuted())
|
||||
{
|
||||
Playercontrols.choose_button(0, true);
|
||||
ytplayer.mute();
|
||||
Youtube.ytplayer.mute();
|
||||
}else
|
||||
{
|
||||
ytplayer.unMute();
|
||||
Playercontrols.choose_button(ytplayer.getVolume(), false);
|
||||
Youtube.ytplayer.unMute();
|
||||
Playercontrols.choose_button(Youtube.ytplayer.getVolume(), false);
|
||||
}
|
||||
},
|
||||
|
||||
setVolume: function(vol)
|
||||
{
|
||||
ytplayer.setVolume(vol);
|
||||
Youtube.ytplayer.setVolume(vol);
|
||||
Playercontrols.choose_button(vol, false);
|
||||
if(ytplayer.isMuted())
|
||||
ytplayer.unMute();
|
||||
if(Youtube.ytplayer.isMuted())
|
||||
Youtube.ytplayer.unMute();
|
||||
},
|
||||
|
||||
choose_button: function(vol, mute)
|
||||
@@ -150,54 +144,57 @@ var Playercontrols = {
|
||||
|
||||
playPause: function()
|
||||
{
|
||||
state = ytplayer.getPlayerState();
|
||||
state = Youtube.ytplayer.getPlayerState();
|
||||
button = document.getElementById("playpause");
|
||||
if(state == 1)
|
||||
{
|
||||
ytplayer.pauseVideo();
|
||||
Youtube.ytplayer.pauseVideo();
|
||||
}else if(state == 2)
|
||||
{
|
||||
ytplayer.playVideo();
|
||||
Youtube.ytplayer.playVideo();
|
||||
}
|
||||
},
|
||||
|
||||
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+"%");
|
||||
duration = Youtube.ytplayer.getDuration();
|
||||
if(duration != undefined){
|
||||
dMinutes = Math.floor(duration / 60);
|
||||
dSeconds = duration - dMinutes * 60;
|
||||
currDurr = Youtube.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+"%");
|
||||
}
|
||||
if(!Playercontrols.stopInterval) setTimeout(Playercontrols.durationSetter, 1000);
|
||||
},
|
||||
|
||||
volumeOptions: function()
|
||||
{
|
||||
if(ytplayer.isMuted())
|
||||
if(Youtube.ytplayer.isMuted())
|
||||
{
|
||||
ytplayer.unMute();
|
||||
vol = ytplayer.getVolume();
|
||||
$("#volume").slider("value", ytplayer.getVolume());
|
||||
Youtube.ytplayer.unMute();
|
||||
vol = Youtube.ytplayer.getVolume();
|
||||
$("#volume").slider("value", Youtube.ytplayer.getVolume());
|
||||
}
|
||||
else
|
||||
{
|
||||
ytplayer.mute();
|
||||
Youtube.ytplayer.mute();
|
||||
$("#volume").slider("value", 0);
|
||||
}
|
||||
},
|
||||
|
||||
hoverMute: function(foo)
|
||||
{
|
||||
vol = ytplayer.getVolume();
|
||||
vol = Youtube.ytplayer.getVolume();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,14 @@ var Youtube = {
|
||||
loaded: true,
|
||||
before_load: "",
|
||||
after_load: "",
|
||||
ytplayer: "",
|
||||
|
||||
setup_youtube_listener: function(channel)
|
||||
{
|
||||
socket.on("np", function(obj)
|
||||
{
|
||||
Youtube.loaded = false;
|
||||
if(video_id != undefined && ytplayer !== undefined) Youtube.before_load = ytplayer.getVideoUrl();
|
||||
if(video_id != undefined && Youtube.ytplayer !== undefined) Youtube.before_load = Youtube.ytplayer.getVideoUrl();
|
||||
if(obj[0].length == 0){
|
||||
|
||||
document.getElementById('song-title').innerHTML = "Empty channel. Add some songs!";
|
||||
@@ -17,7 +18,7 @@ var Youtube = {
|
||||
|
||||
if(!/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) $("#player_overlay").toggleClass("hide");
|
||||
try{
|
||||
ytplayer.stopVideo();
|
||||
Youtube.ytplayer.stopVideo();
|
||||
}catch(e){}
|
||||
//List.importOldList(channel.toLowerCase());
|
||||
}
|
||||
@@ -42,18 +43,18 @@ var Youtube = {
|
||||
//if(player_ready && !window.mobilecheck())
|
||||
if(player_ready && !/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream)
|
||||
{
|
||||
if(ytplayer.getVideoUrl().split('v=')[1] != video_id)
|
||||
if(Youtube.ytplayer.getVideoUrl().split('v=')[1] != video_id)
|
||||
{
|
||||
ytplayer.loadVideoById(video_id);
|
||||
Youtube.ytplayer.loadVideoById(video_id);
|
||||
Youtube.notifyUser(video_id, song_title);
|
||||
ytplayer.seekTo(seekTo);
|
||||
Youtube.ytplayer.seekTo(seekTo);
|
||||
if(paused)
|
||||
ytplayer.pauseVideo();
|
||||
Youtube.ytplayer.pauseVideo();
|
||||
}
|
||||
if(!paused)
|
||||
ytplayer.playVideo();
|
||||
if(ytplayer.getDuration() > seekTo || ytplayer.getDuration() == 0)
|
||||
ytplayer.seekTo(seekTo);
|
||||
Youtube.ytplayer.playVideo();
|
||||
if(Youtube.ytplayer.getDuration() > seekTo || Youtube.ytplayer.getDuration() == 0)
|
||||
Youtube.ytplayer.seekTo(seekTo);
|
||||
Youtube.after_load = video_id;
|
||||
setTimeout(function(){Youtube.loaded = true;},500);
|
||||
}
|
||||
@@ -85,7 +86,7 @@ var Youtube = {
|
||||
case 1:
|
||||
playing = true;
|
||||
if(beginning && window.mobilecheck()){
|
||||
ytplayer.pauseVideo();
|
||||
Youtube.ytplayer.pauseVideo();
|
||||
beginning = false;
|
||||
}
|
||||
if(document.getElementById("play").className.split(" ").length == 1)
|
||||
@@ -135,21 +136,21 @@ var Youtube = {
|
||||
/*console.log("Before: " + Youtube.before_load);
|
||||
console.log("Now: " + video_id);
|
||||
console.log("After: " + Youtube.after_load);
|
||||
console.log(Youtube.before_load == ytplayer.getVideoUrl);*/
|
||||
curr_playing = ytplayer.getVideoUrl().replace("https://www.youtube.com/watch?v=", "");
|
||||
console.log(Youtube.before_load == Youtube.ytplayer.getVideoUrl);*/
|
||||
curr_playing = Youtube.ytplayer.getVideoUrl().replace("https://www.youtube.com/watch?v=", "");
|
||||
|
||||
|
||||
socket.emit("skip", {error: newState.data, id: video_id, pass: adminpass});
|
||||
//console.log(video_id, ytplayer.getVideoUrl(), ytplayer.getPlayerState());
|
||||
//console.log(video_id, Youtube.ytplayer.getVideoUrl(), Youtube.ytplayer.getPlayerState());
|
||||
|
||||
/*}else{
|
||||
setTimeout(function(){
|
||||
ytplayer.loadVideoById(video_id);
|
||||
Youtube.ytplayer.loadVideoById(video_id);
|
||||
Youtube.count ++;
|
||||
}, Math.floor((Math.random() * 100) + 1));
|
||||
}*/
|
||||
}else if(video_id !== undefined)
|
||||
ytplayer.loadVideoById(video_id);
|
||||
Youtube.ytplayer.loadVideoById(video_id);
|
||||
},
|
||||
|
||||
onPlayerReady: function(event) {
|
||||
@@ -160,14 +161,14 @@ var Youtube = {
|
||||
$("#player").css("opacity", "1");
|
||||
$("#controls").css("opacity", "1");
|
||||
$(".playlist").css("opacity", "1");
|
||||
ytplayer.loadVideoById(video_id);
|
||||
ytplayer.playVideo();
|
||||
ytplayer.seekTo(seekTo);
|
||||
Youtube.ytplayer.loadVideoById(video_id);
|
||||
Youtube.ytplayer.playVideo();
|
||||
Youtube.ytplayer.seekTo(seekTo);
|
||||
}
|
||||
Youtube.readyLooks();
|
||||
Playercontrols.initYoutubeControls(ytplayer);
|
||||
Playercontrols.initYoutubeControls(Youtube.ytplayer);
|
||||
Playercontrols.initSlider();
|
||||
ytplayer.setVolume(Crypt.get_volume());
|
||||
Youtube.ytplayer.setVolume(Crypt.get_volume());
|
||||
},
|
||||
|
||||
readyLooks: function()
|
||||
@@ -223,7 +224,7 @@ var Youtube = {
|
||||
},
|
||||
|
||||
onYouTubeIframeAPIReady: function() {
|
||||
ytplayer = new YT.Player('player', {
|
||||
Youtube.ytplayer = new YT.Player('player', {
|
||||
videoId: "asd",
|
||||
playerVars: { rel:"0", wmode:"transparent", controls: "0" , iv_load_policy: "3", theme:"light", color:"white"},
|
||||
events: {
|
||||
@@ -235,9 +236,7 @@ var Youtube = {
|
||||
},
|
||||
|
||||
loadPlayer: function() {
|
||||
console.log($("script[src='https://www.youtube.com/iframe_api']")["length"]);
|
||||
if($("script[src='https://www.youtube.com/iframe_api']")["length"] == 1){
|
||||
console.log("script exists");
|
||||
Youtube.onYouTubeIframeAPIReady();
|
||||
}else{
|
||||
tag = document.createElement('script');
|
||||
|
||||
Reference in New Issue
Block a user