forked from ptrk95/MMM-MusicOnDemand
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
93 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,84 @@ | ||
|
||
var text = "Initializing..."; | ||
var init = "Initializing..."; | ||
var Title = ""; | ||
var Artist = ""; | ||
var currentTime = ""; | ||
var maxTime = ""; | ||
var Cover = ""; | ||
var CoverLink = ""; | ||
var closed = false; | ||
|
||
Module.register("MMM-MusicOnDemand",{ | ||
|
||
defaults:{ | ||
chromiumPath: "/usr/bin/chromium-browser", // Set: chromiumPath : null, if you want to use the puppeteer chromium | ||
showCover : true, | ||
email: "[email protected]", | ||
password: "MaxMusterMann" | ||
}, | ||
|
||
getStyles: function() { | ||
return ['style.css',]; | ||
}, | ||
|
||
start: function(){ | ||
this.sendSocketNotification("CONFIG", this.config); | ||
}, | ||
|
||
getDom: function(){ | ||
var wrapper = document.createElement("div"); | ||
wrapper.innerHTML = "<p>" + text + "<br>" + "Title: " + Title + "<br>" + "Artist: " + Artist + "<br>" + currentTime + "/" + maxTime + "</p>" + Cover; | ||
var text = ''; | ||
if(!closed){ | ||
text += "<div class='player'>"; | ||
text += "<div class='text-container'><table class='small'><tr class='title bright'><td>"+ Title +"</td></tr><tr class='artist'><td>"+ Artist +"</td></tr><tr class='init'><td>"+ init +"</td><tr class='time'><td>"+ currentTime + " " + maxTime + "</td></tr></tr></table></div>"; | ||
if(this.config.showCover && Artist != "Deezer"){ | ||
text += "<div class='cover-container'><div class='cover'><img src='"+ CoverLink +"' width='250'></div></div>"; | ||
} | ||
|
||
text += "</div>"; | ||
//text = "<p>" + init + "<br>" + "Title: " + Title + "<br>" + "Artist: " + Artist + "<br>" + currentTime + "/" + maxTime + "</p>" + Cover; | ||
}else{ | ||
wrapper.innerHTML = "Closed"; | ||
wrapper.className = "dimmed light small"; | ||
return wrapper; | ||
} | ||
wrapper.innerHTML = text; | ||
return wrapper; | ||
|
||
}, | ||
|
||
socketNotificationReceived: function(notification, payload) { | ||
switch(notification){ | ||
case("LogIn"): | ||
text = "Logging in to deezer..."; | ||
this.updateDom(); | ||
closed = false; | ||
init = "Logging in to deezer..."; | ||
break; | ||
case("Ready"): | ||
text = ""; | ||
this.updateDom(); | ||
init = ""; | ||
break; | ||
case("Title"): | ||
Title = payload; | ||
this.updateDom(); | ||
break; | ||
case("Update"): | ||
Artist = payload.Artist; | ||
Title = payload.Title; | ||
maxTime = payload.MaxTime; | ||
currentTime = payload.CurrentTime; | ||
this.updateDom(); | ||
break; | ||
case("Ads"): | ||
Title = "Ads"; | ||
Artist = "Deezer"; | ||
Cover = ""; | ||
this.updateDom(); | ||
case("Cover"): | ||
CoverLink = payload; | ||
Cover = '<img height="250" width="250" src="' + CoverLink + '" </img>'; | ||
this.updateDom(); | ||
break; | ||
case("Closed"): | ||
closed = true; | ||
break; | ||
default: | ||
break; | ||
|
||
} | ||
this.updateDom(); | ||
}, | ||
|
||
notificationReceived: function(notification, payload, sender) { | ||
|
@@ -83,13 +102,13 @@ Module.register("MMM-MusicOnDemand",{ | |
this.sendSocketNotification("PREVIOUS", ""); | ||
break; | ||
case("Artist"): | ||
this.sendSocketNotification("Artist", payload.Artist.Artist); | ||
this.sendSocketNotification("Artist", payload.Artist); | ||
break; | ||
case("Close"): | ||
this.sendSocketNotification("Close", ""); | ||
break; | ||
case("Title"): | ||
this.sendSocketNotification("Title", payload.Title.Title); | ||
this.sendSocketNotification("Title", payload.Title); | ||
break; | ||
default: | ||
break; | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.player{ | ||
margin : auto; | ||
width:250px; | ||
display: block; | ||
} | ||
|
||
.cover-container{ | ||
|
||
} | ||
|
||
.text-container{ | ||
|
||
} | ||
|
||
.cover{ | ||
width:250px; | ||
height:250px; | ||
} | ||
|
||
.init{ | ||
font-size:28px; | ||
font-weight: bold; | ||
margin: 0; | ||
} | ||
|
||
.title{ | ||
font-size:20px; | ||
font-weight: bold; | ||
margin: 0; | ||
} | ||
|
||
.artist{ | ||
font-size:20px; | ||
margin: 0px; | ||
} | ||
|
||
.time{ | ||
font-size:20px; | ||
margin: 0px; | ||
} |