|
|
#1 |
|
Prospect
Join Date: Jan 2002
Location: Hong Kong
Posts: 24
|
QT SS current track on web page?
Could anyone suggest an easy way to display the currently playing track name, album and artist from my QT streaming Server on my web page in a nice way?
I know all the information is stored in the playlist.current file but I'm not smart enough to figure out a way to display it on my web page. - I don't just want to list the path - I know there is a nice way of doing this for iTunes. Can anyone give me some ideas or hints? Thanks
|
|
|
|
|
|
#2 |
|
Triple-A Player
Join Date: Jul 2002
Location: Louisiana
Posts: 208
|
Could you post exactly what this file says?
|
|
|
|
|
|
#3 |
|
Prospect
Join Date: Jan 2002
Location: Hong Kong
Posts: 24
|
Example playlist.current file
The contents of the file is just the following -
u=/Users/Shared/Various Artists/Back To Mine (mixed by Nick Warren)/02 Talismantra - Warmth Reheated.mp3 Which is just the path to the currently playing track. This path info includes the artist name (Various Artists in this case), Album name (Back To Mine (mixed by Nick Warren)) and track name (02 Talismantra - Warmth Reheated.mp3) What I want to do is be able to break this info up and display it dynamically (or at least refresh it at fairly short time intervals) on my web page so people can know what they are listening to. |
|
|
|
|
|
#4 |
|
Triple-A Player
Join Date: Jul 2002
Location: Louisiana
Posts: 208
|
I don't know how to do this. Maybe someone could write a shell script that reads that file and writes the track name and artist to a php file. Then (if you have PHP) you could use a php include to put that on any webpage. You could make that shell script a cron job.
I don't have any shell script experience. Just thinking out loud here. |
|
|
|
|
|
#5 |
|
Prospect
Join Date: Jan 2002
Location: Hong Kong
Posts: 24
|
Yeah, I guess that is the best way although I don't know much about PHP either.
Thanks anyway Der |
|
|
|
|
|
#6 |
|
Prospect
Join Date: Jan 2002
Location: Hong Kong
Posts: 24
|
No script guys out there who can help?
|
|
|
|
|
|
#7 |
|
All Star
Join Date: Jan 2002
Posts: 579
|
Hello,
You don't have to use a shell script, you can just do it using PHP. It would look something like: Code:
<?php
// Read playlist.current into $file
$file = fopen("/path/to/playlist.current", "r");
// Separate into parts and put in $info array
$info = explode("/",$file);
// Make sure to close after you open
fclose($file);
$info[0] = Users $info[1] = Shared $info[2] = Various Artists...[/code] etc. (i'm assuming from your example file) If the path is always the same (as in they're all contained in "/Users/Shared" and all the songs are organized in "/Album/Artist/Song". Then you can assume and just do something like: Code:
echo "Current song playing is: $info[4]/n"; echo "by $info[3]."; ?> hth, v Disclaimer: typed in browser, haven't tested. |
|
|
|
|
|
#8 |
|
Prospect
Join Date: Jan 2002
Location: Hong Kong
Posts: 24
|
Is there any simpler way of doing it? I don't know anything about PHP or programming.
Is installing and learning PHP going to be a really big job?
|
|
|
|
|
|
#9 |
|
All Star
Join Date: Jan 2002
Posts: 579
|
Nah, Installing PHP is really simple if you follow the instructions on Mark Liyanage's page:
http://www.entropy.ch/software/macosx/php/ Then just paste in my script and adjust to taste. v edit: you do have to use some sort of scripting language for what you want regardless, be it perl, php, etc... I think php is the easiest for what you want to do. |
|
|
|
|
|
#10 |
|
Prospect
Join Date: Jan 2002
Location: Hong Kong
Posts: 24
|
Thanks - I've almost got it working - PHP is up and running but I cant quite get it working right.
I think it might be a problem with the fopen command - if I replace the fopen bit with just the text of my .current file then it works perfectly but when it tries to read the same text from the file it doesn't work. I'm not sure if it is to do with directory permissions or something like that. Can you guys help me out just a little bit more? Thanks
|
|
|
|
|
|
#11 |
|
All Star
Join Date: Jan 2002
Posts: 579
|
Hello,
My bad, you should read the text after you open it, so adjust as follows: (btw, next time add an echo somewhere to test that the values are what they should be, in this case "echo $file;") Code:
// Define your path of your playlist.current
$path = "/path/to/playlist.current";
// Open playlist and reference it with $file
$file = fopen($path, "r");
// Read the contents playlist.current into $content
$content = fread ($file, filesize($path));
// Separate into parts and put in $info array
$info = explode("/",$content);
// Make sure to close after you open
fclose($file);
v |
|
|
|
|
|
#12 |
|
Prospect
Join Date: Jan 2002
Location: Hong Kong
Posts: 24
|
Thanks vonleigh - Almost there!
If I copy the playlist.current file into the same folder as my web pages and the .php file it works great. When I point the path to the original playlist.current file location I get a problem with file permisions Warning: fopen("/library/quicktimestreaming/playlists/playlist/playlist.current", "r") - Permission denied in /Library/WebServer/Documents/trackinfo.php on line 7 How do I change the file permissions? I think it might be to do with the php.ini file but I can't even find it! Thanks again for all your help |
|
|
|
|
|
#13 |
|
Triple-A Player
Join Date: Jul 2002
Location: Louisiana
Posts: 208
|
php.ini location
For the permissions problem, go to that place in the Finder, hold down COMMAND-I (Apple logo on the keyboard and I.), click the "Ownership & Permissions arrow", put the "others" group as "Read-only" or if that doesn't work, "Read & Write." |
|
|
|
|
|
#14 |
|
Prospect
Join Date: Jan 2002
Location: Hong Kong
Posts: 24
|
For anyone interested here is the code as its looking so far (thanks to Von).
<?php // Define path to playlist.current $path = "/library/quicktimestreaming/playlists/eclectasy/eclectasy.current"; // Read playlist.current into $file $file = fopen($path, "r"); // Read the contents of $file into $content $content = fread ($file, filesize($path)); // Separate into parts and put in $info array $info = explode("/",$content); // Make sure to close after you open fclose($file); // Print the information echo "Current song playing is $info[5]"; echo " by $info[3]."; ?> Now if I could just get rid of the .mp3 from the track name in the output. I think it should be something like: //$content = preg_replace ("mp3.", "/", $content); but it doesn't seem to work right just yet.... |
|
|
|
|
|
#15 |
|
Triple-A Player
Join Date: Jul 2002
Location: Louisiana
Posts: 208
|
Well, I guess you solved your permissions problem...
|
|
|
|
|
|
#16 |
|
Prospect
Join Date: Jan 2002
Location: Hong Kong
Posts: 24
|
No - the permission problem remains - I think it's something to do with php having permission to access files in that directory. If I move the file into the web directory then it works fine but it wont work when the .current file is in the right directory.
|
|
|
|
|
|
#17 |
|
All Star
Join Date: Jan 2002
Posts: 579
|
Hello,
To solve your permission problem, one idea is to make a symlink of the file, say something like: ln -s /path/to/original /path/to/web/documents And see if that gets around your permissions problem. And to get rid of the .mp3, you could do this: $song = substr($info[5], 0, -4); And replace in the last echo the $info[5] for $song v |
|
|
|
|
|
#18 |
|
Prospect
Join Date: Jan 2002
Location: Hong Kong
Posts: 24
|
Hi
I tried the sym link but it doesn't work. Looks like I need to give php permission to access my quicktime streaming directory but I'm still clueless as to how. I'll try to fix up the mp3 tags in the morning but for now I gotta get some sleep Cheers guys |
|
|
|
|
|
#19 |
|
Prospect
Join Date: Jan 2002
Location: Hong Kong
Posts: 24
|
BTW - here's the errors I get:
Warning: fopen("/library/webserver/documents/eclectasy.current", "r") - Permission denied in /Library/WebServer/Documents/trackinfo.php on line 7 Warning: stat failed for /library/webserver/documents/eclectasy.current (errno=13 - Permission denied) in /Library/WebServer/Documents/trackinfo.php on line 10 Warning: Supplied argument is not a valid File-Handle resource in /Library/WebServer/Documents/trackinfo.php on line 10 Warning: Supplied argument is not a valid File-Handle resource in /Library/WebServer/Documents/trackinfo.php on line 19 |
|
|
|
|
|
#20 |
|
All Star
Join Date: Apr 2002
Location: England
Posts: 513
|
I know this probably won't help you at all, but I just tried everything mentioned above, plus I also moved the playlist file to various places around the system, and it worked fine every time. I had no permissions problems at all
|
|
|
|
![]() |
|
|