Merge branch 'filter'
authorSuperBFG7 <daniel@despite.ch>
Sun, 3 Jun 2018 10:06:07 +0000 (12:06 +0200)
committerSuperBFG7 <daniel@despite.ch>
Sun, 3 Jun 2018 10:06:07 +0000 (12:06 +0200)
1  2 
htdocs/js/mpd.js

@@@ -199,69 -185,6 +199,67 @@@ $(document).ready(function()
      else
          if ($.cookie("notification") === "true")
              $('#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() {