mirror of
https://github.com/SuperBFG7/ympd
synced 2025-01-12 10:20:34 +00:00
Show Coverimage
This commit is contained in:
parent
2fa653711d
commit
84ff0b7906
@ -60,14 +60,14 @@
|
|||||||
<span class="glyphicon glyphicon-heart"></span>
|
<span class="glyphicon glyphicon-heart"></span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<!--
|
|
||||||
<div class="btn-group">
|
<div class="btn-group">
|
||||||
<div class="btn btn-toolbar btn-default">
|
<div class="btn btn-toolbar btn-default">
|
||||||
<span id="volume-icon" class="glyphicon glyphicon-volume-up"></span>
|
<span id="volume-icon" class="glyphicon glyphicon-volume-up"></span>
|
||||||
<div id="volumeslider"></div>
|
<div id="volumeslider"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
-->
|
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
<audio id="player" preload="none"></audio>
|
<audio id="player" preload="none"></audio>
|
||||||
<button type="button" class="btn btn-default" onclick="clickLocalPlay()">
|
<button type="button" class="btn btn-default" onclick="clickLocalPlay()">
|
||||||
@ -370,5 +370,5 @@
|
|||||||
<script src="js/sammy.js"></script>
|
<script src="js/sammy.js"></script>
|
||||||
<script src="js/jquery-ui-sortable.min.js"></script>
|
<script src="js/jquery-ui-sortable.min.js"></script>
|
||||||
<script src="js/mpd.js"></script>
|
<script src="js/mpd.js"></script>
|
||||||
</body>
|
<script src="js/custom.js"></script></body>
|
||||||
</html>
|
</html>
|
||||||
|
19
htdocs/js/custom.js
Normal file
19
htdocs/js/custom.js
Normal 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='';
|
||||||
|
}
|
||||||
|
}
|
@ -604,7 +604,7 @@ function webSocketConnect() {
|
|||||||
socket.send('MPD_API_GET_QUEUE,'+pagination);
|
socket.send('MPD_API_GET_QUEUE,'+pagination);
|
||||||
break;
|
break;
|
||||||
case "song_change":
|
case "song_change":
|
||||||
|
changeCover(obj);
|
||||||
$('#album').text("");
|
$('#album').text("");
|
||||||
$('#artist').text("");
|
$('#artist').text("");
|
||||||
|
|
||||||
@ -613,6 +613,7 @@ function webSocketConnect() {
|
|||||||
$('#currenttrack').text(" " + obj.data.title);
|
$('#currenttrack').text(" " + obj.data.title);
|
||||||
var notification = "<strong><h4>" + obj.data.title + "</h4></strong>";
|
var notification = "<strong><h4>" + obj.data.title + "</h4></strong>";
|
||||||
|
|
||||||
|
|
||||||
if(obj.data.album) {
|
if(obj.data.album) {
|
||||||
$('#album').text(obj.data.album);
|
$('#album').text(obj.data.album);
|
||||||
notification += obj.data.album + "<br />";
|
notification += obj.data.album + "<br />";
|
||||||
|
@ -499,6 +499,18 @@ char* mpd_get_artist(struct mpd_song const *song)
|
|||||||
return str;
|
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* mpd_get_year(struct mpd_song const *song)
|
||||||
{
|
{
|
||||||
char *str;
|
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));
|
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)
|
if(mpd_song_get_tag(song, MPD_TAG_ALBUM, 0) != NULL)
|
||||||
{
|
{
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"album\":");
|
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_int(cur, end - cur, mpd_song_get_duration(song));
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
|
cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
|
||||||
cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song));
|
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_raw_str(cur, end - cur, ",\"album\":");
|
||||||
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song));
|
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(song));
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
|
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_quoted_str(cur, end - cur, mpd_get_album(song));
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
|
cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
|
||||||
cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song));
|
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_raw_str(cur, end - cur, ",\"duration\":");
|
||||||
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song));
|
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song));
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
|
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_quoted_str(cur, end - cur, mpd_get_album(song));
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
|
cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
|
||||||
cur += json_emit_quoted_str(cur, end - cur, mpd_get_artist(song));
|
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_raw_str(cur, end - cur, ",\"duration\":");
|
||||||
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song));
|
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(song));
|
||||||
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
|
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
|
||||||
|
Loading…
Reference in New Issue
Block a user