mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Mobile 'hack'
This commit is contained in:
2
server/public/assets/dist/embed.min.js
vendored
2
server/public/assets/dist/embed.min.js
vendored
File diff suppressed because one or more lines are too long
2
server/public/assets/dist/main.min.js
vendored
2
server/public/assets/dist/main.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -59,6 +59,7 @@ var prev_chan_player = "";
|
||||
var chromecastReady = false;
|
||||
var found_array = [];
|
||||
var found_array_index = 0;
|
||||
var guid = "";
|
||||
var castSession;
|
||||
var width_timeout;
|
||||
var tap_target_timeout;
|
||||
@@ -125,6 +126,12 @@ $().ready(function(){
|
||||
initfp();
|
||||
}
|
||||
|
||||
if(Helper.mobilecheck()) {
|
||||
socket.on("guid", function(msg) {
|
||||
guid = msg;
|
||||
});
|
||||
}
|
||||
|
||||
socket.on("connect", function(){
|
||||
if(connect_error){
|
||||
connect_error = false;
|
||||
@@ -399,44 +406,49 @@ initializeCastApi = function() {
|
||||
Helper.log(event.sessionState);
|
||||
switch (event.sessionState) {
|
||||
case cast.framework.SessionState.SESSION_STARTED:
|
||||
castSession = cast.framework.CastContext.getInstance().getCurrentSession();
|
||||
castSession.addMessageListener("urn:x-cast:zoff.me", chromecastListener)
|
||||
chrome.cast.media.GenericMediaMetadata({title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg'});
|
||||
chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
||||
chromecastAvailable = true;
|
||||
paused = false;
|
||||
mobile_beginning = false;
|
||||
var _seekTo;
|
||||
try{
|
||||
_seekTo = Player.player.getCurrentTime();
|
||||
} catch(e){
|
||||
_seekTo = seekTo;
|
||||
}
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", videoId: video_id, seekTo: _seekTo})
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title})
|
||||
hide_native(1);
|
||||
break;
|
||||
castSession = cast.framework.CastContext.getInstance().getCurrentSession();
|
||||
castSession.addMessageListener("urn:x-cast:zoff.me", chromecastListener)
|
||||
chrome.cast.media.GenericMediaMetadata({title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg'});
|
||||
chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
||||
chromecastAvailable = true;
|
||||
paused = false;
|
||||
mobile_beginning = false;
|
||||
var _seekTo;
|
||||
try{
|
||||
_seekTo = Player.player.getCurrentTime();
|
||||
} catch(e){
|
||||
_seekTo = seekTo;
|
||||
}
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", videoId: video_id, seekTo: _seekTo})
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title})
|
||||
|
||||
if(Helper.mobilecheck()) {
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "mobilespecs", guid: guid, socketid: socket.id, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), channel: chan.toLowerCase(), userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))})
|
||||
}
|
||||
|
||||
hide_native(1);
|
||||
break;
|
||||
case cast.framework.SessionState.SESSION_RESUMED:
|
||||
castSession = cast.framework.CastContext.getInstance().getCurrentSession();
|
||||
castSession.addMessageListener("urn:x-cast:zoff.me", chromecastListener);
|
||||
chrome.cast.media.GenericMediaMetadata({title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg'});
|
||||
chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
||||
chromecastAvailable = true;
|
||||
paused = false;
|
||||
mobile_beginning = false;
|
||||
var _seekTo;
|
||||
try{
|
||||
_seekTo = Player.player.getCurrentTime();
|
||||
} catch(e){
|
||||
_seekTo = seekTo;
|
||||
}
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", videoId: video_id, seekTo: _seekTo})
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title})
|
||||
hide_native(1);
|
||||
break;
|
||||
castSession = cast.framework.CastContext.getInstance().getCurrentSession();
|
||||
castSession.addMessageListener("urn:x-cast:zoff.me", chromecastListener);
|
||||
chrome.cast.media.GenericMediaMetadata({title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg'});
|
||||
chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
||||
chromecastAvailable = true;
|
||||
paused = false;
|
||||
mobile_beginning = false;
|
||||
var _seekTo;
|
||||
try{
|
||||
_seekTo = Player.player.getCurrentTime();
|
||||
} catch(e){
|
||||
_seekTo = seekTo;
|
||||
}
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", videoId: video_id, seekTo: _seekTo})
|
||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title})
|
||||
hide_native(1);
|
||||
break;
|
||||
case cast.framework.SessionState.SESSION_ENDED:
|
||||
chromecastAvailable = false;
|
||||
hide_native(0);
|
||||
chromecastAvailable = false;
|
||||
hide_native(0);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -155,6 +155,23 @@ io.on('connection', function(socket){
|
||||
else
|
||||
name = names[guid];
|
||||
|
||||
socket.emit("guid", guid);
|
||||
|
||||
socket.on("chromecast", function(msg) {
|
||||
try {
|
||||
if(typeof(msg) == "object" && msg.hasOwnProperty("guid") && msg.hasOwnProperty("socket_id") && msg.hasOwnProperty("channel")) {
|
||||
if(lists[msg.channel].indexOf(msg.guid) > -1) {
|
||||
guid = msg.guid;
|
||||
socketid = msg.socket_id;
|
||||
coll = msg.channel;
|
||||
in_list = true;
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("get_userlists", function(id) {
|
||||
db.collection("frontpage_lists_" + id).find(function(err, docs) {
|
||||
socket.emit("userlists", [docs]);
|
||||
@@ -605,6 +622,7 @@ io.on('connection', function(socket){
|
||||
io.to(coll).emit("channel", {type: "added", value: {"_id": "asd", "added":added,"guids":guids,"id":id,"now_playing":np,"title":title,"votes":votes, "duration":duration}});
|
||||
}
|
||||
db.collection("frontpage_lists").update({_id:coll}, {$inc:{count:1}, $set:{accessed: get_time()}}, {upsert:true}, function(err, docs){});
|
||||
getNextSong(coll);
|
||||
});
|
||||
if(!full_list) {
|
||||
socket.emit("toast", "addedsong");
|
||||
@@ -1031,6 +1049,7 @@ io.on('connection', function(socket){
|
||||
if(!docs){
|
||||
send_list(coll, undefined, false, true, false, true);
|
||||
socket.emit("toast", "shuffled");
|
||||
|
||||
return;
|
||||
}else{
|
||||
num = Math.floor(Math.random()*1000000);
|
||||
@@ -1048,6 +1067,7 @@ io.on('connection', function(socket){
|
||||
if(tot == curr)
|
||||
{
|
||||
send_list(coll, undefined, false, true, false);
|
||||
getNextSong(coll);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1310,6 +1330,8 @@ function vote(coll, id, guid, socket, full_list, last) {
|
||||
if((full_list && last) || (!full_list))
|
||||
socket.emit("toast", "voted");
|
||||
io.to(coll).emit("channel", {type: "vote", value: id, time: get_time()});
|
||||
|
||||
getNextSong(coll);
|
||||
});
|
||||
}else
|
||||
{
|
||||
@@ -1318,6 +1340,32 @@ function vote(coll, id, guid, socket, full_list, last) {
|
||||
});
|
||||
}
|
||||
|
||||
function getNextSong(coll) {
|
||||
db.collection(coll).aggregate([{
|
||||
$match:{
|
||||
views:{
|
||||
$exists: false
|
||||
},
|
||||
type:{
|
||||
$ne: "suggested"
|
||||
}
|
||||
}
|
||||
}, {
|
||||
$sort:{
|
||||
now_playing: 1,
|
||||
votes:-1,
|
||||
added:1,
|
||||
title: 1
|
||||
}
|
||||
}, {
|
||||
$limit:1
|
||||
}], function(err, doc) {
|
||||
if(doc.length == 1) {
|
||||
io.to(coll).emit("next_song", {videoId: doc[0].id, title: doc[0].title});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function change_song(coll, error, id) {
|
||||
db.collection(coll).find({views:{$exists:true}}, function(err, docs){
|
||||
@@ -1565,9 +1613,10 @@ function send_play(coll, socket)
|
||||
if(conf[0].hasOwnProperty("userpass") && conf[0].userpass != "") conf[0].userpass = true;
|
||||
else conf[0].userpass = false;
|
||||
toSend = {np: np, conf: conf, time: get_time()};
|
||||
if(socket === undefined)
|
||||
io.to(coll).emit("np", toSend);
|
||||
else{
|
||||
if(socket === undefined) {
|
||||
io.to(coll).emit("np", toSend);
|
||||
getNextSong(coll)
|
||||
} else {
|
||||
socket.emit("np", toSend);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user