1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-12-24 10:00:27 +00:00

Show Coverimage

This commit is contained in:
jcorporation 2018-04-16 20:22:07 +01:00
parent 2fa653711d
commit 84ff0b7906
4 changed files with 48 additions and 4 deletions

View File

@ -60,14 +60,14 @@
<span class="glyphicon glyphicon-heart"></span>
</button>
</div>
<!--
<div class="btn-group">
<div class="btn btn-toolbar btn-default">
<span id="volume-icon" class="glyphicon glyphicon-volume-up"></span>
<div id="volumeslider"></div>
</div>
</div>
-->
<div class="btn-group" role="group">
<audio id="player" preload="none"></audio>
<button type="button" class="btn btn-default" onclick="clickLocalPlay()">
@ -370,5 +370,5 @@
<script src="js/sammy.js"></script>
<script src="js/jquery-ui-sortable.min.js"></script>
<script src="js/mpd.js"></script>
</body>
<script src="js/custom.js"></script></body>
</html>

19
htdocs/js/custom.js Normal file
View File

@ -0,0 +1,19 @@
var div=document.createElement('div');
div.id='album-cover';
div.style='background-size:cover;border:1px solid black;border-radius:5px;overflow:hidden;float:left;margin-right:20px;width:120px;height:120px;background-color:#eee;';
var pb=document.querySelector('.panel-body');
pb.insertBefore(div,pb.childNodes[0]);
document.getElementById('btnlove').parentNode.style.display='none';
document.getElementById('player').parentNode.style.display='none';
function changeCover(obj) {
if (obj.data.artist && obj.data.album) {
var coverImg=obj.data.album_artist.replace(/ /g,'_')+'-'+obj.data.album.replace(/ /g,'_')+'.jpg';
document.getElementById('album-cover').style.backgroundImage='url("/covers/'+coverImg+'")';
}
else {
document.getElementById('album-cover').style.backgroundImage='';
}
}

View File

@ -604,7 +604,7 @@ function webSocketConnect() {
socket.send('MPD_API_GET_QUEUE,'+pagination);
break;
case "song_change":
changeCover(obj);
$('#album').text("");
$('#artist').text("");
@ -613,6 +613,7 @@ function webSocketConnect() {
$('#currenttrack').text(" " + obj.data.title);
var notification = "<strong><h4>" + obj.data.title + "</h4></strong>";
if(obj.data.album) {
$('#album').text(obj.data.album);
notification += obj.data.album + "<br />";

View File

@ -499,6 +499,18 @@ char* mpd_get_artist(struct mpd_song const *song)
return str;
}
char* mpd_get_album_artist(struct mpd_song const *song)
{
char *str;
str = (char *)mpd_song_get_tag(song, MPD_TAG_ALBUM_ARTIST, 0);
if(str == NULL){
str = "-";
}
return str;
}
char* mpd_get_year(struct mpd_song const *song)
{
char *str;
@ -602,6 +614,12 @@ int mpd_put_current_song(char *buffer)
cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_tag(song, MPD_TAG_ARTIST, 0));
}
if(mpd_song_get_tag(song, MPD_TAG_ALBUM_ARTIST, 0) != NULL)
{
cur += json_emit_raw_str(cur, end - cur, ",\"album_artist\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_tag(song, MPD_TAG_ALBUM_ARTIST, 0));
}
if(mpd_song_get_tag(song, MPD_TAG_ALBUM, 0) != NULL)
{
cur += json_emit_raw_str(cur, end - cur, ",\"album\":");
@ -640,6 +658,8 @@ int mpd_put_queue(char *buffer, unsigned int offset)
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song));
cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song));
cur += json_emit_raw_str(cur, end - cur, ",\"album_artist\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album_artist(song));
cur += json_emit_raw_str(cur, end - cur, ",\"album\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song));
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
@ -700,6 +720,8 @@ int mpd_put_browse(char *buffer, char *path, unsigned int offset)
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song));
cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song));
cur += json_emit_raw_str(cur, end - cur, ",\"album_artist\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album_artist(song));
cur += json_emit_raw_str(cur, end - cur, ",\"duration\":");
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song));
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
@ -762,6 +784,8 @@ int mpd_search(char *buffer, char *searchstr)
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song));
cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song));
cur += json_emit_raw_str(cur, end - cur, ",\"album_artist\":");
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album_artist(song));
cur += json_emit_raw_str(cur, end - cur, ",\"duration\":");
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song));
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");