Go Back   The macosxhints Forums > OS X Help Requests > Applications



Reply
 
Thread Tools Rate Thread Display Modes
Old 12-14-2002, 05:51 AM   #1
der
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
der is offline   Reply With Quote
Old 12-14-2002, 06:43 AM   #2
nosaj56
Triple-A Player
 
Join Date: Jul 2002
Location: Louisiana
Posts: 208
Could you post exactly what this file says?
nosaj56 is offline   Reply With Quote
Old 12-15-2002, 08:16 PM   #3
der
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.
der is offline   Reply With Quote
Old 12-15-2002, 08:52 PM   #4
nosaj56
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.
nosaj56 is offline   Reply With Quote
Old 12-15-2002, 09:20 PM   #5
der
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
der is offline   Reply With Quote
Old 12-18-2002, 09:01 PM   #6
der
Prospect
 
Join Date: Jan 2002
Location: Hong Kong
Posts: 24
No script guys out there who can help?
der is offline   Reply With Quote
Old 12-19-2002, 05:04 AM   #7
vonleigh
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);
At this point you end up with an array ($info) that contains:

$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.
vonleigh is offline   Reply With Quote
Old 12-19-2002, 11:30 PM   #8
der
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?
der is offline   Reply With Quote
Old 12-19-2002, 11:44 PM   #9
vonleigh
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.
vonleigh is offline   Reply With Quote
Old 12-20-2002, 06:35 AM   #10
der
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
der is offline   Reply With Quote
Old 12-20-2002, 06:53 AM   #11
vonleigh
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);
If it isn't working correctly, add echo's to see if the value of the parameter is what it should be.


v
vonleigh is offline   Reply With Quote
Old 12-20-2002, 08:41 AM   #12
der
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
der is offline   Reply With Quote
Old 12-20-2002, 08:49 AM   #13
nosaj56
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."
nosaj56 is offline   Reply With Quote
Old 12-20-2002, 08:55 AM   #14
der
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....
der is offline   Reply With Quote
Old 12-20-2002, 08:56 AM   #15
nosaj56
Triple-A Player
 
Join Date: Jul 2002
Location: Louisiana
Posts: 208
Well, I guess you solved your permissions problem...
nosaj56 is offline   Reply With Quote
Old 12-20-2002, 09:11 AM   #16
der
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.
der is offline   Reply With Quote
Old 12-20-2002, 11:08 AM   #17
vonleigh
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
vonleigh is offline   Reply With Quote
Old 12-20-2002, 11:25 AM   #18
der
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
der is offline   Reply With Quote
Old 12-20-2002, 11:28 AM   #19
der
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
der is offline   Reply With Quote
Old 12-20-2002, 06:24 PM   #20
darkpaw
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
darkpaw is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 08:47 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.