mirror of
https://github.com/SuperBFG7/ympd
synced 2025-01-13 19:00:37 +00:00
Added Replaygain to settings
Improved coverimage display
This commit is contained in:
parent
060aeff3ff
commit
7d5accdb92
BIN
htdocs/assets/coverimage-notavailable.png
Normal file
BIN
htdocs/assets/coverimage-notavailable.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
@ -464,6 +464,16 @@
|
||||
</div>
|
||||
<input id="inputCrossfade" type="text" class="form-control border-secondary" value="">
|
||||
</div>
|
||||
<div class="form-group input-group col-md-6 border-secondary">
|
||||
<div class="input-group-prepend">
|
||||
<div class="input-group-text bg-secondary text-light border-secondary">Replaygain</div>
|
||||
</div>
|
||||
<select id="selectReplaygain" class="form-control border-secondary">
|
||||
<option value="off">Off</option>
|
||||
<option value="track">Track</option>
|
||||
<option value="album">Album</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group input-group col-md-6 border-secondary">
|
||||
|
@ -45,7 +45,6 @@ var app = $.sammy(function() {
|
||||
$('#cardQueue').addClass('hide');
|
||||
$('#cardBrowse').addClass('hide');
|
||||
$('#cardSearch').addClass('hide');
|
||||
$('.pagination').addClass('hide');
|
||||
$('#searchqueue > input').val('');
|
||||
$('#cardBrowsePlaylists').addClass('hide');
|
||||
$('#cardBrowseDatabase').addClass('hide');
|
||||
@ -81,7 +80,6 @@ var app = $.sammy(function() {
|
||||
$('#cardQueue').removeClass('hide');
|
||||
$('#navQueue').addClass('active');
|
||||
}
|
||||
//$('#queueList > tbody').empty();
|
||||
if (searchstr.length >= 3) {
|
||||
socket.send('MPD_API_SEARCH_QUEUE,' + mpdtag + ','+pagination+',' + searchstr);
|
||||
}
|
||||
@ -123,7 +121,6 @@ var app = $.sammy(function() {
|
||||
$('#cardBrowse').removeClass('hide');
|
||||
$('#cardBrowseFilesystem').removeClass('hide');
|
||||
$('#cardBrowseNavFilesystem').addClass('active');
|
||||
//$('#browseFilesystemList > tbody').empty();
|
||||
$('#browseBreadcrumb').empty().append("<li class=\"breadcrumb-item\"><a uri=\"\">root</a></li>");
|
||||
socket.send('MPD_API_GET_BROWSE,'+pagination+','+(browsepath ? browsepath : "/"));
|
||||
// Don't add all songs from root
|
||||
@ -252,14 +249,13 @@ function webSocketConnect() {
|
||||
try {
|
||||
socket.onopen = function() {
|
||||
console.log("connected");
|
||||
showNotification('Connected to myMPD','','','success');
|
||||
$('#modalConnectionError').modal('hide');
|
||||
app.run();
|
||||
/* emit request for mympd settings */
|
||||
socket.send('MPD_API_GET_SETTINGS');
|
||||
/* emit initial request for output names */
|
||||
socket.send('MPD_API_GET_OUTPUTS');
|
||||
|
||||
showNotification('Connected to myMPD','','','success');
|
||||
$('#modalConnectionError').modal('hide');
|
||||
app.run();
|
||||
}
|
||||
|
||||
socket.onmessage = function got_packet(msg) {
|
||||
@ -278,7 +274,6 @@ function webSocketConnect() {
|
||||
if(current_app !== 'queue')
|
||||
break;
|
||||
$('#panel-heading-queue').empty();
|
||||
|
||||
if (obj.totalEntities > 0) {
|
||||
$('#panel-heading-queue').text(obj.totalEntities+' Songs');
|
||||
}
|
||||
@ -286,7 +281,6 @@ function webSocketConnect() {
|
||||
$('#panel-heading-queue').append(' – ' + beautifyDuration(obj.totalTime));
|
||||
}
|
||||
|
||||
//$('#queueList > tbody').empty();
|
||||
var nrItems=0;
|
||||
var tr=document.getElementById(current_app+'List').getElementsByTagName('tbody')[0].getElementsByTagName('tr');
|
||||
for (var song in obj.data) {
|
||||
@ -407,7 +401,6 @@ function webSocketConnect() {
|
||||
}
|
||||
break;
|
||||
case 'search':
|
||||
//$('#searchList > tbody').empty();
|
||||
$('#panel-heading-search').text(obj.totalEntities + ' Songs found');
|
||||
case 'browse':
|
||||
if(current_app !== 'browseFilesystem' && current_app !== 'search')
|
||||
@ -577,7 +570,6 @@ function webSocketConnect() {
|
||||
break;
|
||||
case 'disconnected':
|
||||
showNotification('myMPD lost connection to MPD','','','danger');
|
||||
|
||||
break;
|
||||
case 'update_queue':
|
||||
if(current_app === 'queue') {
|
||||
@ -631,6 +623,8 @@ function webSocketConnect() {
|
||||
$('#btnrepeat').removeClass('btn-secondary').addClass("btn-success")
|
||||
else
|
||||
$('#btnrepeat').removeClass("btn-success").addClass("btn-secondary");
|
||||
|
||||
$("#selectReplaygain").val(obj.data.replaygain);
|
||||
|
||||
setLocalStream(obj.data.mpdhost,obj.data.streamport);
|
||||
coverImageFile=obj.data.coverimage;
|
||||
@ -823,55 +817,68 @@ function toggleBtn(btn) {
|
||||
}
|
||||
|
||||
$('#btnrandom').on('click', function (e) {
|
||||
socket.send("MPD_API_TOGGLE_RANDOM," + ($(this).hasClass('btn-success') ? 0 : 1));
|
||||
toggleBtn(this);
|
||||
});
|
||||
$('#btnconsume').on('click', function (e) {
|
||||
socket.send("MPD_API_TOGGLE_CONSUME," + ($(this).hasClass('btn-success') ? 0 : 1));
|
||||
toggleBtn(this);
|
||||
});
|
||||
$('#btnsingle').on('click', function (e) {
|
||||
socket.send("MPD_API_TOGGLE_SINGLE," + ($(this).hasClass('btn-success') ? 0 : 1));
|
||||
toggleBtn(this);
|
||||
toggleBtn(this);
|
||||
});
|
||||
|
||||
$('#btnrepeat').on('click', function (e) {
|
||||
socket.send("MPD_API_TOGGLE_REPEAT," + ($(this).hasClass('btn-success') ? 0 : 1));
|
||||
toggleBtn(this);
|
||||
});
|
||||
|
||||
function confirmSettings() {
|
||||
var value=parseInt($('#inputCrossfade').val());
|
||||
if (!isNaN(value)) {
|
||||
var formOK=true;
|
||||
if (!$('#inputCrossfade').is(':disabled')) {
|
||||
var value=parseInt($('#inputCrossfade').val());
|
||||
if (!isNaN(value)) {
|
||||
$('#inputCrossfade').val(value);
|
||||
socket.send("MPD_API_SET_CROSSFADE," + value);
|
||||
} else {
|
||||
} else {
|
||||
$('#inputCrossfade').popover({"content":"Must be a number","trigger":"manual"});
|
||||
$('#inputCrossfade').popover('show');
|
||||
$('#inputCrossfade').focus();
|
||||
return;
|
||||
formOK=false;
|
||||
}
|
||||
}
|
||||
value=parseFloat($('#inputMixrampdb').val());
|
||||
if (!isNaN(value)) {
|
||||
if (!$('#inputMixrampdb').is(':disabled')) {
|
||||
value=parseFloat($('#inputMixrampdb').val());
|
||||
if (!isNaN(value)) {
|
||||
$('#inputMixrampdb').val(value);
|
||||
socket.send("MPD_API_SET_MIXRAMPDB," + value);
|
||||
} else {
|
||||
} else {
|
||||
$('#inputMixrampdb').popover({"content":"Must be a number","trigger":"manual"});
|
||||
$('#inputMixrampdb').popover('show');
|
||||
$('#inputMixrampdb').focus();
|
||||
return;
|
||||
}
|
||||
value=parseFloat($('#inputMixrampdelay').val());
|
||||
if (!isNaN(value)) {
|
||||
formOK=false;
|
||||
}
|
||||
}
|
||||
if (!$('#inputMixrampdelay').is(':disabled')) {
|
||||
value=parseFloat($('#inputMixrampdelay').val());
|
||||
if (!isNaN(value)) {
|
||||
$('#inputMixrampdelay').val(value);
|
||||
socket.send("MPD_API_SET_MIXRAMPDELAY," + value);
|
||||
} else {
|
||||
} else {
|
||||
$('#inputMixrampdelay').popover({"content":"Must be a number","trigger":"manual"});
|
||||
$('#inputMixrampdelay').popover('show');
|
||||
$('#inputMixrampdelay').focus();
|
||||
return;
|
||||
formOK=false;
|
||||
}
|
||||
}
|
||||
if (formOK == true) {
|
||||
socket.send("MPD_API_TOGGLE_CONSUME," + ($('#btnconsume').hasClass('btn-success') ? 1 : 0));
|
||||
socket.send("MPD_API_TOGGLE_RANDOM," + ($('#btnrandom').hasClass('btn-success') ? 1 : 0));
|
||||
socket.send("MPD_API_TOGGLE_SINGLE," + ($('#btnsingle').hasClass('btn-success') ? 1 : 0));
|
||||
socket.send("MPD_API_TOGGLE_REPEAT," + ($('#btnrepeat').hasClass('btn-success') ? 1 : 0));
|
||||
socket.send("MPD_API_SET_REPLAYGAIN," + $('#selectReplaygain').val());
|
||||
if (!$('#inputCrossfade').is(':disabled'))
|
||||
socket.send("MPD_API_SET_CROSSFADE," + $('#inputCrossfade').val());
|
||||
if (!$('#inputMixrampdb').is(':disabled'))
|
||||
socket.send("MPD_API_SET_MIXRAMPDB," + $('#inputMixrampdb').val());
|
||||
if (!$('#inputMixrampdelay').is(':disabled'))
|
||||
socket.send("MPD_API_SET_MIXRAMPDELAY," + $('#inputMixrampdelay').val());
|
||||
$('#settings').modal('hide');
|
||||
}
|
||||
$('#settings').modal('hide');
|
||||
}
|
||||
|
||||
function toggleoutput(button, id) {
|
||||
@ -1061,12 +1068,14 @@ function songChange(title, artist, album, uri) {
|
||||
|
||||
if (typeof uri != 'undefined' && uri.length > 0) {
|
||||
var coverImg='';
|
||||
if (uri.indexOf('http://') == 0) {
|
||||
coverImg='/assets/httpstream.png';
|
||||
} else {
|
||||
if (uri.indexOf('http://') == 0 || uri.indexOf('https://') == 0 ) {
|
||||
coverImg='/assets/coverimage-httpstream.png';
|
||||
} else if (coverImageFile != '') {
|
||||
coverImg='/library/'+uri.replace(/\/[^\/]+$/,'\/'+coverImageFile);
|
||||
} else {
|
||||
coverImg='/assets/coverimage-notavailable.png';
|
||||
}
|
||||
$('#album-cover').css('backgroundImage','url("'+coverImg+'")');
|
||||
$('#album-cover').css('backgroundImage','url("'+coverImg+'"),url("/assets/coverimage-notavailable.png")');
|
||||
}
|
||||
if(typeof artist != 'undefined' && artist.length > 0 && artist != '-') {
|
||||
textNotification += artist;
|
||||
|
@ -197,7 +197,7 @@ out_browse:
|
||||
if((token = strtok(NULL, ",")) == NULL)
|
||||
goto out_add_track;
|
||||
|
||||
free(p_charbuf);
|
||||
free(p_charbuf);
|
||||
p_charbuf = strdup(c->content);
|
||||
mpd_run_add(mpd.conn, get_arg1(p_charbuf));
|
||||
out_add_track:
|
||||
@ -337,6 +337,24 @@ out_rm_playlist:
|
||||
case MPD_API_GET_STATS:
|
||||
n = mympd_get_stats(mpd.buf);
|
||||
break;
|
||||
case MPD_API_SET_REPLAYGAIN:
|
||||
p_charbuf = strdup(c->content);
|
||||
if(strcmp(strtok(p_charbuf, ","), "MPD_API_SET_REPLAYGAIN"))
|
||||
goto out_set_replaygain;
|
||||
|
||||
if((token = strtok(NULL, ",")) == NULL)
|
||||
goto out_set_replaygain;
|
||||
|
||||
free(p_charbuf);
|
||||
p_charbuf = strdup(c->content);
|
||||
mpd_send_command(mpd.conn, "replay_gain_mode", get_arg1(p_charbuf), NULL);
|
||||
struct mpd_pair *pair;
|
||||
while ((pair = mpd_recv_pair(mpd.conn)) != NULL) {
|
||||
mpd_return_pair(mpd.conn, pair);
|
||||
}
|
||||
out_set_replaygain:
|
||||
free(p_charbuf);
|
||||
break;
|
||||
}
|
||||
|
||||
if(mpd.conn_state == MPD_CONNECTED && mpd_connection_get_error(mpd.conn) != MPD_ERROR_SUCCESS)
|
||||
@ -549,6 +567,7 @@ char* mpd_get_year(struct mpd_song const *song)
|
||||
int mpd_put_state(char *buffer, int *current_song_id, int *next_song_id, unsigned *queue_version)
|
||||
{
|
||||
struct mpd_status *status;
|
||||
const struct mpd_audio_format *audioformat;
|
||||
int len;
|
||||
|
||||
status = mpd_run_status(mpd.conn);
|
||||
@ -557,11 +576,13 @@ int mpd_put_state(char *buffer, int *current_song_id, int *next_song_id, unsign
|
||||
mpd.conn_state = MPD_FAILURE;
|
||||
return 0;
|
||||
}
|
||||
audioformat = mpd_status_get_audio_format(status);
|
||||
|
||||
len = snprintf(buffer, MAX_SIZE,
|
||||
"{\"type\":\"state\", \"data\":{"
|
||||
"\"state\":%d, \"volume\":%d, \"songpos\": %d, \"elapsedTime\": %d, "
|
||||
"\"totalTime\":%d, \"currentsongid\": %d, \"kbitrate\": %d, "
|
||||
"\"audioformat\": { \"sample_rate\": %d, \"bits\": %d, \"channels\": %d}, "
|
||||
"\"queue_length\": %d, \"nextsongpos\": %d"
|
||||
"}}",
|
||||
mpd_status_get_state(status),
|
||||
@ -571,6 +592,7 @@ int mpd_put_state(char *buffer, int *current_song_id, int *next_song_id, unsign
|
||||
mpd_status_get_total_time(status),
|
||||
mpd_status_get_song_id(status),
|
||||
mpd_status_get_kbit_rate(status),
|
||||
audioformat->sample_rate, audioformat->bits, audioformat->channels,
|
||||
mpd_status_get_queue_length(status),
|
||||
mpd_status_get_next_song_pos(status)
|
||||
);
|
||||
@ -586,6 +608,7 @@ int mympd_put_settings(char *buffer)
|
||||
{
|
||||
struct mpd_status *status;
|
||||
int len;
|
||||
char *replaygain;
|
||||
|
||||
status = mpd_run_status(mpd.conn);
|
||||
if (!status) {
|
||||
@ -594,11 +617,18 @@ int mympd_put_settings(char *buffer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
mpd_send_command(mpd.conn, "replay_gain_status", NULL);
|
||||
struct mpd_pair *pair;
|
||||
while ((pair = mpd_recv_pair(mpd.conn)) != NULL) {
|
||||
replaygain=strdup(pair->value);
|
||||
mpd_return_pair(mpd.conn, pair);
|
||||
}
|
||||
|
||||
len = snprintf(buffer, MAX_SIZE,
|
||||
"{\"type\":\"settings\", \"data\":{"
|
||||
"\"repeat\":%d, \"single\":%d, \"crossfade\":%d, \"consume\":%d, \"random\":%d, "
|
||||
"\"mixrampdb\": %lf, \"mixrampdelay\": %lf, \"mpdhost\" : \"%s\", \"mpdport\": \"%d\", \"passwort_set\": %s, "
|
||||
"\"streamport\": \"%d\",\"coverimage\": \"%s\", \"max_elements_per_page\": %d"
|
||||
"\"streamport\": \"%d\",\"coverimage\": \"%s\", \"max_elements_per_page\": %d, \"replaygain\": \"%s\""
|
||||
"}}",
|
||||
mpd_status_get_repeat(status),
|
||||
mpd_status_get_single(status),
|
||||
@ -610,7 +640,8 @@ int mympd_put_settings(char *buffer)
|
||||
mpd.host, mpd.port,
|
||||
mpd.password ? "true" : "false",
|
||||
streamport, coverimage,
|
||||
MAX_ELEMENTS_PER_PAGE
|
||||
MAX_ELEMENTS_PER_PAGE,
|
||||
replaygain
|
||||
);
|
||||
mpd_status_free(status);
|
||||
return len;
|
||||
|
@ -78,7 +78,8 @@
|
||||
X(MPD_API_SET_MIXRAMPDB) \
|
||||
X(MPD_API_SET_MIXRAMPDELAY) \
|
||||
X(MPD_API_GET_PLAYLISTS) \
|
||||
X(MPD_API_RM_PLAYLIST)
|
||||
X(MPD_API_RM_PLAYLIST) \
|
||||
X(MPD_API_SET_REPLAYGAIN)
|
||||
|
||||
enum mpd_cmd_ids {
|
||||
MPD_CMDS(GEN_ENUM)
|
||||
|
Loading…
Reference in New Issue
Block a user