Merge branch 'dirble_fix' of git://github.com/Nofre/ympd into Nofre-dirble_fix
authorSuperBFG7 <daniel@despite.ch>
Mon, 8 Feb 2016 09:32:08 +0000 (10:32 +0100)
committerSuperBFG7 <daniel@despite.ch>
Mon, 8 Feb 2016 09:32:08 +0000 (10:32 +0100)
1  2 
README.md
htdocs/index.html
htdocs/js/mpd.js

diff --cc 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
  ---------
Simple merge
@@@ -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');
  });