好的,我正在重新提出这个问题,因为我认为我做的有点太长了:)
我的研究来自我学习如何制作函数和计时器的网站。我当然想用计时器重复 php 部分,但我想我也知道怎么做。首先,我认为这很重要,当我改变流时,我至少得到改变的价值。
这是我的 JQuery 代码,它从 @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
},
我想要这个代码:
$('#title').append(myPlaylist.playlist[myPlaylist.current].title);
获取ip和端口。但是在 PHP 中,因为我有以下 php 代码,它可以从广播流 URL 中获取歌曲标题。
php代码如下:
<?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]);
}
?>
我希望我清楚地展示我的问题:)