0

Ok i am remaking this question since i think i made it a bit too long :)

My research was from websites where i learned how to make functions and timers. I wanna ofcourse repeat the php part with a timer but i think i know how too. First i think its important i atleast get the value to change when i change stream.
This is my JQuery Code that grabs the title variable from @2

@1

$("#jquery_jplayer").bind($.jPlayer.event.play, function(event) {       
$('#title').empty();
$('#title').append(myPlaylist.playlist[myPlaylist.current].title);

@2

var myPlaylist = new jPlayerPlaylist({jPlayer: "#jquery_jplayer",
    cssSelectorAncestor: "#jp_container"
}, [{
    title: "test",                                           // This is grabbed
    mp3: "http://x.x.x.x:xxxx/",
    streaminfo: "x.x.x.x","xxxx",                            // Ip and port Seperate
    },
    {
    title: "test2",                                           // This is grabbed
    mp3: "http://x.x.x.x:xxxx/",
    streaminfo: "x.x.x.x","xxxx",                            // Ip and port Seperate
    },

I would like to have this code:

$('#title').append(myPlaylist.playlist[myPlaylist.current].title);

Fetch the ip and port. but then in PHP, Because i have the folowing php code that grabs the song title from a shoutcast stream URL.

The php code is as follows:

<?php

    function myTest($host,$port)
    {
        //$host = "178.156.201.212"; // ip or url of shoutcast server
        //$port = "8000";          // port of shoutcast server 

        $fp = @fsockopen("$host", $port, $errno, $errstr, 30);

        if($fp)
        {
          fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: GET SEVEN (Mozilla Compatible)\r\n\r\n");

          while(!feof($fp))
          {
            $data .= fgets($fp, 1000);
          }

          fclose($fp);

          $data              = ereg_replace(".*<body>", "", $data);
          $data              = ereg_replace("</body>.*", ",", $data);
          $data_array        = explode(",",$data);
          $listeners         = $data_array[0];
          $status            = $data_array[1];
          $peak_listeners    = $data_array[2];
          $maximum_listeners = $data_array[3];
          $unique_listeners  = $data_array[4];
          $bitrate           = $data_array[5];
          $track             = $data_array[6];
        }

        $title  = chop($track);
        $select = explode(" - ",$title);
        $artist = chop($select[0]);
        $title  = chop($select[1]);
    }
?> 

I hope i am being clear on displaying my question :)

Rob W
  • 341,306
  • 83
  • 791
  • 678
ChoCho
  • 1
  • 2
  • 2
    Seriously? Research on w3schools? – Antony Mar 01 '13 at 10:20
  • 2
    And Java is no JavaScript. You need further research. – Antony Mar 01 '13 at 10:21
  • If I got it right, you want PHP code to self-execute in intervals of 20 seconds? – N.B. Mar 01 '13 at 10:22
  • Thanks for the constructive comments Antony. @N.B. i know how to make it interval every 20 seconds. but i dont know how i can have it fetch the right ip and port from my playlist into the function. – ChoCho Mar 01 '13 at 10:25
  • From the part where i do. $('#title').append(myPlaylist.playlist[myPlaylist.current].title); i would like to do something similar but then putting the ip and host as 2 variables for my php script and then have that repeat every 20seconds. i hope i am making sense ^^ And thank you very much for the help N.B. – ChoCho Mar 01 '13 at 10:28
  • weird for some reason my php example code is being formatted really strangely. – ChoCho Mar 01 '13 at 11:46
  • 1
    Re the PHP code: Please note that the `ereg_replace()` function is deprecated and has been removed entirely from the latest PHP versions. You should switch to using `preg_replace()` instead. – SDC Mar 01 '13 at 11:54
  • Oh wow really? Thanks! Do you think you can help me solve the problem of it being viewed when switching stream? I would be so grateful i have really been at it for some time now. but i keep ending up with no result: the songtitle just stays the same. – ChoCho Mar 01 '13 at 11:57
  • Wow that's some reputation you have here ^^ – ChoCho Mar 01 '13 at 11:58

0 Answers0