Page 4 of 4 FirstFirst ... 234
Results 31 to 37 of 37
  1. #31

    Title
    Junior Broadcaster
    Join Date
    Oct 2012
    Posts
    85
    Rep Power
    6
    im using that script

    <?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://149.56.234.138:8157/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='http://urban-radio.co.uk/images/jukebox.gif'>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>";
    }
    ?>

    but my question is how am i suppose to know if one of my djs are on the air?

  2. #32

    Title
    Junior Broadcaster
    Join Date
    Jul 2017
    Location
    Cypress, TX
    Posts
    17
    Rep Power
    1
    ok so how do I use this php file to display it on my website? Yes i am still new to this and am in the process of rebuilding it using cpanel.

    Thanks in advance!

  3. #33
    James's Avatar
    Title
    Administrator
    Join Date
    Jan 2008
    Location
    Melbourne, Australia
    Posts
    12,136
    Rep Power
    10
    I have a simplified PHP script in this post:
    http://forums.broadcastingworld.com/...159&#post96159

  4. #34

    Title
    Junior Broadcaster
    Join Date
    Jul 2017
    Location
    Cypress, TX
    Posts
    17
    Rep Power
    1
    Awesome! I will let you know when i am able to test it and let you know the results.

  5. #35

    Title
    Junior Broadcaster
    Join Date
    Jun 2016
    Posts
    47
    Rep Power
    0

    Talking Code I need a Script to show the Current DJ on air (Details Below)

    can someone show me an example page of this php code working please
    i have edited this code before posting


    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://virtual-nexus.de:8000/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/jukebox.png'>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/jukebox.png".$parts[0].".jpg'>Auto DJ</img>";
    }
    ?>

  6. #36
    James's Avatar
    Title
    Administrator
    Join Date
    Jan 2008
    Location
    Melbourne, Australia
    Posts
    12,136
    Rep Power
    10
    Quote Originally Posted by ultra89 View Post
    can someone show me an example page of this php code working please
    i have edited this code before posting


    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://virtual-nexus.de:8000/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/jukebox.png'>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/jukebox.png".$parts[0].".jpg'>Auto DJ</img>";
    }
    ?>

    That script assumes that you show the DJ name via your 'current playing song' input via your stream server.
    Running the script myself, all I get is "feed not loading", this is due to you having a SHOUTcast V1 server, whereas the '/stats?sid=X' parameter is exclusive to SHOUTcast V2.

    I would not be a fan of this script mainly due to the fact it uses the 'current playing song' output for a different purpose than intended. If you wanted to display what DJ is on air now, along with the current playing song, you would not be able to do so.

    Since you are on SHOUTcast V1, you will need a script that analyses the '/7.html' script. This uses a comma separated string rather than XML to pull the info.

  7. #37
    PapaBearPW's Avatar
    Title
    Avid Broadcaster
    Join Date
    Jun 2012
    Posts
    272
    Rep Power
    11
    Quote Originally Posted by James View Post
    I would not be a fan of this script mainly due to the fact it uses the 'current playing song' output for a different purpose than intended. If you wanted to display what DJ is on air now, along with the current playing song, you would not be able to do so.
    Not exactly true James. That script assumes the song titles have been prepended or appended with the DJ names. Echoing out $parts[1] (assuming appended DJ name) will display the DJ name and echoing out $parts[0] will display the current playing song.

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
  •