offline and color fixes

- ColorThief on soundcloud images
- Video title now working on offline instantiated player
- Green connected toast on connected
This commit is contained in:
Kasper Rynning-Tønnesen
2018-05-24 13:22:29 +02:00
parent b2a5901a11
commit 2174d9bfd7
4 changed files with 20 additions and 13 deletions

View File

@@ -612,9 +612,13 @@ function send_play(coll, socket, broadcast) {
io.to(coll).emit("np", toSend);
//
List.getNextSong(coll)
sendColor(coll, false, np[0].id);
var url = 'https://img.youtube.com/vi/'+np[0].id+'/mqdefault.jpg';
if(np[0].source == "soundcloud") url = np[0].thumbnail;
sendColor(coll, false, url);
} else {
sendColor(coll, socket, np[0].id);
var url = 'https://img.youtube.com/vi/'+np[0].id+'/mqdefault.jpg';
if(np[0].source == "soundcloud") url = np[0].thumbnail;
sendColor(coll, socket, url);
if(broadcast) {
socket.to(coll).emit("np", toSend);
return;
@@ -637,11 +641,13 @@ function send_play(coll, socket, broadcast) {
});
}
function sendColor(coll, socket, id, ajax, res) {
function sendColor(coll, socket, url, ajax, res) {
if(coll != undefined && typeof(coll) == "string") {
coll = coll.replace(/ /g,'');
}
var url = 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg';
if(url.indexOf("://") == -1) url = 'https://img.youtube.com/vi/'+url+'/mqdefault.jpg';
//var url = 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg';
Jimp.read(url).then(function (image) {
var c = ColorThief.getColor(image);

View File

@@ -218,6 +218,7 @@ window.addEventListener("DOMContentLoaded", function() {
if(offline) {
socket.emit("offline", {status: true, channel: chan != undefined ? chan.toLowerCase() : ""});
}
/*if(chan != undefined && (Crypt.get_pass(chan.toLowerCase()) !== undefined && Crypt.get_pass(chan.toLowerCase()) !== "")){
emit("password", {password: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), channel: chan.toLowerCase()});
}*/
@@ -230,6 +231,7 @@ window.addEventListener("DOMContentLoaded", function() {
var instance = M.Toast.getInstance(to_remove);
instance.dismiss();
}
M.toast({ html: "Connected!", displayLength: 2000, classes: "green lighten"});
//before_toast();
}
Chat.namechange("", true, true);

View File

@@ -13,9 +13,10 @@ var Player = {
},
now_playing_listener: function(obj) {
if(offline && video_id != undefined) return;
if(offline && video_id != undefined) {
return;
}
if(obj.np != undefined) {
video_id = obj.np[0].id;
Player.np = obj.np[0];
Player.np.start = obj.np[0].start;
Player.np.end = obj.np[0].end;
@@ -26,21 +27,19 @@ var Player = {
duration = obj.np[0].duration;
if(offline && (video_id == "" || video_id == undefined) && !client){
if(obj.conf != undefined) {
conf = obj.conf[0];
}
time = obj.time;
seekTo = 0 + Player.np.start;
startTime = time - conf.startTime;
videoSource = obj.np[0].hasOwnProperty("source") ? obj.np[0].source : "youtube";
Player.getTitle(song_title, viewers);
Player.loadVideoById(Player.np.id, duration, Player.np.start, Player.np.end);
} else {
videoSource = obj.np[0].hasOwnProperty("source") ? obj.np[0].source : "youtube";
}
video_id = obj.np[0].id;
} else {
Player.np = {
id: "",
@@ -397,8 +396,9 @@ var Player = {
}
}
if(offline) {
getColor(id);
//socket.emit("color", {id: id});
var url = 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg';
if(videoSource == "soundcloud") url = Player.np.thumbnail;
getColor(url);
}
},

View File

@@ -273,7 +273,7 @@ var Playercontrols = {
setVolume: function(vol) {
Player.setVolume(vol);
Player.soundcloud_player.setVolume(vol / 1000);
Player.soundcloud_player.setVolume(vol / 100);
Playercontrols.choose_button(vol, false);
if(Player.player.isMuted())
Player.player.unMute();
@@ -380,7 +380,6 @@ var Playercontrols = {
var cmp_elmnt = document.getElementById("volume");
var slid_elmnt = document.getElementsByClassName("volume-slid")[0];
if(slider_type != "vertical") {
var pos = (cmp_elmnt.offsetWidth / 100) * val;
var volume = 0;