mirror of
https://github.com/SuperBFG7/ympd
synced 2024-12-24 10:00:27 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
4200630849
@ -12,18 +12,17 @@
|
||||
|
||||
name="ympd"
|
||||
rcvar="${name}_enable"
|
||||
command="/usr/local/bin/ympd"
|
||||
command="/usr/local/bin/${name}"
|
||||
pidfile="/var/run/${name}.pid"
|
||||
start_cmd="ympd_start"
|
||||
|
||||
load_rc_config "$name"
|
||||
load_rc_config "${name}"
|
||||
: ${ympd_enable:="NO"}
|
||||
: ${ympd_user:="nobody"}
|
||||
|
||||
ympd_start()
|
||||
{
|
||||
check_startmsgs && echo "Starting ${name}."
|
||||
/usr/sbin/daemon -f -p "${pidfile}" -t "${name}" -u "${ympd_user}" "${command}"
|
||||
/usr/sbin/daemon -f -p "${pidfile}" "${command}" "${rc_flags}"
|
||||
}
|
||||
|
||||
run_rc_command "$1"
|
||||
|
@ -27,11 +27,18 @@ button {
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
#breadcrump {
|
||||
display: block;
|
||||
|
||||
overflow: auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#counter {
|
||||
font-size: 24px;
|
||||
margin-top: -6px;
|
||||
margin-left: 10px;
|
||||
min-width: 50px;
|
||||
font-size: 24px;
|
||||
margin-top: -6px;
|
||||
margin-left: 10px;
|
||||
min-width: 50px;
|
||||
}
|
||||
|
||||
#search {
|
||||
@ -39,7 +46,7 @@ button {
|
||||
}
|
||||
|
||||
.btn-group-hover {
|
||||
opacity: 20%;
|
||||
opacity: 20%;
|
||||
}
|
||||
|
||||
.btn:active,
|
||||
@ -61,8 +68,51 @@ button {
|
||||
}
|
||||
}
|
||||
|
||||
#salamisandwich td:nth-child(3), th:nth-child(3) {
|
||||
h1 {
|
||||
display: block;
|
||||
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
td:nth-child(4), th:nth-child(4) {
|
||||
/* This *has* to be placed before
|
||||
any t[dh]:nth-last-child(2) for
|
||||
the override to work. */
|
||||
min-width: 50%;
|
||||
}
|
||||
|
||||
td:nth-last-child(2), th:nth-last-child(2) {
|
||||
text-align: right;
|
||||
width: 4em;
|
||||
}
|
||||
|
||||
#salamisandwich td:nth-child(4) span {
|
||||
font-style: italic;
|
||||
font-size: 90%;
|
||||
|
||||
display: block;
|
||||
}
|
||||
|
||||
td:nth-child(2), td:nth-child(3) {
|
||||
min-width: 25%;
|
||||
max-width: 10em;
|
||||
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 600px) {
|
||||
td:nth-child(2), td:nth-child(3) {
|
||||
min-width: 0;
|
||||
max-width: 0;
|
||||
}
|
||||
td:nth-child(4), th:nth-child(4) {
|
||||
min-width: 10%;
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
|
||||
tbody {
|
||||
@ -78,7 +128,7 @@ td:last-child, td:first-child {
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
/* Positioning */
|
||||
/* Positioning */
|
||||
.notifications.top-right {
|
||||
right: 10px;
|
||||
top: 60px;
|
||||
@ -94,3 +144,9 @@ td:last-child, td:first-child {
|
||||
button {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#trashmode span:last-child {
|
||||
display:inline-block;
|
||||
text-align:left;
|
||||
width:2.8em;
|
||||
}
|
||||
|
@ -93,18 +93,19 @@
|
||||
|
||||
<div class="col-md-10 col-xs-12">
|
||||
<div class="notifications top-right"></div>
|
||||
|
||||
|
||||
<div class="panel panel-primary">
|
||||
<!-- Default panel contents -->
|
||||
<div class="panel-heading"><b id="panel-heading">Queue</b></div>
|
||||
<div class="panel-heading"><b id="panel-heading">Queue</b>
|
||||
<b id="panel-heading-info" class="text pull-right"></b></div>
|
||||
<div class="panel-body">
|
||||
<h1>
|
||||
<span id="track-icon" onclick="clickPlay();" class="glyphicon glyphicon-play"></span>
|
||||
<span id="currenttrack"></span>
|
||||
</h1>
|
||||
<h4>
|
||||
<span id="album" class="text"></span>
|
||||
<span id="artist" class="text pull-right"></span>
|
||||
<span id="artist" class="text"></span>
|
||||
<span id="album" class="text pull-right"></span>
|
||||
</h4>
|
||||
<p id="counter" class="text pull-right"> </p>
|
||||
|
||||
@ -126,10 +127,10 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>Title</th>
|
||||
<th>Album</th>
|
||||
<th>Artist</th>
|
||||
<th>Duration</th>
|
||||
<th>Album</th>
|
||||
<th>Title</th>
|
||||
<th>Length</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -166,7 +167,7 @@
|
||||
</ul>
|
||||
</div><!-- /.col-md-10 -->
|
||||
|
||||
<div class="col-md-2 col-xs-12" >
|
||||
<div class="col-md-2 col-xs-12">
|
||||
<div class="btn-toolbar">
|
||||
<div class="btn-group-vertical btn-block btn-group-lg" data-toggle="buttons">
|
||||
<button id="btnrandom" type="button" class="btn btn-default">
|
||||
@ -191,32 +192,27 @@
|
||||
<div id="trashmode" class="btn-group-vertical btn-block btn-group-lg" data-toggle="radio">
|
||||
<button id="btntrashmodeup" type="button" class="btn btn-default">
|
||||
<span class="glyphicon glyphicon-chevron-up"></span>
|
||||
<span class="glyphicon glyphicon-trash"></span> up
|
||||
<span class="glyphicon glyphicon-trash"></span> <span>Up</span>
|
||||
</button>
|
||||
<button id="btntrashmodesingle" type="button" class="btn btn-default active">
|
||||
<span class="glyphicon glyphicon-star-empty"></span>
|
||||
<span class="glyphicon glyphicon-trash"></span> single
|
||||
<span class="glyphicon glyphicon-trash"></span> <span>Single</span>
|
||||
</button>
|
||||
<button id="btntrashmodedown" type="button" class="btn btn-default">
|
||||
<span class="glyphicon glyphicon-chevron-down"></span>
|
||||
<span class="glyphicon glyphicon-trash"></span> down
|
||||
<span class="glyphicon glyphicon-trash"></span> <span>Down</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div id="btn-responsive-block" class="btn-group-vertical btn-block btn-group-lg">
|
||||
<button type="button" class="btn btn-default" onclick="socket.send('MPD_API_RM_ALL');">
|
||||
<span class="glyphicon glyphicon-trash"></span> Clear queue
|
||||
<span class="glyphicon glyphicon-trash"></span> Clear Queue
|
||||
</button>
|
||||
<a href="#" data-toggle="modal" data-target="#savequeue" class="btn btn-default">
|
||||
<span class="glyphicon glyphicon-save"></span> Save queue
|
||||
<span class="glyphicon glyphicon-save"></span> Save Queue
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div id="btn-responsive-block" class="btn-group-vertical btn-block btn-group-lg" data-toggle="buttons">
|
||||
<button type="button" class="btn btn-default" id="btnnotify">
|
||||
<span class="glyphicon glyphicon-comment"></span> Notifications
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.col-md-2 -->
|
||||
</div><!-- /.row -->
|
||||
@ -238,6 +234,19 @@
|
||||
<h6><a href="http://cesanta.com/docs.html">Mongoose</a> <small>GPLv2</small></h6>
|
||||
<h6><a href="http://www.musicpd.org/libs/libmpdclient/">libMPDClient</a> <small>BSD License</small></h6>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6">
|
||||
<button type="button" class="btn btn-default btn-block" onclick="updateDB();">
|
||||
<span class="glyphicon glyphicon-refresh"></span> Update Database
|
||||
</button>
|
||||
</div>
|
||||
<div class="form-group col-md-6" data-toggle="buttons">
|
||||
<button type="button" class="btn btn-default btn-block" id="btnnotify">
|
||||
<span class="glyphicon glyphicon-comment"></span> Enable Notifications
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<form role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-md-9">
|
||||
@ -256,7 +265,7 @@
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label class="control-label" for="mpd_pw_con">MPD Password (Confirmation)</label>
|
||||
<input type="password" class="form-control" id="mpd_pw_con" placeholder="Password confirmation"
|
||||
<input type="password" class="form-control" id="mpd_pw_con" placeholder="Confirmation"
|
||||
data-placement="right" data-toggle="popover" data-content="Password does not match!"
|
||||
data-trigger="manual" />
|
||||
</div>
|
||||
@ -301,7 +310,7 @@
|
||||
<div class="modal-body">
|
||||
<form role="form">
|
||||
<div class="row">
|
||||
<div class="form-group col-md-9">
|
||||
<div class="form-group col-md-12">
|
||||
<label class="control-label" for="streamurl">Stream URL</label>
|
||||
<input type="text" class="form-control" id="streamurl" />
|
||||
</div>
|
||||
@ -315,7 +324,7 @@
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
|
||||
<div class="modal fade" id="savequeue" tabindex="-1" role="dialog" aria-labelledby="savequeueLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
142
htdocs/js/mpd.js
142
htdocs/js/mpd.js
@ -47,6 +47,8 @@ var app = $.sammy(function() {
|
||||
socket.send('MPD_API_GET_QUEUE,'+pagination);
|
||||
|
||||
$('#panel-heading').text("Queue");
|
||||
$('#panel-heading-info').empty();
|
||||
|
||||
$('#queue').addClass('active');
|
||||
}
|
||||
|
||||
@ -112,7 +114,6 @@ var app = $.sammy(function() {
|
||||
$('#panel-heading').text("Search: "+searchstr);
|
||||
});
|
||||
|
||||
|
||||
this.get(/\#\/dirble\/(\d+)\/(\d+)/, function() {
|
||||
|
||||
if (TOKEN === "") context.redirect("#/0");
|
||||
@ -127,6 +128,8 @@ var app = $.sammy(function() {
|
||||
$('#dirble_right').find("tr:gt(0)").remove();
|
||||
|
||||
$('#panel-heading').text("Dirble");
|
||||
$('#panel-heading-info').empty();
|
||||
|
||||
$('#dirble').addClass('active');
|
||||
|
||||
$('#next').addClass('hide');
|
||||
@ -139,14 +142,9 @@ var app = $.sammy(function() {
|
||||
|
||||
dirble_stations = true;
|
||||
|
||||
if(dirble_api_token) {
|
||||
dirble_load_stations();
|
||||
} else {
|
||||
getDirbleApiToken();
|
||||
}
|
||||
if (dirble_api_token) { dirble_load_stations(); }
|
||||
});
|
||||
|
||||
|
||||
this.get(/\#\/dirble\//, function() {
|
||||
|
||||
if (TOKEN === "") context.redirect("#/0");
|
||||
@ -161,15 +159,13 @@ var app = $.sammy(function() {
|
||||
$('#dirble_right').find("tr:gt(0)").remove();
|
||||
|
||||
$('#panel-heading').text("Dirble");
|
||||
$('#panel-heading-info').empty();
|
||||
|
||||
$('#dirble').addClass('active');
|
||||
|
||||
dirble_stations = false;
|
||||
|
||||
if(dirble_api_token) {
|
||||
dirble_load_categories();
|
||||
} else {
|
||||
getDirbleApiToken();
|
||||
}
|
||||
if (dirble_api_token) { dirble_load_categories(); }
|
||||
});
|
||||
|
||||
this.get("/", function(context) {
|
||||
@ -268,7 +264,6 @@ $(document).ready(function(){
|
||||
if (TOKEN === "") $('#dirble').addClass('hide');
|
||||
});
|
||||
|
||||
|
||||
function webSocketConnect() {
|
||||
if (typeof MozWebSocket != "undefined") {
|
||||
socket = new MozWebSocket(get_appropriate_ws_url());
|
||||
@ -286,7 +281,9 @@ function webSocketConnect() {
|
||||
|
||||
app.run();
|
||||
/* emit initial request for output names */
|
||||
socket.send("MPD_API_GET_OUTPUTS");
|
||||
socket.send('MPD_API_GET_OUTPUTS');
|
||||
/* emit initial request for dirble api token */
|
||||
socket.send('MPD_API_GET_DIRBLEAPITOKEN');
|
||||
}
|
||||
|
||||
socket.onmessage = function got_packet(msg) {
|
||||
@ -297,10 +294,22 @@ function webSocketConnect() {
|
||||
|
||||
|
||||
switch (obj.type) {
|
||||
case "queue":
|
||||
case 'queue':
|
||||
if(current_app !== 'queue')
|
||||
break;
|
||||
|
||||
if (obj.totalTime > 0) {
|
||||
var hours = Math.floor(obj.totalTime / 3600);
|
||||
var minutes = Math.floor(obj.totalTime / 60) - hours * 60;
|
||||
var seconds = obj.totalTime - hours * 3600 - minutes * 60;
|
||||
|
||||
$('#panel-heading-info').text('Total: ' +
|
||||
(hours > 0 ? hours + '\u2009h ' + (minutes < 10 ? '0' : '') : '') +
|
||||
minutes + '\u2009m ' + (seconds < 10 ? '0' : '') + seconds + '\u2009s');
|
||||
} else {
|
||||
$('#panel-heading-info').empty();
|
||||
}
|
||||
|
||||
$('#salamisandwich > tbody').empty();
|
||||
for (var song in obj.data) {
|
||||
var minutes = Math.floor(obj.data[song].duration / 60);
|
||||
@ -308,9 +317,9 @@ function webSocketConnect() {
|
||||
|
||||
$('#salamisandwich > tbody').append(
|
||||
"<tr trackid=\"" + obj.data[song].id + "\"><td>" + (obj.data[song].pos + 1) + "</td>" +
|
||||
"<td>"+ obj.data[song].title +"</td>" +
|
||||
"<td>"+ obj.data[song].album +"</td>" +
|
||||
"<td>"+ obj.data[song].artist +"</td>" +
|
||||
"<td>"+ obj.data[song].album +"</td>" +
|
||||
"<td>"+ obj.data[song].title +"</td>" +
|
||||
"<td>"+ minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
|
||||
"</td><td></td></tr>");
|
||||
}
|
||||
@ -371,14 +380,14 @@ function webSocketConnect() {
|
||||
};
|
||||
|
||||
//Make queue table sortable
|
||||
$("#salamisandwich > tbody").sortable({
|
||||
$('#salamisandwich > tbody').sortable({
|
||||
helper: fixHelperModified,
|
||||
stop: function(event,ui) {renumber_table('#salamisandwich',ui.item)}
|
||||
}).disableSelection();
|
||||
break;
|
||||
case "search":
|
||||
case 'search':
|
||||
$('#wait').modal('hide');
|
||||
case "browse":
|
||||
case 'browse':
|
||||
if(current_app !== 'browse' && current_app !== 'search')
|
||||
break;
|
||||
|
||||
@ -391,7 +400,7 @@ function webSocketConnect() {
|
||||
}
|
||||
for (var item in obj.data) {
|
||||
switch(obj.data[item].type) {
|
||||
case "directory":
|
||||
case 'directory':
|
||||
var clazz = 'dir';
|
||||
if (filter !== undefined) {
|
||||
var first = obj.data[item].dir[0];
|
||||
@ -406,12 +415,11 @@ function webSocketConnect() {
|
||||
$('#salamisandwich > tbody').append(
|
||||
"<tr uri=\"" + encodeURI(obj.data[item].dir) + "\" class=\"" + clazz + "\">" +
|
||||
"<td><span class=\"glyphicon glyphicon-folder-open\"></span></td>" +
|
||||
"<td><a>" + basename(obj.data[item].dir) + "</a></td>" +
|
||||
"<td></td><td></td>" +
|
||||
"<td colspan=\"3\"><a>" + basename(obj.data[item].dir) + "</a></td>" +
|
||||
"<td></td><td></td></tr>"
|
||||
);
|
||||
break;
|
||||
case "playlist":
|
||||
case 'playlist':
|
||||
var clazz = 'plist';
|
||||
if (filter !== "||") {
|
||||
clazz += ' hide';
|
||||
@ -419,33 +427,38 @@ function webSocketConnect() {
|
||||
$('#salamisandwich > tbody').append(
|
||||
"<tr uri=\"" + encodeURI(obj.data[item].plist) + "\" class=\"" + clazz + "\">" +
|
||||
"<td><span class=\"glyphicon glyphicon-list\"></span></td>" +
|
||||
"<td><a>" + basename(obj.data[item].plist) + "</a></td>" +
|
||||
"<td></td><td></td>" +
|
||||
"<td colspan=\"3\"><a>" + basename(obj.data[item].plist) + "</a></td>" +
|
||||
"<td></td><td></td></tr>"
|
||||
);
|
||||
break;
|
||||
case "song":
|
||||
case 'song':
|
||||
var minutes = Math.floor(obj.data[item].duration / 60);
|
||||
var seconds = obj.data[item].duration - minutes * 60;
|
||||
|
||||
if (obj.data[item].artist == null) {
|
||||
var artist = "<td colspan=\"2\">";
|
||||
} else {
|
||||
var artist = "<td>" + obj.data[item].artist +
|
||||
"<span>" + obj.data[item].album + "</span></td><td>";
|
||||
}
|
||||
|
||||
$('#salamisandwich > tbody').append(
|
||||
"<tr uri=\"" + encodeURI(obj.data[item].uri) + "\" class=\"song\">" +
|
||||
"<td><span class=\"glyphicon glyphicon-music\"></span></td>" +
|
||||
"<td>" + obj.data[item].title + "</td>" +
|
||||
"<td>" + obj.data[item].album + "</td>" +
|
||||
"<td>" + obj.data[item].artist + "</td>" +
|
||||
"<td>" + obj.data[item].album + "</td>" +
|
||||
"<td>" + obj.data[item].title + "</td>" +
|
||||
"<td>" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds +
|
||||
"</td><td></td></tr>"
|
||||
);
|
||||
break;
|
||||
case "wrap":
|
||||
case 'wrap':
|
||||
if(current_app == 'browse') {
|
||||
$('#next').removeClass('hide');
|
||||
} else {
|
||||
$('#salamisandwich > tbody').append(
|
||||
"<tr><td><span class=\"glyphicon glyphicon-remove\"></span></td>" +
|
||||
"<td>Too many results, please refine your search!</td>" +
|
||||
"<td></td><td></td>" +
|
||||
"<tr><td><span class=\"glyphicon glyphicon-remove\"></span></td>" +
|
||||
"<td colspan=\"3\">Too many results, please refine your search!</td>" +
|
||||
"<td></td><td></td></tr>"
|
||||
);
|
||||
}
|
||||
@ -466,7 +479,7 @@ function webSocketConnect() {
|
||||
socket.send(onClickAction + "," + decodeURI($(this).parents("tr").attr("uri")));
|
||||
$('.top-right').notify({
|
||||
message:{
|
||||
text: $('td:nth-child(2)', $(this).parents("tr")).text() + " added"
|
||||
text: "\"" + $('td:nth-last-child(3)', $(this).parents("tr")).text() + "\" added"
|
||||
} }).show();
|
||||
}).fadeTo('fast',1);
|
||||
}
|
||||
@ -500,7 +513,7 @@ function webSocketConnect() {
|
||||
socket.send("MPD_API_ADD_TRACK," + decodeURI($(this).attr("uri")));
|
||||
$('.top-right').notify({
|
||||
message:{
|
||||
text: $('td:nth-child(2)', this).text() + " added"
|
||||
text: "\"" + $('td:nth-last-child(3)', this).text() + "\" added"
|
||||
}
|
||||
}).show();
|
||||
break;
|
||||
@ -508,7 +521,7 @@ function webSocketConnect() {
|
||||
socket.send("MPD_API_ADD_PLAYLIST," + decodeURI($(this).attr("uri")));
|
||||
$('.top-right').notify({
|
||||
message:{
|
||||
text: "Playlist " + $('td:nth-child(2)', this).text() + " added"
|
||||
text: "\"" + $('td:nth-last-child(3)', this).text() + "\" added"
|
||||
}
|
||||
}).show();
|
||||
break;
|
||||
@ -517,7 +530,7 @@ function webSocketConnect() {
|
||||
});
|
||||
|
||||
break;
|
||||
case "state":
|
||||
case 'state':
|
||||
updatePlayIcon(obj.data.state);
|
||||
updateVolumeIcon(obj.data.volume);
|
||||
|
||||
@ -571,16 +584,20 @@ function webSocketConnect() {
|
||||
|
||||
last_state = obj;
|
||||
break;
|
||||
case "outputnames":
|
||||
case 'outputnames':
|
||||
$('#btn-outputs-block button').remove();
|
||||
$.each(obj.data, function(id, name){
|
||||
var btn = $('<button id="btnoutput'+id+'" class="btn btn-default" onclick="toggleoutput(this, '+id+')"><span class="glyphicon glyphicon-volume-up"></span> '+name+'</button>');
|
||||
btn.appendTo($('#btn-outputs-block'));
|
||||
});
|
||||
if ( Object.keys(obj.data).length ) {
|
||||
$.each(obj.data, function(id, name){
|
||||
var btn = $('<button id="btnoutput'+id+'" class="btn btn-default" onclick="toggleoutput(this, '+id+')"><span class="glyphicon glyphicon-volume-up"></span> '+name+'</button>');
|
||||
btn.appendTo($('#btn-outputs-block'));
|
||||
});
|
||||
} else {
|
||||
$('#btn-outputs-block').addClass('hide');
|
||||
}
|
||||
/* remove cache, since the buttons have been recreated */
|
||||
last_outputs = '';
|
||||
break;
|
||||
case "outputs":
|
||||
case 'outputs':
|
||||
if(JSON.stringify(obj) === JSON.stringify(last_outputs))
|
||||
break;
|
||||
$.each(obj.data, function(id, enabled){
|
||||
@ -591,7 +608,7 @@ function webSocketConnect() {
|
||||
});
|
||||
last_outputs = obj;
|
||||
break;
|
||||
case "disconnected":
|
||||
case 'disconnected':
|
||||
if($('.top-right').has('div').length == 0)
|
||||
$('.top-right').notify({
|
||||
message:{text:"ympd lost connection to MPD "},
|
||||
@ -599,11 +616,13 @@ function webSocketConnect() {
|
||||
fadeOut: { enabled: true, delay: 1000 },
|
||||
}).show();
|
||||
break;
|
||||
case "update_queue":
|
||||
case 'update_queue':
|
||||
if(current_app === 'queue')
|
||||
socket.send('MPD_API_GET_QUEUE,'+pagination);
|
||||
break;
|
||||
case "song_change":
|
||||
|
||||
case "song_change":
|
||||
|
||||
changeCover(obj);
|
||||
$('#album').text("");
|
||||
$('#artist').text("");
|
||||
@ -614,14 +633,20 @@ function webSocketConnect() {
|
||||
var notification = "<strong><h4>" + obj.data.title + "</h4></strong>";
|
||||
|
||||
|
||||
|
||||
if(obj.data.album) {
|
||||
$('#album').text(obj.data.album);
|
||||
notification += obj.data.album + "<br />";
|
||||
}
|
||||
|
||||
if(obj.data.artist) {
|
||||
$('#artist').text(obj.data.artist);
|
||||
notification += obj.data.artist + "<br />";
|
||||
}
|
||||
if(obj.data.album) {
|
||||
$('#album').text(obj.data.album);
|
||||
notification += obj.data.album + "<br />";
|
||||
}
|
||||
|
||||
if ($.cookie("notification") === "true")
|
||||
songNotify(obj.data.title, obj.data.artist, obj.data.album );
|
||||
@ -632,23 +657,27 @@ function webSocketConnect() {
|
||||
}).show();
|
||||
|
||||
break;
|
||||
case "mpdhost":
|
||||
case 'mpdhost':
|
||||
$('#mpdhost').val(obj.data.host);
|
||||
setLocalStream(obj.data.host);
|
||||
$('#mpdport').val(obj.data.port);
|
||||
if(obj.data.passwort_set)
|
||||
$('#mpd_password_set').removeClass('hide');
|
||||
break;
|
||||
case "dirbleapitoken":
|
||||
case 'dirbleapitoken':
|
||||
dirble_api_token = obj.data;
|
||||
|
||||
if(dirble_stations) {
|
||||
dirble_load_stations();
|
||||
if (dirble_api_token) {
|
||||
$('#dirble').removeClass('hide');
|
||||
|
||||
if (dirble_stations) { dirble_load_stations(); }
|
||||
else { dirble_load_categories(); }
|
||||
|
||||
} else {
|
||||
dirble_load_categories();
|
||||
}
|
||||
$('#dirble').addClass('hide');
|
||||
}
|
||||
break;
|
||||
case "error":
|
||||
case 'error':
|
||||
$('.top-right').notify({
|
||||
message:{text: obj.data},
|
||||
type: "danger",
|
||||
@ -656,9 +685,8 @@ function webSocketConnect() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
socket.onclose = function(){
|
||||
console.log("disconnected");
|
||||
$('.top-right').notify({
|
||||
@ -899,10 +927,6 @@ function getHost() {
|
||||
$('#mpd_pw_con').keypress(onEnter);
|
||||
}
|
||||
|
||||
function getDirbleApiToken() {
|
||||
socket.send('MPD_API_GET_DIRBLEAPITOKEN');
|
||||
}
|
||||
|
||||
$('#search').submit(function () {
|
||||
app.setLocation("#/search/"+$('#search > div > input').val());
|
||||
$('#wait').modal('show');
|
||||
|
@ -608,6 +608,7 @@ int mpd_put_current_song(char *buffer)
|
||||
cur += json_emit_raw_str(cur, end - cur, ",\"title\":");
|
||||
cur += json_emit_quoted_str(cur, end - cur, mpd_get_title(song));
|
||||
|
||||
|
||||
if(mpd_song_get_tag(song, MPD_TAG_ARTIST, 0) != NULL)
|
||||
{
|
||||
cur += json_emit_raw_str(cur, end - cur, ",\"artist\":");
|
||||
@ -626,6 +627,12 @@ int mpd_put_current_song(char *buffer)
|
||||
cur += json_emit_quoted_str(cur, end - cur, mpd_song_get_tag(song, MPD_TAG_ALBUM, 0));
|
||||
}
|
||||
|
||||
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, "}}");
|
||||
mpd_song_free(song);
|
||||
mpd_response_finish(mpd.conn);
|
||||
@ -638,6 +645,7 @@ int mpd_put_queue(char *buffer, unsigned int offset)
|
||||
char *cur = buffer;
|
||||
const char *end = buffer + MAX_SIZE;
|
||||
struct mpd_entity *entity;
|
||||
unsigned long totalTime = 0;
|
||||
|
||||
if (!mpd_send_list_queue_range_meta(mpd.conn, offset, offset+MAX_ELEMENTS_PER_PAGE))
|
||||
RETURN_ERROR_AND_RECOVER("mpd_send_list_queue_meta");
|
||||
@ -646,16 +654,18 @@ int mpd_put_queue(char *buffer, unsigned int offset)
|
||||
|
||||
while((entity = mpd_recv_entity(mpd.conn)) != NULL) {
|
||||
const struct mpd_song *song;
|
||||
unsigned int drtn;
|
||||
|
||||
if(mpd_entity_get_type(entity) == MPD_ENTITY_TYPE_SONG) {
|
||||
song = mpd_entity_get_song(entity);
|
||||
drtn = mpd_song_get_duration(song);
|
||||
|
||||
cur += json_emit_raw_str(cur, end - cur, "{\"id\":");
|
||||
cur += json_emit_int(cur, end - cur, mpd_song_get_id(song));
|
||||
cur += json_emit_raw_str(cur, end - cur, ",\"pos\":");
|
||||
cur += json_emit_int(cur, end - cur, mpd_song_get_pos(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_int(cur, end - cur, drtn);
|
||||
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\":");
|
||||
@ -664,7 +674,13 @@ int mpd_put_queue(char *buffer, unsigned int offset)
|
||||
cur += json_emit_quoted_str(cur, end - cur, mpd_get_album(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, ",\"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, "},");
|
||||
|
||||
totalTime += drtn;
|
||||
}
|
||||
mpd_entity_free(entity);
|
||||
}
|
||||
@ -672,7 +688,9 @@ int mpd_put_queue(char *buffer, unsigned int offset)
|
||||
/* remove last ',' */
|
||||
cur--;
|
||||
|
||||
cur += json_emit_raw_str(cur, end - cur, "]}");
|
||||
cur += json_emit_raw_str(cur, end - cur, "],\"totalTime\":");
|
||||
cur += json_emit_int(cur, end - cur, totalTime);
|
||||
cur += json_emit_raw_str(cur, end - cur, "}");
|
||||
return cur - buffer;
|
||||
}
|
||||
|
||||
@ -790,6 +808,10 @@ int mpd_search(char *buffer, char *searchstr)
|
||||
cur += json_emit_int(cur, end - cur, mpd_song_get_duration(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, ",\"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, "},");
|
||||
mpd_song_free(song);
|
||||
|
||||
|
@ -95,8 +95,6 @@ int main(int argc, char **argv)
|
||||
mpd.gpass = NULL;
|
||||
strcpy(mpd.host, "127.0.0.1");
|
||||
|
||||
strcpy(dirble_api_token, "2e223c9909593b94fc6577361a");
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"digest", required_argument, 0, 'D'},
|
||||
{"host", required_argument, 0, 'h'},
|
||||
|
Loading…
Reference in New Issue
Block a user