----==== problem solved with this ====----
<body bgcolor="#004200">
<center>
<h1>Random Clip</h1>
<?php
print getRandomMovie('../clips/',320,260,2);
function getRandomMovie($dir,$h,$w,$b)
{
$movie = getRandomImage($dir);
$s = '<embed src="'.$dir.$movie.'" cache="true" controller="true"';
$s .= ' width="'. $h .'" height="'. $w. '" border="'.$b.'"></embed>';
return $s;
}
function getRandomImage($dir,$type='random')
{
global $errors;
if (is_dir($dir)) {
$fd = opendir($dir);
$images = array();
while (($part = @readdir($fd)) == true) {
clearstatcache();
if ( eregi("(avi|mov|mpeg|mpg)$",$part) ) {
$images[] = $part;
}
}
// adding this in case you want to return the image array
if ($type == 'all') { return $images; }
// Be sure to call srand() once per script
srand ((double) microtime() * 1000000);
$key = rand (0,sizeof($images)-1);
return $dir . $images[$key];
} else {
$errors[] = $dir.' is not a directory';
return false;
}
}
?>
<br><b><br>refreshing this page loads another clip</b>
</center>
</body>