Thread: PHP Help
View Single Post
Old 04-08-2008   #1 (permalink)
pbcmedia
NewYork
 
pbcmedia's Avatar
 
Join Date: Mar 2007
Location: bk, ny
Posts: 21

Send a message via AIM to pbcmedia
Angry PHP Help

HELP.... im trying to do a random track playing playlist for this site that im doing and im having serious trouble with this php code....im getting an error when i test it saying theres something undefined in line 3...... all my mp3 tracks are on the server and so is the playlist(all in the same folder)... does any1 on here know programming to the point where u might be able to figure this out, can u atleast point me n the right direction??? PLEASE HELP ME



<?php
$playlist = "c:\sites\single39\holloywood\webroot\gudlyfeplayl ist.m3u";
if ($_SERVER['PATH_INFO'] == "gudlyfeplaylist.m3u") {
# This a request for the actual playlist.
playlist();
} else {
# Fall through to end of script and display
# the player HTML.
}
function playlist() {
header("Content-type: audio/mpeg");

# Needed for PHP versions OLDER than 4.2.0 only.
# If your host still has PHP older than 4.2.0, shame on them.
# Find a better web host.
srand(make_seed());

# Fetch our list of songs from a file.
$songs = file($playlist);
shuffle($songs);
# Now output the URLs in random order.
foreach ($songs as $song) {
# Remove newline and any other leading and trailing
# whitespace from URL of song.
$song = trim($song);
echo "$song\n";
}
# Now exit before any HTML is produced.
exit(0);
}
# Needed only for very old versions of PHP,
# see srand call earlier.
function make_seed()
{
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
?>

<html>
<head>
<title>MP3s Playing in Random Order</title>
</head>
<body>
<h1 align="center">MP3s Playing in Random Order</h1>
<embed src="c:\sites\single39\holloywood\webroot\gudlyfep laylist.m3u"
width="200"
height="25"
autostart="true"
type="audio/mpeg"
loop="true"/>
</body>
</html>
pbcmedia is offline   Reply With Quote