Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 39
  1. #11
    PapaBearPW's Avatar
    Title
    Avid Broadcaster
    Join Date
    Jun 2012
    Posts
    273
    Rep Power
    14
    Give this a try and let me know how it works for you. The code itself is just a couple lines, but I thought it best to put in a good amount of comments to explain what is going on.

    PHP Code:
    <?php
    // First we need to make a connection to your Shoutcast server stats xml page. Change host and port of the url to yours and the sid number too if needed (default is 1).
    $url "http://host:port/stats?sid=1";
    $xml simplexml_load_file($url) or die("feed not loading");

    // Use SERVERGENRE instead of SONGTITLE to parse DJ name from the Genre.
    // $genre = $xml->SERVERGENRE;
    // echo $genre;

    // Next we pull the SONGTITLE from the xml and split the variable with delimiter ":"

    $songTitle $xml->SONGTITLE;
    $parts explode(':'$songTitle);

    // $parts should now contain 2 strings of text in an array if a DJ is onair, and just one if not.
    // Use $parts[0] for prepended song titles and $parts[1] for appended song titles.
    // For prepended (DJ name before title info), DJs must prepend in the format of "DJname: " (without "s.)
    // For appended (DJ name after title info), DJs must append in the format of ":DJname" (without "s.)
    // The colon is important as it is what tells us where the DJ name ends and the Song Title begins.

    // Next we check if anything is in the second part of our array.
    if($parts[1] == ""){ 

    // If there is nothing in the second part of the array, we know that the Auto DJ is on.
    echo "AutoDJ OnAir!";

    // Instead of just saying AutoDJ OnAir, we can echo out an image based on one located in 
    // a folder called djimages like this
    // echo "<img src='djimages/AutoDJ.jpg'>Auto DJ</img>";

    } else {

    // If $parts[1] does have text, our DJ is on.
    echo $parts[0]." OnAir";

    // Instead of just saying DJ XYZ OnAir, we can echo out an image based on one located in
    // a folder called djimages where the image filename is the same as the djname used like this:
    // echo "<img src='djimages/".$parts[0].".jpg'>Auto DJ</img>";
    }
    ?>
    Last edited by PapaBearPW; 07-22-2017 at 04:54 PM. Reason: Fixed an error in the code...

  2. #12

    Title
    Junior Broadcaster
    Join Date
    Oct 2012
    Location
    UK
    Posts
    86
    Rep Power
    8
    that code don't work for me

  3. #13
    PapaBearPW's Avatar
    Title
    Avid Broadcaster
    Join Date
    Jun 2012
    Posts
    273
    Rep Power
    14
    Did you try it after the edit I made? There was a mistake in it that I fixed about 12 minutes before you posted. I was able to get your server info from my side. So, it should work for you too.

  4. #14

    Title
    Junior Broadcaster
    Join Date
    Jul 2017
    Location
    Cypress, TX
    Posts
    17
    Rep Power
    3
    I am getting an error in the code when I put it into an HTMl box on my website:

    SERVERGENRE; // echo $genre; // Next we pull the SONGTITLE from the xml and split the variable with delimiter ":" $songTitle = $xml->SONGTITLE; $parts = explode(':'
    Last edited by mrdata71; 07-22-2017 at 09:50 PM. Reason: something did not paste

  5. #15
    shoutcaststreaming's Avatar
    Title
    Premium Member
    Join Date
    Sep 2008
    Location
    Los Angeles, California
    Posts
    784
    Rep Power
    29
    I tried the code and it works for me.
    SCS - Dedicated Bandwidth Servers
    Shoutcast / Icecast / Windows Media
    Transcoding - Auto DJ - Mobile Radio - FLASH Players - Auto DJ
    Broadcasting World's Stream Host of the Month

  6. #16

    Title
    Junior Broadcaster
    Join Date
    Jul 2017
    Location
    Cypress, TX
    Posts
    17
    Rep Power
    3
    Can you give some insight as to how you are adding this to your website? I cannot upload files to my website and have to add it in an HTML box. Yes I am still learning this and need some assistance please. I so want this code to work. I have a DJ on air right now.

  7. #17
    PapaBearPW's Avatar
    Title
    Avid Broadcaster
    Join Date
    Jun 2012
    Posts
    273
    Rep Power
    14
    That is a php script. If you need to put it inside a pure html page (or box), you should probably upload the code as a php file to your server and then include the php file inside your html box by using an iframe.

  8. #18

    Title
    Junior Broadcaster
    Join Date
    Jul 2017
    Location
    Cypress, TX
    Posts
    17
    Rep Power
    3
    Quote Originally Posted by PapaBearPW View Post
    That is a php script. If you need to put it inside a pure html page (or box), you should probably upload the code as a php file to your server and then include the php file inside your html box by using an iframe.
    I tried to make a folder and it told me 'Wrong File Type' when i uploaded it.

  9. #19
    PapaBearPW's Avatar
    Title
    Avid Broadcaster
    Join Date
    Jun 2012
    Posts
    273
    Rep Power
    14
    More details would be helpful in trying to determine what the problem is.

    You tried to make a folder where?
    Using what?
    Wrong File Type reported by what?
    For what filename exactly?

  10. #20

    Title
    Junior Broadcaster
    Join Date
    Jul 2017
    Location
    Cypress, TX
    Posts
    17
    Rep Power
    3
    i was trying to upload it to my Centova Cast where i send my songs so i made a new folder called PHP. I was able to upload it as an MP3 and reame it as .php but i cant access the file with iframe code.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •