MediaElementJS playing the cache instead of the current song

0

I have the following code:

  $(document).ready(function(){

    var stream = 'http://somdomato.com:8000/stream.mp3';
    var nocache = '';

    $('#tocando').click(function(e) {
        e.preventDefault();
    });

    $('#player').mediaelementplayer({
      //   pluginPath: 'https://cdnjs.com/libraries/mediaelement/',
      //   shimScriptAccess: 'always',
      startVolume: 0.4,
      alwaysShowControls: true,
      features: ['playpause','volume'],
      audioWidth: 145,
      iPadUseNativeControls: true,
      iPhoneUseNativeControls: true,
      //AndroidUseNativeControls: true,
      success: function(player, node) {
        player.addEventListener('pause', function () {
        player.setSrc('');
      }, false);
      player.addEventListener('stalled', function () {
        var checkNetworkStateTimer = setInterval(function () {
          if (!paused) {
            if (node.networkState == 1 || node.networkState == 3) {
                                 var nocache = Math.floor((Math.random() * 1000000) + 1);
                                 player.setSrc(stream+'?nocache='+nocache);
                                 player.load();
                                 player.play();
                                 console.log('re-connecting after stalling due to networkState: '+node.networkState); //2 indicates NETWORK_LOADING state
                             }
                         }
                     }, 3000);

                 }, false);
         player.addEventListener('error', function () {
             var checkNetworkStateTimer = setInterval(function () {
                 if (!paused) {
                     if (node.networkState == 1 || node.networkState == 3) {
                         var nocache = Math.floor((Math.random() * 1000000) + 1);
                         player.setSrc(stream+'?nocache='+nocache);
                         player.load();
                         player.play();
                         console.log('re-connecting after error due to networkState: '+node.networkState); //2 indicates NETWORK_LOADING state
                     }
                 }
             }, 3000);
           }, false);




             },
             error: function () {
                 console.log('error log');
             }


    });


  });

But most of the time when you press pause and then play the player plays a cached version instead of the current song in Streaming (Shoutcast + sc_trans).

I tried to follow this: link

But it did not work, the player sometimes plays and sometimes it returns pro pause, or plays and does not pause ...

Complete Code: link

    
asked by anonymous 17.09.2017 / 03:31

0 answers