mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
More fixes for current playing, and enabling remotecontroller if specified
This commit is contained in:
@@ -13,6 +13,7 @@ var durationBegun = false;
|
||||
var chromecastAvailable = false;
|
||||
var private_channel = false;
|
||||
var offline = false;
|
||||
var began = false;
|
||||
var from_frontpage = false;
|
||||
var seekTo;
|
||||
var socket;
|
||||
@@ -75,7 +76,7 @@ $(document).ready(function(){
|
||||
Player.getTitle(song_title, viewers);
|
||||
});
|
||||
|
||||
|
||||
setup_host_initialization();
|
||||
setup_youtube_listener();
|
||||
setup_list_listener();
|
||||
|
||||
@@ -88,8 +89,20 @@ $(document).ready(function(){
|
||||
window.setVolume = setVolume;
|
||||
$("#controls").css("background-color", color);
|
||||
$("#playlist").css("background-color", color);
|
||||
if(hash.indexOf("controll") > -1) {
|
||||
Hostcontroller.change_enabled(true);
|
||||
} else {
|
||||
Hostcontroller.change_enabled(false);
|
||||
}
|
||||
});
|
||||
|
||||
function setup_host_listener(id){
|
||||
socket.on(id, Hostcontroller.host_on_action);
|
||||
}
|
||||
|
||||
function setup_host_initialization(){
|
||||
socket.on("id", Hostcontroller.host_listener);
|
||||
}
|
||||
|
||||
function setup_youtube_listener(){
|
||||
socket.on("np", Player.youtube_listener);
|
||||
|
||||
@@ -5,13 +5,17 @@ var Hostcontroller = {
|
||||
old_id: null,
|
||||
|
||||
host_listener: function(id) {
|
||||
|
||||
if(Hostcontroller.old_id === null) Hostcontroller.old_id = id;
|
||||
else {
|
||||
socket.removeAllListeners(id);
|
||||
began = false;
|
||||
Hostcontroller.old_id = id;
|
||||
}
|
||||
if(embed) {
|
||||
if(window.parentWindow && window.parentOrigin) {
|
||||
window.parentWindow.postMessage({type: "controller", id: id}, window.parentOrigin);
|
||||
}
|
||||
}
|
||||
var codeURL = "https://remote."+window.location.hostname+"/"+id;
|
||||
$("#code-text").text(id);
|
||||
$("#code-qr").attr("src", "https://chart.googleapis.com/chart?chs=221x221&cht=qr&choe=UTF-8&chld=L|1&chl="+codeURL);
|
||||
@@ -54,6 +58,7 @@ var Hostcontroller = {
|
||||
|
||||
change_enabled:function(val){
|
||||
enabled = val;
|
||||
document.getElementsByName("remote_switch")[0].checked = enabled;
|
||||
console.log(enabled);
|
||||
$(".remote_switch_class").prop("checked", enabled);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -10,6 +10,14 @@ var Player = {
|
||||
youtube_listener: function(obj)
|
||||
{
|
||||
var state;
|
||||
if(embed && obj.np) {
|
||||
if(window.parentWindow && window.parentOrigin) {
|
||||
window.parentWindow.postMessage({type: "np", title: obj.np[0].title}, window.parentOrigin);
|
||||
if(full_playlist.length > 0) {
|
||||
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
|
||||
}
|
||||
}
|
||||
}
|
||||
try{
|
||||
state = Player.player.getPlayerState();
|
||||
}catch(e){
|
||||
@@ -29,15 +37,7 @@ var Player = {
|
||||
} catch(e){}
|
||||
Helper.log("video_id variable: " + video_id);
|
||||
Helper.log("---------------------------------");
|
||||
if(embed && obj.np) {
|
||||
if(window.parentWindow && window.parentOrigin) {
|
||||
window.parentWindow.postMessage({type: "np", title: obj.np[0].title}, window.parentOrigin);
|
||||
if(full_playlist.length > 0) {
|
||||
Player.sendNext({title: full_playlist[0].title, videoId: full_playlist[0].id});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!obj.np){
|
||||
|
||||
document.getElementById('song-title').innerHTML = "Empty channel. Add some songs!";
|
||||
|
||||
Reference in New Issue
Block a user