Announcement

Collapse
No announcement yet.

Broadcast Detection Script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Broadcast Detection Script

    I need a javascript or php script which will detect whether or not I'm broadcasting and redirect to a page based on the result.

    Something like this ...

    1) Visitor goes to my site
    2) Index page has a javascript or php script
    3) The script checks to see "is he broadcasting?"

    4) if he is ... go to page yada
    5) otherwise, go to page bada-bing

    Currently, I've been using something called Lite.pm but it only works by asking for rtsp info.

    I've had much difficulty making it work, so I'm hoping others have attempted what I'm after with more success.

    P.s. Before you ask "but why would you want to?" ... please understand that such information doesn't matter in reference to the solution.

  • #2
    This is easily done with PHP. You may need to do a bit of modification to some existing script(s), however.

    Check out www.hotscripts.com - search for Shoutcast under PHP.
    Wavestreaming | Shoutcast Hosting | Auto DJ |
    How To Start An Internet Radio Station

    Comment


    • #3
      Here's the code I found which is "simple."

      However, I can't even get this code to work as it is.

      I've added the info for my server. Any suggestions to get the redirect?

      the code ...

      <?php

      // Mysql staus image script by Anthony Parkes
      // [email protected]
      // www.aj-services.com

      $server = "robindean.no-ip.info"; // IP address to your shoutcast server.
      $port = "8554"; // port of your shoutcast server
      $online = "http://www.robindean.com/media_debut.jpg"; // Online Gif image
      $offline = "http://www.robindean.com/media_shadows.jpg"; // offline gif image

      // Start Data Collection

      $fp = fsockopen("$server", $port, $errno, $errstr, 30);
      fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)\r\n\r\n");
      while (!feof($fp))
      {
      $content .= fgets($fp,128);
      }
      fclose($fp);

      // start data processing

      $debut = strpos($content, '<body>') + strlen('<body>');
      $fin = strpos($content, '</body>', $debut);
      $string = substr($content, $debut, $fin - $debut);
      $stats = explode(',', $string);

      // Start Image generation
      // Dedug Status echo "$stats[1]";

      // offline

      if ($stats[1] == "0")
      {
      header("Content-type: image/gif");
      readfile('$offline');
      }

      //online

      if ($stats[1] == "1")
      {
      header("Content-type: image/gif");
      readfile('$online');
      }

      ?>

      Comment


      • #4
        What is a /7.html anyway. I have been getting a few of those.

        Comment


        • #5
          Go hit it on your dnas

          http://yourip:yourport/7.html
          Atlantic Sound Factory
          Licensed by StreamLicensing | Powered by Fast Serv | Radionomy Broadcaster

          Comment


          • #6
            rob,

            learn php heres how to use redirection. so you could add some lines in the existing code you have to change to a differnet page, rather than show the online/offline status

            Use this PHP redirect script to transfer visitors from one webpage URL to another, either on your own site or on a page on another domain.


            This is not a shoutcast server problem, and if we teach you too much about web and scripting people tend to get uptight including myself

            cheers
            ~ According to the ship's log we're down to our last 3000 vomit bags.It'll never be enough.
            search the forums! don't PM me on how-to, or ask me to setup you system. you do it so you learn.

            Comment


            • #7
              I don't want to learn PHP. I just want to know what it is and why someone would do it so it shows up in my shoutcast log.

              Comment


              • #8
                So it is someone determining wether I am broadcasting?

                Comment


                • #9
                  The script you had all ready will show if the station is online or not! If you want it to write to a log file you need to write that code or pary someone to do it.

                  There are more example of the radio station status scripts at http://www.streamsolutions.co.uk

                  Real simple to place into html/php files on your web server and it can show 'I AM ON THE AIR', 'I AM NOT ON THE AIR' or graphics like the one you posted here. If you wanted to redirect the entire site to another page, that can be done by changing the code around.

                  again its not shoutcast server problems, its web server setup. Ask around if someone will do it for free and white the stuff for your site.

                  heres a big question, do you have a web site on a host that supports php?? if you are a free account with yahoo, tripod, and others , they do NOT offer php.

                  Dissscusion closed??
                  ~ According to the ship's log we're down to our last 3000 vomit bags.It'll never be enough.
                  search the forums! don't PM me on how-to, or ask me to setup you system. you do it so you learn.

                  Comment


                  • #10
                    I realized after the post that you had two conversations going on this thread. One was to Rob and one to me (Voice23). I apologize more my terse response.

                    I was just trying to determine what the /7.html was because I have never seen it before.

                    Now, if I can figure why I am not listed for weeks, and where Alvin and the Chipmunks on speed are coming from when you connect - I will have had my day completed.

                    Comment


                    • #11
                      Ah - might be able to help there.

                      The chipmunks thing is often caused by an Intro or Backup file on a server that doesn't match frequency and bit rate of the stream. If you stream 64k, 44.1 kHz and you use backup files, make sure they are also encoded to those values.

                      You're not listed because the YP is selectively discarding servers. If you get the nak (100) error and on a server startup, you get the "added" message but no visit from the Directory Tester, you're not getting listed. I have found no pattern to this yet - except it's getting worse, and some servers get listed every time while others never get listed.
                      Atlantic Sound Factory
                      Licensed by StreamLicensing | Powered by Fast Serv | Radionomy Broadcaster

                      Comment


                      • #12
                        Ok, so it is an ongoing issue with the listing problem. I know I was listed a few weeks ago. So at least it is not me. I am glad that I do not depend on Shoutcast to market my stream. ( smile *)

                        As for the introfile. It is .../intro64.mp3. I am encoding a 64k 44.1hz stream in stereo. So I do not know what the deal is. I encoded the intro file to 64k 44.1hz.

                        I took it out and everything went back to normal. I understand what you are telling me, and I thought I had that covered. So once again I plead ignorance here.

                        Thanks for the response. You must be sitting at the computer. (Like Me). No life I guess.

                        Comment


                        • #13
                          voice23 you need to start your own threads it gets too confusing. this thread started with dection scripts or html display of the station status
                          ~ According to the ship's log we're down to our last 3000 vomit bags.It'll never be enough.
                          search the forums! don't PM me on how-to, or ask me to setup you system. you do it so you learn.

                          Comment


                          • #14
                            EXCUSE ME! I saw that it was dealing with the topic that I had a question. Excuse the distraction.

                            Comment


                            • #15
                              Hi,

                              Here's the resolution I'm using. I was looking for similar script for myself. Here's what I did get:

                              PHP Code:
                              <?php $data=file_get_contents("http://url.to/script");
                              if ( 
                              $data !== false && strstr($data,'dj1') !== false ) { $img="http://url.to.images/dj1.jpg"; }
                              elseif ( 
                              $data !== false && strstr($data,'dj2') !== false ) { $img="http://url.to.images/dj2.jpg"; }
                              elseif ( 
                              $data !== false && strstr($data,'dj3') !== false ) { $img="http://url.to.images/dj3.jpg"; }
                              else { 
                              $img="http://url.to.images/default.jpg"; }
                              echo 
                              "<img src={$img} border=0>";
                              ?>
                              Every dj is instructed to put their name into Genre field.
                              I have php/xml script, which gets info from stream server and displays Genre (which will be dj name or default server). If dj is on air, this code will replace default.jpg with dj1.jpg

                              You can edit this simple script to do redirection or whatever you like instead of displaying image.

                              Hope this helps.
                              Tom
                              tau.fm

                              Comment

                              Working...
                              X