Web Analytics Made Easy -
StatCounter 'Now playing' banner which pulls information from radio stream. - CodingForum

Announcement

Collapse
No announcement yet.

'Now playing' banner which pulls information from radio stream.

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

  • 'Now playing' banner which pulls information from radio stream.

    Hello, I need to make a 'now playing' banner which pulls information from an internet radio. The banner will show the song/dj playing etc.
    As far as Im aware the banner needs to be built in php & I havent been able to find any more information on the subject.
    The information will be pulled from a source like this for e.g http://204.162.193.507:8000/listen
    Any help would be great appreciated
    Thanks

  • #2
    Originally posted by Mark P View Post
    Hello, I need to make a 'now playing' banner which pulls information from an internet radio. The banner will show the song/dj playing etc.
    As far as Im aware the banner needs to be built in php & I havent been able to find any more information on the subject.
    The information will be pulled from a source like this for e.g http://204.162.193.507:8000/listen
    Any help would be great appreciated
    Thanks
    your link don't work for me.

    best regards

    Comment


    • #3
      Hello, no thats just a dummy link to show the kind of stream format the information will be coming from

      Comment


      • #4
        Originally posted by Mark P View Post
        Hello, no thats just a dummy link to show the kind of stream format the information will be coming from
        it's not clear for me what you want and I'm not sure that this will help you, but I guess is something like this:

        http://dir.xiph.org/index.php

        you probably must search for help on the icecast server site:

        http://www.icecast.org/docs.php

        best regards

        Comment


        • #5
          hmm i do understan dwhat he wants but i dont know how to do it since ive never worked with that kind before ... sorry ...

          Comment


          • #6
            Hi, thanks for the replies.
            I found this php code that does what I want, but couldnt seem to get it to work.

            <?php
            // Ruff Dawg's 'Now Playing Sig w/ Background v. 1.2 April 7, 2004
            // Special thanks to the origionator, DJ Rampage

            // This image you can call immediately from an html file in the image tag
            // (i.e. <img src="black.php"> ) easy huh?

            // If you wish to put song/artist in this format: 'artist - song'
            // please use the code at www.ruffdawgradio.com/sig2lines.phps

            Header("Content-type: image/png");

            //*Picture File*//

            // Replace "sicpic.png" with your picture file (must be a .png)

            $im = imagecreatefrompng("np1.png");

            //*Host Information*//

            $host = "rdr.zapto.org"; // No 'http://' in the host
            $port = "8000";


            //*Don't Touch This Stuff Unless You know What You're Doing*//

            $fp = fsockopen("$host", $port, &$errno, &$errstr, 30);
            if(!$fp) {
            $success=2;
            }
            if($success!=2){ //if connection
            fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n");
            while(!feof($fp)) {
            $page .= fgets($fp, 1000);
            }
            fclose($fp);
            $page = ereg_replace(".*<body>", "", $page); //extract data
            $page = ereg_replace("</body>.*", ",", $page); //extract data
            $numbers = explode(",",$page);
            $currentlisteners=$numbers[0];
            $connected=$numbers[1];
            if($connected==1)
            $wordconnected="yes";
            else
            $wordconnected="no";
            $peaklisteners=$numbers[2];
            $maxlisteners=$numbers[3];
            $reportedlisteners=$numbers[4];
            }

            //*Text Colors*//

            // text colors are in RGB

            $text_color1 = ImageColorAllocate($im,0,153,255);
            $text_color2 = ImageColorAllocate($im,0,153,255);

            if($success!=2 && $connected==1){

            $song=explode(" - ",$numbers[6]);


            //*Text Strings*//


            $string1= $song[0];
            $string2= $song[1];
            }

            // These strings below can be repalced with your own ideas

            else {
            $string1= "Ruff Dawg Radio is:";
            $string2= "Temporarily Offline";
            }


            //*Text Positioning*//

            // image,font (from 1 to 5),starting x position, y position,line of text,color

            $px = (imagesx($im)-5*strlen($string1))/2;
            ImageString($im,3,78,24,$string1,$text_color1);
            $px = (imagesx($im)-5*strlen($string2))/2;
            ImageString($im,3,78,44,$string2,$text_color1);

            ImagePng($im);
            imagedestroy($im);
            ?>

            Im wondering if theres an easier way to pull the title info from the stream & display it in a graphic?

            Comment


            • #7
              Originally posted by Mark P View Post
              Hi, thanks for the replies.
              I found this php code that does what I want, but couldnt seem to get it to work.

              PHP Code:
              <?php
              // Ruff Dawg's 'Now Playing Sig w/ Background v. 1.2 April 7, 2004
              // Special thanks to the origionator, DJ Rampage

              // This image you can call immediately from an html file in the image tag
              // (i.e. <img src="black.php"> )    easy huh?

              // If you wish to put song/artist in this format: 'artist - song'
              // please use the code at [url]www.ruffdawgradio.com/sig2lines.phps[/url]

                  
              Header("Content-type: image/png");

              //*Picture File*//

              // Replace "sicpic.png" with your picture file (must be a .png)

                  
              $im imagecreatefrompng("np1.png");

              //*Host Information*//

                  
              $host "rdr.zapto.org"// No 'http://' in the host
                  
              $port "8000";


              //*Don't Touch This Stuff Unless You know What You're Doing*//

                  
              $fp fsockopen("$host"$port, &$errno, &$errstr30);
                  if(!
              $fp) {
                      
              $success=2;
                  }
                  if(
              $success!=2){ //if connection
                      
              fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n");
                      while(!
              feof($fp)) {
                          
              $page .= fgets($fp1000);
                      }
                      
              fclose($fp);
                      
              $page ereg_replace(".*<body>"""$page); //extract data
                      
              $page ereg_replace("</body>.*"","$page); //extract data
                      
              $numbers explode(",",$page);
                      
              $currentlisteners=$numbers[0];
                      
              $connected=$numbers[1];
                      if(
              $connected==1)
                          
              $wordconnected="yes";
                      else
                          
              $wordconnected="no";
                      
              $peaklisteners=$numbers[2];
                      
              $maxlisteners=$numbers[3];
                      
              $reportedlisteners=$numbers[4];
                  }

              //*Text Colors*//

              // text colors are in RGB

                  
              $text_color1 ImageColorAllocate($im,0,153,255);
                  
              $text_color2 ImageColorAllocate($im,0,153,255);
                  
                  if(
              $success!=&& $connected==1){
                      
                  
              $song=explode(" - ",$numbers[6]);


              //*Text Strings*//


                      
              $string1$song[0];
                      
              $string2$song[1];
                  }

              // These strings below can be repalced with your own ideas

                  
              else {
                      
              $string1"Ruff Dawg Radio is:";
              $string2"Temporarily Offline";
                  }


              //*Text Positioning*//

              // image,font (from 1 to 5),starting x position, y position,line of text,color

                  
              $px = (imagesx($im)-5*strlen($string1))/2;
                  
              ImageString($im,3,78,24,$string1,$text_color1);
                  
              $px = (imagesx($im)-5*strlen($string2))/2;
                  
              ImageString($im,3,78,44,$string2,$text_color1);

                  
              ImagePng($im);
                  
              imagedestroy($im);
              ?>
              Im wondering if theres an easier way to pull the title info from the stream & display it in a graphic?
              please put the code between [ php] and [ /php] tags,
              the biggest part of the code in this script is to create a picture. The rest, between "//*Don't Touch This Stuff Unless You know What You're Doing*//" and "//*Text Colors*//" is the detection part, probably by fetching a list from the streaming server, I'm not sure.
              Probably the simplest way to achive this is using a HEAD request to the streaming server, checking if the response is Ok and assume that is onair if server is online.

              best regards

              Comment


              • #8
                hi guys, thanks for the replies.
                one of the problems for me is i dont know how to display this php segment within my html page.
                ive created an iframe & pointed it to this php file on my server but it doesnt seem to work. am i doing it right?
                thanks

                Comment

                Working...
                X