1
0
mirror of https://github.com/SuperBFG7/ympd synced 2024-12-02 01:09:55 +00:00

add play-on-click func, fixup of current playing song

This commit is contained in:
Andrew Karpow 2013-11-08 12:58:18 +01:00
parent 1675fe5220
commit 9ee50d00b7
6 changed files with 19 additions and 2011 deletions

View File

@ -53,13 +53,13 @@
<div class="btn-toolbar navbar-btn navbar-right" role="toolbar"> <div class="btn-toolbar navbar-btn navbar-right" role="toolbar">
<div class="btn-group"> <div class="btn-group">
<button type="button" class="btn btn-default"> <button type="button" class="btn btn-default" onclick="socket.send('MPD_API_SET_NEXT');">
<span class="glyphicon glyphicon-backward" onclick="socket.send('MPD_API_SET_NEXT')"></span> <span class="glyphicon glyphicon-backward"></span>
</button> </button>
<button type="button" class="btn btn-default" onclick="socket.send('MPD_API_SET_PAUSE')"> <button type="button" class="btn btn-default" onclick="socket.send('MPD_API_SET_PAUSE');">
<span id="play-icon" class="glyphicon glyphicon-pause"></span> <span id="play-icon" class="glyphicon glyphicon-pause"></span>
</button> </button>
<button type="button" class="btn btn-default" onclick="socket.send('MPD_API_SET_PREV')"> <button type="button" class="btn btn-default" onclick="socket.send('MPD_API_SET_PREV');">
<span class="glyphicon glyphicon-forward"></span> <span class="glyphicon glyphicon-forward"></span>
</button> </button>
</div> </div>

2002
htdocs/js/bootstrap.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -98,6 +98,12 @@ function webSocketConnect() {
"<span class=\"glyphicon glyphicon-trash\"></span></a>") "<span class=\"glyphicon glyphicon-trash\"></span></a>")
.find('a').fadeTo('fast',1); .find('a').fadeTo('fast',1);
}, },
click: function() {
console.log($(this));
$('#salamisandwich > tbody > tr').removeClass('success');
socket.send('MPD_API_PLAY_TRACK,'+$(this).attr('trackid'));
$(this).addClass('success');
},
mouseleave: function(){ mouseleave: function(){
$(this).children().last().find("a").stop().remove(); $(this).children().last().find("a").stop().remove();
} }
@ -176,10 +182,8 @@ function webSocketConnect() {
(elapsed_seconds < 10 ? '0' : '') + elapsed_seconds + " / " + (elapsed_seconds < 10 ? '0' : '') + elapsed_seconds + " / " +
total_minutes + ":" + (total_seconds < 10 ? '0' : '') + total_seconds); total_minutes + ":" + (total_seconds < 10 ? '0' : '') + total_seconds);
$('#salamisandwich > thead > tr').each(function(value) { $('#salamisandwich > tbody > tr').removeClass('success').css("font-weight", "");
$(this).removeClass('success'); $('#salamisandwich > tbody > tr[trackid='+obj.data.currentsongid+']').addClass('success').css("font-weight", "bold");
});
$('#playlist_'+obj.data.currentsongid).addClass('success');
if(obj.data.random) if(obj.data.random)
$('#btnrandom').addClass("active") $('#btnrandom').addClass("active")

View File

@ -1,4 +1,4 @@
CFLAGS = -ggdb -Wall CFLAGS = -Wall -Os
LFLAGS = `pkg-config --libs libwebsockets libmpdclient` LFLAGS = `pkg-config --libs libwebsockets libmpdclient`
.PHONY: clean .PHONY: clean

View File

@ -111,6 +111,11 @@ int callback_ympd(struct libwebsocket_context *context,
if(sscanf(in, "MPD_API_RM_TRACK,%d", &id)) if(sscanf(in, "MPD_API_RM_TRACK,%d", &id))
mpd_run_delete_id(conn, id); mpd_run_delete_id(conn, id);
} }
else if(!strncmp((const char *)in, MPD_API_PLAY_TRACK, sizeof(MPD_API_PLAY_TRACK)-1)) {
unsigned id;
if(sscanf(in, "MPD_API_PLAY_TRACK,%d", &id))
mpd_run_play_id(conn, id);
}
else if(!strncmp((const char *)in, MPD_API_TOGGLE_RANDOM, sizeof(MPD_API_TOGGLE_RANDOM)-1)) { else if(!strncmp((const char *)in, MPD_API_TOGGLE_RANDOM, sizeof(MPD_API_TOGGLE_RANDOM)-1)) {
unsigned random; unsigned random;
if(sscanf(in, "MPD_API_TOGGLE_RANDOM,%d", &random)) if(sscanf(in, "MPD_API_TOGGLE_RANDOM,%d", &random))

View File

@ -25,6 +25,7 @@ enum mpd_conn_states {
#define MPD_API_GET_TRACK_INFO "MPD_API_GET_TRACK_INFO" #define MPD_API_GET_TRACK_INFO "MPD_API_GET_TRACK_INFO"
#define MPD_API_GET_BROWSE "MPD_API_GET_BROWSE" #define MPD_API_GET_BROWSE "MPD_API_GET_BROWSE"
#define MPD_API_ADD_TRACK "MPD_API_ADD_TRACK" #define MPD_API_ADD_TRACK "MPD_API_ADD_TRACK"
#define MPD_API_PLAY_TRACK "MPD_API_PLAY_TRACK"
#define MPD_API_RM_TRACK "MPD_API_RM_TRACK" #define MPD_API_RM_TRACK "MPD_API_RM_TRACK"
#define MPD_API_RM_ALL "MPD_API_RM_ALL" #define MPD_API_RM_ALL "MPD_API_RM_ALL"
#define MPD_API_SET_VOLUME "MPD_API_SET_VOLUME" #define MPD_API_SET_VOLUME "MPD_API_SET_VOLUME"