Shoutcast no cache html5 player

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Jannes01
    Junior Member
    • Aug 2017
    • 13

    Shoutcast no cache html5 player

    On every SHOUTcast Streams Status (V2) page, there is a html5 webplayer, which has a nocache function.
    When you copy the audio link you see something like "/stream?type=http&nocache=376"
    I also have a html5 audio player on my site, and this one is caching sometimes, So how is this done?
    I think it is with javascript but i can't find out exactly how to do this?
    Anyone can help me with this?
  • djSpinnerCee
    Forum King
    • Aug 2004
    • 3558

    #2
    I would say that each time you load the dnas page the nocache= value is different, that way, your browser will see the url as unique and not attempt to find it in it's cache. the nocache= parameter is most likely ignored by the dnas in returning the actual stream.
    /* v2 HTML5 / Player test pages DigitalMixNYC, DigitalMixNYCbx | DNAS Status: Now Playing js codes (scaststatus_X.php) | PortForward.com | Upload/Download Speed Test | No-IP.com: Free Dynamic DNS | In the YP | dnasDir */

    Comment

    • Jannes01
      Junior Member
      • Aug 2017
      • 13

      #3
      Ok thanks but, how can i achieve the same thing on my website, so visitors also don't have a caching webplayer.

      Comment

      • Jannes01
        Junior Member
        • Aug 2017
        • 13

        #4
        really no one can help me with this?
        I will try to explain it better...
        On the shoutcast Stream Status page, there is an html5 audio player...
        when you look at the source code, you will see at the
        <source src="/stream?type=http&;nocache=Randomnumber
        I really wanted to know how this is being done, the random number changes every time you refresh so it must being done something like Math.floor(Math.random() * 1000000)
        Can this be done in the <audio> tag or must it be done with JS?
        In the JS source i dont see where this must be done.

        Comment

        • knklsturgis
          Junior Member
          • Jun 2018
          • 3

          #5
          api nocache

          yes its a unique number and yes, it will force the cache to be flushed for the element. This also can be used as a session-less token so that each web user instance that has activated the player can be individually tracked, and logged. The random number is generated in java by this file: https://www.radionomy.com/js/radionomy.api.agentid.js by the fallowing code:
          code:
          function GetAgentToken() {
          return 'xxxxxxxxxxxxxxxxxxxx'.replace(/x/g, function (c) { return ((Math.random() * 16) | 0).toString(16) });
          }

          Comment

          • knklsturgis
            Junior Member
            • Jun 2018
            • 3

            #6
            Also, some web browsers will attempt to cache the whole page, that sometimes causes the player to be cached for a few seconds. Placing the no-cache meta tag fixes those browsers:
            code:
            <meta http-equiv="Pragma" content="no-cache">

            Comment

            • corsschip
              Junior Member
              • Jan 2019
              • 6

              #7
              Try this: ?type=http&amp;nocache='.time().'

              Comment

              • PimpUigi
                Junior Member
                • Sep 2005
                • 27

                #8
                So what should I write in my HTML?

                code:
                <script type="text/javascript">
                function GetAgentToken() {
                return 'xxxxxxxxxxxxxxxxxxxx'.replace(/x/g, function (c) { return ((Math.random() * 16) | 0).toString(16) });
                }
                document.getElementById('source1').innerHTML = /stream?type=http&nocache=(16)
                </script>
                <audio controls preload="none">
                <source src="source1" type="audio/mpeg">
                Your browser does not support the audio element.
                </audio>

                ?????
                Sexy Kick!

                Comment

                • PimpUigi
                  Junior Member
                  • Sep 2005
                  • 27

                  #9
                  OK, I got it. This actually inserts the Audio tag right where the script is in the HTML code, so you don't have to retype it. So it starts the Audio controls and the </audio> is still there at the bottom to end it.

                  code:
                  <script type="text/javascript">
                  var nocache=10000+Math.round(Math.random()*90000);
                  document.writeln('<audio id="StationName" controls preload="none" src="/stream?type=http&nocache='+ nocache +'" type="audio/mpeg">');
                  </script>
                  Your browser does not support the audio element.
                  </audio>

                  I recommend getting an HTTPS shoutcast stream if doing this with shoutcast. Since Chrome has issues with shoutcast these days otherwise. I know Shoutcast isn't really built for HTTPS but NexusCast is one such provider of Shoutcast stations that can use an HTTPS server.
                  Sexy Kick!

                  Comment

                  Working...
                  X