我想知道如何更改或重复 php 中的某些元素。现在,我正在使用脚本从喊话信息页面获取正在播放的歌曲。
在 JQuery 中,我有一个播放器,其播放列表可以切换流。
现在它现在唯一要做的就是切换到流而不显示任何内容。那么我将如何在 jQuery 中调用 php 部分呢?
天哪,我真的希望我的解释足够清楚。
对于那些能够帮助我
的人,您希望我显示我的代码的哪些部分?
然后我会立即为您粘贴!:)
问候,
库斯。
Arjan 的代码:JQUery
$(document).ready(function(){
var myPlaylist = new jPlayerPlaylist({
jPlayer: "#jquery_jplayer",
cssSelectorAncestor: "#jp_container"
}, [
{
title: "test",
mp3: "http://178.156.201.212:8018/;stream/1",
<?php
$host = "178.156.201.212"; // ip or url of shoutcast server
$port = "8018";
?>
},
{
title: "test2",
mp3: "http://stream1.slowradio.com/;stream/1",
<?php
$host = "http://stream1.slowradio.com"; // ip or url of shoutcast server
$port = "8008";
?>
},
{
title: "test3",
mp3: "http://108.61.73.119:8022/;stream/1",
<?php
$host = "108.61.73.119"; // ip or url of shoutcast server
$port = "8022";
?>
},
], {
swfPath: "js",
supplied: "oga, mp3",
wmode: "window"
});
$("#jquery_jplayer").bind($.jPlayer.event.play, function(event) {
//$('#fetch').html(jPlayerPlaylist.playlist[jPlayerPlaylist.current].title);
$('#fetch').empty();
$('#fetch').append(myPlaylist.playlist[myPlaylist.current].title);
});
});
PHP
<?php
$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]);
?>
<?php
if($status == 1)
{
echo $artist. " - " .$title;
}
else
{
print 'document.getElementById("title").innerHTML = "Offline";';
}
?>