From c83fa60e20be6d07f84c9eac4e9a3c188fb84e94 Mon Sep 17 00:00:00 2001 From: jcorporation Date: Mon, 7 May 2018 20:11:49 +0100 Subject: [PATCH] Filename for album covers are now based on song_uri, replacing filename with folder.jpg Merged css/js files --- README.md | 2 +- htdocs/css/mpd.css | 12 ++++++++++++ htdocs/index.html | 1 + htdocs/js/custom.js | 18 +----------------- htdocs/js/mpd.js | 9 +++++---- src/mpd_client.c | 18 ++++++++++-------- 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 1513a6b..3ca90e3 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ympd Standalone MPD Web GUI written in C, utilizing Websockets and Bootstrap/JS This fork supports display of coverimages. -Put cover images in: ```/path/to/src/htdocs/covers/albumartis-album.jpg``` +Link your mpd music directory to ```/path/to/src/htdocs/library``` and put ```folder.jpg``` files in your album directories http://www.ympd.org diff --git a/htdocs/css/mpd.css b/htdocs/css/mpd.css index ea64fc8..1e27d54 100644 --- a/htdocs/css/mpd.css +++ b/htdocs/css/mpd.css @@ -150,3 +150,15 @@ button { text-align:left; width:2.8em; } + +#album-cover { + background-size:cover; + border:1px solid black; + border-radius:5px; + overflow:hidden; + float:left; + margin-right:20px; + width:120px; + height:120px; + background-color:#eee; +} \ No newline at end of file diff --git a/htdocs/index.html b/htdocs/index.html index 32d0b53..4293d49 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -99,6 +99,7 @@
Queue
+

diff --git a/htdocs/js/custom.js b/htdocs/js/custom.js index 3756429..7efa561 100644 --- a/htdocs/js/custom.js +++ b/htdocs/js/custom.js @@ -1,19 +1,3 @@ -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]); - +//Remove some buttons 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(/\s+/g,'_')+'-'+obj.data.album.replace(/\s+/g,'_')+'.jpg'; - document.getElementById('album-cover').style.backgroundImage='url("/covers/'+coverImg+'")'; - } - else { - document.getElementById('album-cover').style.backgroundImage=''; - } -} diff --git a/htdocs/js/mpd.js b/htdocs/js/mpd.js index 60f4841..9b52559 100644 --- a/htdocs/js/mpd.js +++ b/htdocs/js/mpd.js @@ -87,6 +87,7 @@ var app = $.sammy(function() { } $('#panel-heading').text("Browse database: "+browsepath); + $('#panel-heading-info').empty(); var path_array = browsepath.split('/'); var full_path = ""; $.each(path_array, function(index, chunk) { @@ -623,18 +624,18 @@ function webSocketConnect() { break; case "song_change": - - changeCover(obj); + var coverImg='/library/'+obj.data.uri.replace(/\/[^\/]+$/,'\/folder.jpg'); + document.getElementById('album-cover').style.backgroundImage='url("'+coverImg+'")'; + $('#album').text(""); $('#artist').text(""); - $('#btnlove').removeClass("active"); + $('#btnlove').removeClass("active"); $('#currenttrack').text(" " + obj.data.title); var notification = "

" + obj.data.title + "

"; - if(obj.data.album) { $('#album').text(obj.data.album); notification += obj.data.album + "
"; diff --git a/src/mpd_client.c b/src/mpd_client.c index 51b7f5a..7e852b1 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -607,13 +607,15 @@ int mpd_put_current_song(char *buffer) cur += json_emit_int(cur, end - cur, mpd_song_get_pos(song)); cur += json_emit_raw_str(cur, end - cur, ",\"title\":"); cur += json_emit_quoted_str(cur, end - cur, mpd_get_title(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_artist\":"); +// cur += json_emit_quoted_str(cur, end - cur, mpd_get_album_artist(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\":"); cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song)); + cur += json_emit_raw_str(cur, end - cur, ",\"uri\":"); + cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_uri(song)); cur += json_emit_raw_str(cur, end - cur, "}}"); mpd_song_free(song); @@ -655,8 +657,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_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\":"); @@ -727,8 +729,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, ",\"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\":"); @@ -791,8 +793,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, ",\"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\":");