View previous topic :: View next topic |
Author |
Message |
impactdj
Joined: 06 Apr 2010 Posts: 18
|
Posted: Wed Jun 23, 2010 8:46 pm Post subject: Pls Help with Now Playing Script |
|
|
Please can someone help me with a script? I've searched everywhere for ages now and have found a few but they do not do exactly what i'm after and i don't know php
Basically my host only allows some functions so the php needs to use "fsockopen" as i know it works.
Just two rules:
If fsockopen is open then display the song artist/title
If fsockopen is closed then show Server Offline
I've tried loads now but the closest i got to one doesn't use fsockopen and the page keeps trying to load when server is offline instead of just displaying |
|
Back to top |
|
|
impactdj
Joined: 06 Apr 2010 Posts: 18
|
Posted: Thu Jun 24, 2010 11:32 am Post subject: |
|
|
The below would be perfect but it is for a shoutcast server and i need icecast:
Can anyone convert?
index.php
Code: |
<html>
<head>
<script type="text/javascript" src="./jquery.js"></script>
<script type="text/javascript">
function updateNowPlaying(){
$.ajax({
url: "./now-playing.php",
cache: false,
success: function(html){
$("#nowPlaying").html(html);
}
});
}
updateNowPlaying();
setInterval( "updateNowPlaying()", 10000 );
</script>
</head>
<body bgcolor="#171717">
<center>
<font size="3" color="ff0000"><b>
<div id="nowPlaying"></div></b>
</font>
</center>
</body>
</html>
|
now-playing.php
Code: |
<?php
/*
Now Playing PHP script for SHOUTcast
This script is (C) MixStream.net 2008
Feel free to modify this free script
in any other way to suit your needs.
Version: v1.1
*/
/* ----------- Server configuration ---------- */
$ip = "host.host.net";
$port = "9999";
/* ----- No need to edit below this line ----- */
/* ------------------------------------------- */
$fp = @fsockopen($ip,$port,$errno,$errstr,1);
if (!$fp)
{
echo "OFF AIR - Tune In At 6pm"; // Diaplays when sever is offline
}
else
{
fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
while (!feof($fp))
{
$info = fgets($fp);
}
$info = str_replace('</body></html>', "", $info);
$split = explode(',', $info);
if (empty($split[6]) )
{
echo "The current song is not available"; // Diaplays when sever is online but no song title
}
else
{
$title = str_replace('\'', '`', $split[6]);
$title = str_replace(',', ' ', $title);
echo "$title"; // Diaplays song
}
}
?>
|
|
|
Back to top |
|
|
karlH Code Warrior
Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Thu Jun 24, 2010 12:43 pm Post subject: |
|
|
does the icecast status2.xsl help you out at all, it would seem simpler than parsing html. All the php would need to do is http://icecast:port/status2.xsl?mount=/mountpint If you can change xsl or copy it, you can tailor it so only the title is reported, then it would be very trivial to read from php
karl. |
|
Back to top |
|
|
impactdj
Joined: 06 Apr 2010 Posts: 18
|
Posted: Thu Jun 24, 2010 1:32 pm Post subject: |
|
|
To be honest with you i wouldn't know
I guess i'm looking for some one who'd be kind enough to write me a little script that uses fsockopen if possilbe, whether it grabs it from status.xsl or status2.xsl.
In order to acheive the below (baring in mind its a part time radio station so server will only be on at certain times)
if fsockopen then display: title/artist
if fsockclosed then display: "Server Offline"
the reason i particulaly like the shoutcast code above is as it uses ajax and automatically updates on a set interval |
|
Back to top |
|
|
karlH Code Warrior
Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Thu Jun 24, 2010 4:59 pm Post subject: |
|
|
just copy the status2.xsl to another file in webroot, and edit it so the the headings are gone and just the title is sent. Then your php can then just do the fsocklopen, a single fgets and then you have the title to echo, so generally it's
fsockopen...
fputs ("GET /mytitle.xsl?mount=/mystream HTTP/1.0\r\nUser-A....");
headers = fgets (.. eg HTTP 200 OK
$title = fgets (..
echo $title
karl. |
|
Back to top |
|
|
impactdj
Joined: 06 Apr 2010 Posts: 18
|
Posted: Thu Jun 24, 2010 8:46 pm Post subject: |
|
|
do you mean something like the below?
would you mind filling in the blanks? haven't got a clue what i'm doing with this lol!
here is the location of my status3.xsl: http://undergroundsoundz.kicks-ass.net:7500/status3.xsl
index.php
Code: |
<html>
<head>
<script type="text/javascript" src="./jquery.js"></script>
<script type="text/javascript">
function updateNowPlaying(){
$.ajax({
url: "./now-playing.php",
cache: false,
success: function(html){
$("#nowPlaying").html(html);
}
});
}
updateNowPlaying();
setInterval( "updateNowPlaying()", 10000 );
</script>
</head>
<body bgcolor="#171717">
<center>
<font size="3" color="ff0000"><b>
<div id="nowPlaying"></div></b>
</font>
</center>
</body>
</html>
|
now-playing.php
Code: |
<?php
/* ----------- Server configuration ---------- */
$ip = "undergroundsoundz.kicks-ass.net";
$port = "7500";
/* ------------------------------------------- */
$fp = @fsockopen($ip,$port,$errno,$errstr,1);
if (!$fp)
{
echo "OFF AIR - Tune In At 6pm"; // Diaplays when sever is offline
}
else
{
fputs($fp, "GET /status3.xsl HTTP/1.0\r\nUser-Agent: Mozilla\r\n\r\n");
headers = fgets(
$title = fgets (
echo $title
}
?>
|
|
|
Back to top |
|
|
impactdj
Joined: 06 Apr 2010 Posts: 18
|
|
Back to top |
|
|
|