Skip to content

Commit

Permalink
Merge pull request #52 from ajs124/master
Browse files Browse the repository at this point in the history
Add crossfade support. Not sure about the icon/glyph though
  • Loading branch information
notandy committed Mar 3, 2015
2 parents 1268cab + 3eb12e6 commit ca40c44
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions htdocs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ <h4>
<button id="btnsingle" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-star"></span> Single
</button>
<button id="btncrossfade" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-link"></span> Crossfade
</button>
<button id="btnrepeat" type="button" class="btn btn-default">
<span class="glyphicon glyphicon-repeat"></span> Repeat
</button>
Expand Down
8 changes: 8 additions & 0 deletions htdocs/js/mpd.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ function webSocketConnect() {
else
$('#btnsingle').removeClass("active");

if(obj.data.crossfade)
$('#btncrossfade').addClass("active")
else
$('#btncrossfade').removeClass("active");

if(obj.data.repeat)
$('#btnrepeat').addClass("active")
else
Expand Down Expand Up @@ -488,6 +493,9 @@ $('#btnconsume').on('click', function (e) {
$('#btnsingle').on('click', function (e) {
socket.send("MPD_API_TOGGLE_SINGLE," + ($(this).hasClass('active') ? 0 : 1));
});
$('#btncrossfade').on('click', function(e) {
socket.send("MPD_API_TOGGLE_CROSSFADE," + ($(this).hasClass('active') ? 0 : 1));
});
$('#btnrepeat').on('click', function (e) {
socket.send("MPD_API_TOGGLE_REPEAT," + ($(this).hasClass('active') ? 0 : 1));
});
Expand Down
7 changes: 6 additions & 1 deletion src/mpd_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ int callback_mpd(struct mg_connection *c)
if(sscanf(c->content, "MPD_API_TOGGLE_SINGLE,%u", &uint_buf))
mpd_run_single(mpd.conn, uint_buf);
break;
case MPD_API_TOGGLE_CROSSFADE:
if(sscanf(c->content, "MPD_API_TOGGLE_CROSSFADE,%u", &uint_buf))
mpd_run_crossfade(mpd.conn, uint_buf);
break;
case MPD_API_SET_VOLUME:
if(sscanf(c->content, "MPD_API_SET_VOLUME,%ud", &uint_buf) && uint_buf <= 100)
mpd_run_set_volume(mpd.conn, uint_buf);
Expand Down Expand Up @@ -335,14 +339,15 @@ int mpd_put_state(char *buffer, int *current_song_id, unsigned *queue_version)
len = snprintf(buffer, MAX_SIZE,
"{\"type\":\"state\", \"data\":{"
" \"state\":%d, \"volume\":%d, \"repeat\":%d,"
" \"single\":%d, \"consume\":%d, \"random\":%d, "
" \"single\":%d, \"crossfade\":%d, \"consume\":%d, \"random\":%d, "
" \"songpos\": %d, \"elapsedTime\": %d, \"totalTime\":%d, "
" \"currentsongid\": %d"
"}}",
mpd_status_get_state(status),
mpd_status_get_volume(status),
mpd_status_get_repeat(status),
mpd_status_get_single(status),
mpd_status_get_crossfade(status),
mpd_status_get_consume(status),
mpd_status_get_random(status),
mpd_status_get_song_pos(status),
Expand Down
1 change: 1 addition & 0 deletions src/mpd_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
X(MPD_API_TOGGLE_RANDOM) \
X(MPD_API_TOGGLE_CONSUME) \
X(MPD_API_TOGGLE_SINGLE) \
X(MPD_API_TOGGLE_CROSSFADE) \
X(MPD_API_TOGGLE_REPEAT)

enum mpd_cmd_ids {
Expand Down

0 comments on commit ca40c44

Please sign in to comment.