Auto Embed Flash Movie XHTML

This function lets you auto embed Flash movie in your PHP applications.
It will read the Height and Width size of Flash movie.

Function Input Parameters:
function VISION_TO_FLASH (

$file_name = 'default.swf', // path to your FLASH movie
$movie_id = 'vision_to_cms', // the ID of flash movie if you embed more than one on same page
$width = '250', //default width
$height = '250', //default height
$bgcolor = '#fefefe', //background color
$wmode = 'transparent', //mode default transparent
$use_bg = false, //set to true if you want to use background image
$bg_img = '',// if you want to add background image to your div
$flash_param = '' // additional movie parameters

)
The functions:
function VISION_TO_FLASH ($file_name = '', $movie_id = 'vision_to_cms', $width = '250', $height = '250', $bgcolor = '#fefefe', $wmode = 'transparent', $use_bg = false, $bg_img = '',$flash_param = '')
{
// Copyright by www.vision.to
// Author: Femi Hasani
// please leave credits above for free use.

if (file_exists($file_name))
{
if ($width == 250 && $height == 250)
{

@list($width, $height, $type, $attr) = getimagesize($file_name);
//$height= $height+40;
}
$width2 = $width . "px";
$height2 = $height . "px";
$flash_movie = "";
$flash_movie .= "<div class=\"flash-movie\">";
if ($use_bg == true) {
$flash_movie .= "<div style=\"width:$width2;height:$height2;padding:1px;background:url($bg_img) no-repeat transparent;margin: 0 auto;\" >\n";
}
$flash_movie .= " \n<object type=\"application/x-shockwave-flash\" data=\"$file_name$flash_param\" width=\"$width\" height=\"$height\" id=\"$movie_id\" >\n";
$flash_movie .= " <param name=\"allowScriptAccess\" value=\"sameDomain\" />\n";
$flash_movie .= " <param name=\"movie\" value=\"$file_name$flash_param\" />\n";
$flash_movie .= " <param name=\"quality\" value=\"high\" />\n";
$flash_movie .= " <param name=\"bgcolor\" value=\"$bgcolor\" />\n";
$flash_movie .= " <param name=\"wmode\" value=\"$wmode\" />\n";
$flash_movie .= "<a href=\"http://www.adobe.com/go/getflashplayer\" title=\"Get Flash Player\" >Get Flash Player</a>";
$flash_movie .= "</object>\n";
if ($use_bg == true) {
$flash_movie .= "</div>\n";
}
$flash_movie .= "</div>\n";

return $flash_movie;
} else {
return " Vision.To CMS :Error :Flash Movie: " . $file_name . " Not Found! ";
}

}

// =======================================================================================================
// part of VISION_TO_DISPLAY Class
//
// =======================================================================================================
function VISION_TO_FLASH_JS ($file_name = '../media/website.swf', $width = '250', $height = '250', $movie_id='vision_to_accordion', $bgcolor = '#fefefe', $wmode = 'transparent', $use_bg = false, $bg_img = '',$flash_param = '',$so = "feha")
{
// Copyright by www.vision.to
// Author: Femi Hasani
// please leave credits above for free use.

if (file_exists($file_name))
{
if ($width == 250 && $height == 250)
{

@list($width, $height, $type, $attr) = getimagesize($file_name);
//$height= $height+40;
}
$width2 = $width . "px";
$height2 = $height . "px";
$flash_movie = "";
$flash_movie .="<!-- generated by PHP VISION_TO_DISPLAY Class of www.vision.to -->\n";
$flash_movie .= "<div class=\"flash-movie\">\n";
if ($use_bg == true) {
$flash_movie .= "<div style=\"width:$width2;height:$height2;padding:1px;background:url($bg_img) no-repeat transparent;margin: 0 auto;\" >\n";
}
$flash_movie .= "<div id=\"$movie_id\">\n";
// $flash_movie .= "<div class=\"no_falsh\">Your browser does not have Latest Version of Flash Player installed. <a href=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" title=\"Download FP\" rel=\"nofollow\">Click here to download</a> the latest version of the Flash Player. If you believe this is an error, <a href=\"".$_SERVER['SCRIPT_NAME']."?detectflash=false\" title=\"Bypass detection\">click here to bypass detection</a>.</div>\n";
$flash_movie .= "</div>\n";
$flash_movie .= "<script type=\"text/javascript\">\n";
$flash_movie .= "// <![CDATA[ \n";
$flash_movie .= "var ".$so." = new FlashObject(\"$file_name$flash_param\", \"$movie_id\", \"$width\", \"$height\", 7, \"$bgcolor\");\n";

if($wmode)
{
$flash_movie .= $so.".addParam(\"wmode\", \"$wmode\");\n";
}
$flash_movie .= $so.".addParam(\"allowFullScreen\",\"true\");\n";
$flash_movie .= $so.".write(\"$movie_id\");\n";
$flash_movie .= " // ]]> \n";
$flash_movie .= "</script>\n";
if ($use_bg == true) {
$flash_movie .= "</div>\n";

}
$flash_movie .= "</div>\n";

return $flash_movie;
} else {
return "<!-- Flash Movie Not Found! -->";
}

}

This can be useful if you have many file names in your DB and want to create a Flash Movies Gallery or You get tired of writing XHTML for each of your movie you want to embed.


Misc Links, Resources

Upperhost best web hosting

Hobby Projects

BOW.TO:Webmaster Marketplace

Recommended

Link Partners

Web Design Forum