Here's what we've come up with for a clip of the day.
First off the Player calls an xml playlist. I have created the following php file to dynamically create the xml and feed it to the player to come up with the clip of the day.
PHP Code:
<?
header ("content-type: text/xml");
$results = array();
$directory = "./media/"; //Directory to search
$handler = opendir($directory);
while ($file = readdir($handler)) {
if ($file != '.' && $file != '..' && !is_dir($file)) $results[] = $file;
}
closedir($handler);
// the above reads files into an array
$count = count($results); // gets number of files in array
$now = getdate(); // get timestamp
$day = $now['yday']; // gets day of the year;
$file = $day%$count; // takes day of year, divides by number of files and returns the left over..
$fileToServe = $results[$file]; // serve file left over..
$fileName = explode(".", $fileToServe);
?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<trackList>
<track>
<title><?=$fileName[0]?></title>
<location>ENTER DIRECTORY LOCATION HERE<?=$fileToServe?></location>
</track>
</trackList>
</playlist>
Let me know what you guys think! You can check out the working version on http://www.myownwoody.com see the 'Clip of the day' on the left column.
Thanks,
- Woody
Bookmarks