From: SuperBFG7 Date: Sun, 22 Apr 2018 16:33:10 +0000 (+0200) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=63be6f0de04fe1d4df9c9975a01ac6e3c8e4b21c;p=ympd.git Merge remote-tracking branch 'upstream/master' --- 63be6f0de04fe1d4df9c9975a01ac6e3c8e4b21c diff --cc htdocs/js/mpd.js index 03fe6ab,ce2fd8e..db738d1 --- a/htdocs/js/mpd.js +++ b/htdocs/js/mpd.js @@@ -112,11 -110,7 +112,10 @@@ var app = $.sammy(function() $('#panel-heading').text("Search: "+searchstr); }); - this.get(/\#\/dirble\/(\d+)\/(\d+)/, function() { + + if (TOKEN === "") context.redirect("#/0"); + prepare(); current_app = 'dirble'; $('#breadcrump').removeClass('hide').empty().append("
  • Categories
  • "+dirble_selected_cat+"
  • "); @@@ -139,18 -133,10 +138,13 @@@ 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"); + prepare(); current_app = 'dirble'; $('#breadcrump').removeClass('hide').empty().append("
  • Categories
  • "); @@@ -205,70 -187,8 +195,69 @@@ $(document).ready(function() $('#btnnotify').addClass("active") add_filter(); + + document.getElementById('player').addEventListener('stalled', function() { + if ( !document.getElementById('player').paused ) { + this.pause(); + clickLocalPlay(); + $('.top-right').notify({ + message:{text:"music stream stalled - trying to recover..."}, + type: "danger", + fadeOut: { enabled: true, delay: 1000 }, + }).show(); + } + }); + + document.getElementById('player').addEventListener('pause', function() { + this.src=''; + this.removeAttribute("src"); + $("#localplay-icon").removeClass("glyphicon-pause").addClass("glyphicon-play"); + }); + + document.getElementById('player').addEventListener('error', function failed(e) { + this.pause(); + switch (e.target.error.code) { + case e.target.error.MEDIA_ERR_ABORTED: + $('.top-right').notify({ + message:{text:"Audio playback aborted by user."}, + type: "info", + fadeOut: { enabled: true, delay: 1000 }, + }).show(); + break; + case e.target.error.MEDIA_ERR_NETWORK: + $('.top-right').notify({ + message:{text:"Network error while playing audio."}, + type: "danger", + fadeOut: { enabled: true, delay: 1000 }, + }).show(); + break; + case e.target.error.MEDIA_ERR_DECODE: + $('.top-right').notify({ + message:{text:"Audio playback aborted. Did you unplug your headphones?"}, + type: "danger", + fadeOut: { enabled: true, delay: 1000 }, + }).show(); + break; + case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED: + $('.top-right').notify({ + message:{text:"Error while loading audio (server, network or format error)."}, + type: "danger", + fadeOut: { enabled: true, delay: 1000 }, + }).show(); + break; + default: + $('.top-right').notify({ + message:{text:"Unknown error while playing audio."}, + type: "danger", + fadeOut: { enabled: true, delay: 1000 }, + }).show(); + break; + } + }, true); + + if (TOKEN === "") $('#dirble').addClass('hide'); }); - function webSocketConnect() { if (typeof MozWebSocket != "undefined") { socket = new MozWebSocket(get_appropriate_ws_url()); @@@ -294,10 -216,9 +285,10 @@@ return; var obj = JSON.parse(msg.data); + switch (obj.type) { - case "queue": + case 'queue': if(current_app !== 'queue') break; @@@ -406,8 -326,7 +397,7 @@@ $('#salamisandwich > tbody').append( "" + "" + - "" + basename(obj.data[item].dir) + "" + - "" + - "" + basename(obj.data[item].dir) + "" + ++ "" + basename(obj.data[item].dir) + "" + "" ); break; @@@ -419,8 -338,7 +409,7 @@@ $('#salamisandwich > tbody').append( "" + "" + - "" + basename(obj.data[item].plist) + "" + - "" + - "" + basename(obj.data[item].plist) + "" + ++ "" + basename(obj.data[item].plist) + "" + "" ); break; @@@ -428,12 -346,15 +417,18 @@@ var minutes = Math.floor(obj.data[item].duration / 60); var seconds = obj.data[item].duration - minutes * 60; - $('#salamisandwich > tbody').append( + if (typeof obj.data[item].artist === 'undefined') { + var details = "" + obj.data[item].title + ""; + } else { + var details = "" + obj.data[item].artist + "
    " + obj.data[item].album + "" + obj.data[item].title + ""; + } + + $('#salamisandwich > tbody').append( "" + - "" + details + + "" + + "" + obj.data[item].title + "" + + "" + obj.data[item].album + "" + + "" + obj.data[item].artist + "" + "" + minutes + ":" + (seconds < 10 ? '0' : '') + seconds + "" ); @@@ -443,9 -364,8 +438,8 @@@ $('#next').removeClass('hide'); } else { $('#salamisandwich > tbody').append( - "" + - "Too many results, please refine your search!" + - "" + + "" + - "Too many results, please refine your search!" + ++ "Too many results, please refine your search!" + "" ); } @@@ -631,9 -555,8 +629,9 @@@ }).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'); diff --cc src/mpd_client.c index 80f15e1,1054ede..a5ebf28 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@@ -638,12 -618,12 +630,16 @@@ int mpd_put_queue(char *buffer, unsigne 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_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, ",\"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_entity_free(entity); diff --cc src/ympd.c index 81e28b0,3aed7e6..8d3f90d --- a/src/ympd.c +++ b/src/ympd.c @@@ -89,19 -77,12 +89,17 @@@ int main(int argc, char **argv mg_set_option(server, "document_root", SRC_PATH); #endif + mg_set_option(server, "auth_domain", "ympd"); mpd.port = 6600; + mpd.local_port = 0; + 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'}, {"port", required_argument, 0, 'p'}, + {"localport", required_argument, 0, 'l'}, {"webport", required_argument, 0, 'w'}, {"dirbletoken", required_argument, 0, 'd'}, {"user", required_argument, 0, 'u'},