Zend - The PHP Company




XML

Add Code


XML Driven Flash FLV Player  

Type: application
Added by: cortstull
Entered: 17/05/2004
Last modified: 05/12/2003
Rating: - (fewer than 3 votes)
Views: 14247
This Dynamic Flash FLV Progressive Video Player is powered by a PHP script that allows you to serve Flash FLV movies or video of any length from your website without needing Flash communications server. The FLV files are displayed using a Flash MX dropdown list which is dynamically populated by php in XML format to the player. The php script parses the working directory for any .FLV files and then generates that list in xml format which is loaded by the player.


<?   
    
static $exclude = array(
        
"." "..""player.php""counter""index.php""mwm_flmx_88_31.gif""readme.txt""abstract.php""paginate.php""ad.flv""popup.php""320x240.swf""listing_example.jpg""flv.jpg""popup.swf""iframe.php""flash_detection.swf""alternate.html""320x240.fla""popup.fla""alternate.gif"
    
);

    function 
dir_count() {
        global 
$exclude $num ;
        
$handle=opendir(".");   
        while (
$file readdir($handle)) { 
            if(
in_array($file$exclude)) continue;
            else 
$num++;
        }
        
closedir($handle); 
        return 
$num;
    } 

    
$props = array(
        
'itemsperpage'=> $items_per_page
        
'file'=>basename($_SERVER[PHP_SELF]), 
        
'delimiter'=>' <span style="font-size: 20pt; vertical-align: absmiddle;">&middot;</span> ',
        
'link_active' => 'font-weight: bold; font-family: Arial, Verdana; color: #FF0000; font-size: 12pt;',
        
'link_inactive' => 'font-weight: bold; font-family: Arial, Verdana; color: #FF0000; font-size: 12pt;'
        
);
    
$pm paginate(dir_count(),'p',$props);
    
$range $pm->get_range();

    function 
directory(&$range) {
     
        global 
$exclude$cnt 0;
        
$handle=opendir(".");   
     
    while (
$file readdir($handle)) {  
         
$fsizebyte filesize($file);
        
// Correctly parse the filesize
        
if ($fsizebyte 1000) {
            
$fsizeraw = ($fsizebyte/1000);
            
$fsizefin round($fsizeraw2);
            
$fsize $fsizefin.' <FONT COLOR=#000000>kb</FONT>';
        } 
        if (
$fsizebyte 1048576) {
            
$fsizeraw = ($fsizebyte/1048576);
            
$fsizefin round($fsizeraw2);
            
$fsize $fsizefin.' <B>mb</B>';
        }
        if (
$fsizebyte 1024) {
            
$fsize $fsizebyte.' bytes';
        }
    
        if(
in_array($file$exclude)) {
             continue;
        }
        else {
            if(
in_array($cnt$range))
                
$result .= "<li><TABLE border=0 cellspacing=0 cellpadding=0 align=center width=440><TR><TD valign="top" align="left" width="65%"><a href="player.php?url=$file&p=".(isset($_REQUEST[p])?$_REQUEST[p]:1).""><img src="flv.jpg" border="0" align="absmiddle" alt="File Name $file"></a>&nbsp;<B>Video:</B>&nbsp;<a href="player.php?url=$file&p=".(isset($_REQUEST[p])?$_REQUEST[p]:1)."">$file</a></td><TD valign="top" align="left" width="35%"><B>File Size:</B> <FONT COLOR="#FF0D0D">$fsize</FONT></td></tr></table><hr>n"; 
            
$cnt++;
        }  
     }   
    
closedir($handle);  
    return 
$result;   
}   


?>
<ol start="<?=($range[0]+1)?>">
<?   
    
echo directory($range); 
?> 
</ol>
    <?=$pm->show();?>


Usage Example


See the example


Rate This Script





Search



This Category All Categories