|
|
#1 |
|
Junior Member
Join Date: Mar 2003
Location: Baytown,Tx
Posts: 49
|
php script for showing current song?
I'm looking for a php script that will scroll the current song/artist on my main site. I've seen it here before, but I've lost the link!
|
|
|
|
|
|
#2 |
|
Alumni
Join Date: Sep 2001
Location: Maui, Hawaii
Posts: 14,108
|
Check out the Sticky post titled...
SHOUTcast: Important Info & Answers to FAQs. READ ME! Scroll down a bit and look for the section titled... General SHOUTcast Information -> SHOUTcast ToolBox (All sorts of nifty add-ons for SHOUTcast) 1. The PHP based XML parser is a complete solution and comes ready for you to customize. 2. The Javascript parser (actually ASP) is another complete solution and comes ready for you to customize. Note: Apparently this link isn't working anymore. Try this thread for other ASP options. Also, for an html implementation, check out: KXRM's RadioToolbox Oddsock's Do Something DSP plugin |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Mar 2003
Location: Baytown,Tx
Posts: 49
|
Hmmm. Tried that script, but even though I'm running my own server w php 4.3.2 it won't do anything.
It just has a blank space on the page where I put the code... |
|
|
|
|
|
#4 |
|
Junior Member
Join Date: Jul 2003
Posts: 19
|
<?php
/////////////////////////////////////////// // Author: Radu Bighiu - radu@webcast.ro // /////////////////////////////////////////// //edit below $host = "webcast.ro"; $port = "8000"; //stop editing from here $fp=fsockopen($host,$port,&$errno,&$errstr,10); if (!$fp) { echo "Can't connect"; } fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:WEBcast Mozilla - www.webcast.ro\n\n"); for($i=0; $i<30; $i++) { if(feof($fp)) break; $fp_data=fread($fp,31337); usleep(500000); } $fp_data=ereg_replace("^.*<body>","",$fp_data); $fp_data=ereg_replace("</body>.*","",$fp_data); list($current,$status,$peak,$max,$reported,$bit,$song) = explode(",", $fp_data); if ($status == "0") { echo "<center>Off Air</center>"; } else { echo "<TABLE>"; //edit below - comment with "//" unnecessary lines echo "<TR><TD>Current Listeners: </TD><TD>".$current."</TD></TR>"; //echo "<TR><TD>Server Status: </TD><TD>".$status."</TD></TR>"; echo "<TR><TD>Listener Peak: </TD><TD>".$peak."</TD></TR>"; echo "<TR><TD>Supported Listeners: </TD><TD>".$max."</TD></TR>"; echo "<TR><TD>Unique Listeners: </TD><TD>".$reported."</TD></TR>"; echo "<TR><TD>Stream Bitrate: </TD><TD>".$bit." kbps</TD></TR>"; echo "<TR><TD>Current Song: </TD><TD>".$song."</TD></TR>"; //stop editing from here echo "</TABLE>"; } ?> |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Jul 2003
Posts: 19
|
PHP Code:
|
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Mar 2003
Location: Baytown,Tx
Posts: 49
|
Thanks! Looks like that did it. Is there a line of code I can put in to make it scroll? I tried the old HTML <marquee> code, but it didn't want to scroll
![]() I'm fairly new to php, but learning fast! |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: Jul 2003
Posts: 20
|
i'm also running php v.4.3.2 and i've modified my script (the host and port) and this is what i get http://psykad.sytes.net:8000/dnas.php
what am i doing wrong? |
|
|
|
|
|
#8 | |
|
Junior Member
Join Date: Mar 2003
Location: Baytown,Tx
Posts: 49
|
Quote:
|
|
|
|
|
|
|
#9 |
|
Junior Member
Join Date: Jul 2003
Posts: 19
|
other php script is working good with Sambar Server?
try set allow_call_time_pass_reference to true in your PHP.INI file |
|
|
|
|
|
#10 | |
|
Junior Member
Join Date: Jul 2003
Posts: 19
|
Quote:
PHP Code:
PHP Code:
|
|
|
|
|
|
|
#11 |
|
Junior Member
Join Date: Jul 2003
Posts: 20
|
lol here's what i have right now:PHP Code:
Notice: Undefined offset: 6 in C:\SAMBAR52\docs\dnas.php on line 23 Notice: Undefined offset: 5 in C:\SAMBAR52\docs\dnas.php on line 23 Notice: Undefined offset: 4 in C:\SAMBAR52\docs\dnas.php on line 23 Notice: Undefined offset: 3 in C:\SAMBAR52\docs\dnas.php on line 23 Notice: Undefined offset: 2 in C:\SAMBAR52\docs\dnas.php on line 23 Notice: Undefined offset: 1 in C:\SAMBAR52\docs\dnas.php on line 23 so it's all coming from one line. i don't much php, just enough to communicate with mysql. i don't know what the offset is or means. anyone see what the problem is? |
|
|
|
|
|
#12 |
|
Junior Member
Join Date: Mar 2003
Location: Baytown,Tx
Posts: 49
|
Thanks Webcast! That did the trick!
|
|
|
|
|
|
#13 | |
|
Junior Member
Join Date: Jul 2003
Posts: 19
|
Quote:
but let my code alone... edit, please edit onlyPHP Code:
copy my PHP code again and replace only $host & $port |
|
|
|
|
|
|
#14 |
|
Moderator Alumni
Join Date: May 2000
Location: Next Door
Posts: 8,942
|
Just a note on the code above is that each time a listener or webpage viewer executes it they make a request from your shoutcast server, if you have heavy traffic to your site I would not use this code without at least modifing it to properly cache results as to not hammer your server into the ground.
The shoutcast server can only handle one connection to the webadmin at any given time, otherwise it gives you a flood warning. -Jay | Radio Toolbox.com |
|
|
|
|
|
#15 |
|
Junior Member
Join Date: Jul 2003
Posts: 19
|
My code uses "7.html" not XML from "admin.cgi", are you sure about this flood warning?
|
|
|
|
|
|
#16 |
|
Moderator Alumni
Join Date: May 2000
Location: Next Door
Posts: 8,942
|
it still makes a connection. regardless of what it requests from the server. By the way, why do you have HTML in your User-Agent field, this makes no sense. Plus it goes against the standard.
-Jay | Radio Toolbox.com |
|
|
|
|
|
#17 | |
|
Junior Member
Join Date: Mar 2003
Location: Baytown,Tx
Posts: 49
|
Quote:
|
|
|
|
|
|
|
#18 |
|
Got his CT back
and didn't pay $10 (Forum King) Join Date: Aug 2002
Location: Phoenix, AZ
Posts: 3,583
|
Nice script! Too bad it doesn't work in sigs... Hey festerhead, which script do you use?
This is a sig of some nature. |
|
|
|
|
|
#19 |
|
Junior Member
Join Date: Jul 2003
Posts: 20
|
WEBcast, you say to only edit the host and port...but there's an error in the code where your site is listed.
PHP Code:
PHP Code:
are you the writer of this code? |
|
|
|
|
|
#20 |
|
Alumni
Join Date: Sep 2001
Location: Maui, Hawaii
Posts: 14,108
|
|
|
|
|
|
|
#21 |
|
Junior Member
Join Date: Jul 2003
Posts: 20
|
final words
well it seems as if this code isn't going to work for my application. i guess i'll write my own script to do it. when i finish i will post it. thanks for your guys help
|
|
|
|
|
|
#22 | |
|
Junior Member
Join Date: Mar 2003
Location: Baytown,Tx
Posts: 49
|
Quote:
The only way to apply that fix IS to edit below the "Do not edit below this" line... I'm confused... |
|
|
|
|
|
|
#23 |
|
Junior Member
Join Date: Jul 2003
Posts: 20
|
i finished my code. it works for me now.
PHP Code:
![]() |
|
|
|
|
|
#24 |
|
Moderator Alumni
Join Date: May 2000
Location: Next Door
Posts: 8,942
|
I wouldn't use images like that, your server each time a user makes a request on the script your server will have to render an image, so it won't take long to really start causing havoc. I would cache that image and make a cron do the work of executing the code to save on CPU and Overall Server Load.
-Jay | Radio Toolbox.com |
|
|
|
|
|
#25 |
|
Junior Member
Join Date: Jul 2003
Posts: 20
|
i have two servers. one running the dnas server and the other running sambar. the only load the dnas server will get is what you mentioned above about bandwidth. but this caching of the picture interests me. anywhere you can direct me to a thread or site for help on it?
|
|
|
|
|
|
#26 |
|
Moderator Alumni
Join Date: May 2000
Location: Next Door
Posts: 8,942
|
yea I was talking about the webserver itself not shoutcast, it will not take many connections before your webserver starts getting bogged down trying to render an image.
Visit php.net and lookup the function ImageJpeg You can force the image be saved to the hard disk using the optional Filename string parameter, rather then displayed. -Jay | Radio Toolbox.com |
|
|
|
|
|
#27 |
|
Junior Member
Join Date: Jul 2003
Posts: 19
|
THIS IS MY CODE please read more careful all the posts and see what is mine.
The Problem with link in UserAgent is from vBulletin automaticly make something like www.webcast.ro in to a web link. This Script is tested with Windows+IIS+PHP v5.0.0b1 and RedHat9+Apache+PHP v4.2.2 and is working. When editing this script fallow "//start edit..." & "//stop edit..." use Notepade or a plain text editor This script is designed for a small network not for heavy trafic If you have problems with my script send me a email at radu@webcast.ro or Private Message See this script working here: http://radio.webcast.ro/tools/7.php PHP Code:
|
|
|
|
|
|
#28 |
|
Moderator Alumni
Join Date: May 2000
Location: Next Door
Posts: 8,942
|
your code has a flaw, remove the HTML from the User-Agent area, and change the protocal version to 1.0, and use proper linefeeds so
code: reads as code: -Jay | Radio Toolbox.com |
|
|
|
|
|
#29 |
|
Junior Member
|
Here is my phpinfo: http://www.eccentricbeats.com/phpinfo.php
Here is my code: <?php /////////////////////////////////////////// // Author: Radu Bighiu - radu@webcast.ro // /////////////////////////////////////////// //start edit below $host = "24.118.66.43"; $port = "8000"; //stop editing from here $fp=fsockopen($host,$port,&$errno,&$errstr,10); if (!$fp) { echo "Can't connect"; } fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:WEBcast Media Mozilla\n\n"); for($i=0; $i<30; $i++) { if(feof($fp)) break; $fp_data=fread($fp,31337); usleep(500000); } $fp_data=ereg_replace("^.*<body>","",$fp_data); $fp_data=ereg_replace("</body>.*","",$fp_data); list($current,$status,$peak,$max,$unique,$bitrate,$song) = explode(",", $fp_data); if ($status == "0") { echo "<center>Off Air</center>"; } else { echo "<TABLE>"; //start edit below - comment with "//" unnecessary lines echo "<TR><TD>Current Listeners: </TD><TD>".$current."</TD></TR>"; //echo "<TR><TD>Server Status: </TD><TD>".$status."</TD></TR>"; echo "<TR><TD>Listener Peak: </TD><TD>".$peak."</TD></TR>"; echo "<TR><TD>Supported Listeners: </TD><TD>".$max."</TD></TR>"; echo "<TR><TD>Unique Listeners: </TD><TD>".$unique."</TD></TR>"; echo "<TR><TD>Stream Bitrate: </TD><TD>".$bitrate." kbps</TD></TR>"; echo "<TR><TD>Current Song: </TD><TD>".$song."</TD></TR>"; //stop editing from here echo "</TABLE>"; //start edit below - comment with "//" next line to stop scrolling echo "<marquee>".$song."</marquee>"; //stop editing here } ?> Here is what my output looks like: Can't connect Warning: fputs(): supplied argument is not a valid File-Handle resource in /home/eccentricbeats.com/httpdocs/playingnow.php on line 15 Warning: feof(): supplied argument is not a valid File-Handle resource in /home/eccentricbeats.com/httpdocs/playingnow.php on line 17 Warning: fread(): supplied argument is not a valid File-Handle resource in /home/eccentricbeats.com/httpdocs/playingnow.php on line 18 It keeps going and going from there....... |
|
|
|
|
|
#30 | |
|
Junior Member
Join Date: Jul 2003
Posts: 19
|
Quote:
|
|
|
|
|
|
|
#31 |
|
Junior Member
|
I turned off the server because I wasn't running it, I still have probelms with the script even after turning the server on, please check your email that I sent.
|
|
|
|
|
|
#32 | |
|
Member
|
Quote:
ya... -L"k" |
|
|
|
|
|
|
#33 |
|
Moderator Alumni
Join Date: May 2000
Location: Next Door
Posts: 8,942
|
ah come on that's one function call and a if statment, jeepers. I wouldn't hold that against someone if they took one function call and an if statement from my scripts.
-Jay | Radio Toolbox.com |
|
|
|
|
|
#34 | |
|
Member
|
Quote:
put your own comments in changed the User Agent and some of the output HTML (which an end user would do anyways) .... |
|
|
|
|
|
|
#35 |
|
Junior Member
Join Date: Jun 2003
Posts: 11
|
Why are you doing a lot heavy calls to the shout server?
My application MP3 Tunes v2 can stream the "Artist - Title" to a shoutserver AND webpage for example it does a call to: track.php?artist= then that php saves the info to a file/database then put a call in your index.php (or something) to read database/file this way you won't have to call shout server. See it in action on http://www.radiogetswild.com when a DJ is playing info will be shown in top-right. http://www.mp3tunes.nl the way music playin should be. |
|
|
|
|
|
#36 |
|
Junior Member
|
Why bother with some complicated scripts??
All I did was install "RadioToolBox", did a little html editing and "voila!". Nice and neat, check it out. http://g3d.mine.nu |
|
|
|
|
|
#37 |
|
Junior Member
|
DOH!
I've just noticed when the last msgs were posted on.. Ancient History, silly me.
|
|
|
|
|
|
#38 |
|
Junior Member
Join Date: Oct 2009
Posts: 1
|
how do i see this?
i can't see the message
|
|
|
|
|
|
#39 |
|
Junior Member
Join Date: Apr 2010
Posts: 1
|
Only works at localhost
Hey guys, i got a little problem, testing scripts like those you posted here, they only works at my localhost, when i upload them to my web host they never get the streaming info, they always show server disconnected, like if i wasnt broadcasting, but i tested in my localhost and the script worked nice, i already CHMOD the folder of the script but still doesnt work, any other solutions?
Thanks |
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|