From: SuperBFG7 Date: Mon, 8 Feb 2016 09:32:08 +0000 (+0100) Subject: Merge branch 'dirble_fix' of git://github.com/Nofre/ympd into Nofre-dirble_fix X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=ac47c6700415633cc4b41a84a2e77d8d32ee213a;p=ympd.git Merge branch 'dirble_fix' of git://github.com/Nofre/ympd into Nofre-dirble_fix --- ac47c6700415633cc4b41a84a2e77d8d32ee213a diff --cc README.md index 4c92337,28e3732..7655920 --- a/README.md +++ b/README.md @@@ -38,19 -36,11 +38,24 @@@ Usage: ./ympd [OPTION].. --help this help ``` +SSL Support +----------- +To run ympd with SSL support: + +- create a certificate (key and cert in the same file), example: +``` +# openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 1000 -nodes +# cat key.pem cert.pem > ssl.pem +``` +- tell ympd to use a webport using SSL and where to find the certificate: +``` +# ./ympd -w "ssl://8081:/path/to/ssl.pem" - ``` ++ + Dirble support + -------------- + + 1. Get an API-key from http://dirble.com + 2. Add the key at ```var TOKEN = "";```, in ```mpd.js```. Copyright --------- diff --cc htdocs/js/mpd.js index 1f8589c,ceb523b..e6e06a4 --- a/htdocs/js/mpd.js +++ b/htdocs/js/mpd.js @@@ -178,65 -185,9 +186,67 @@@ $(document).ready(function() else if ($.cookie("notification") === "true") $('#btnnotify').addClass("active") + + 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'); - });