Flash Video player controls revisited

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
leone
Posts: 21
Joined: Tue 19. Oct 2004, 11:30
Location: Switzerland

Flash Video player controls revisited

Post by leone »

After some more search in the web I have come to the conclusion that the only way to have player controls for flash movies (i.e. non looping videos in the .swf format) is to add some javascript and control buttons. I have tried Ibis Fernandez' approach with a flash file calling another one, but this did not work out as the videos I had produced did not play in the correct speed, i.e. somehow the speed setting in the flash video got lost due to the embedding in other flash files.

I have thus changed the section on the flash player plugin in the file to add some js script and player buttons. You need to change the following file for this to work out:

include/inc_front/content/cnt9.article.inc.php

You need to replace the existing code in the file:

Code: Select all

case 3:	//Flash Player/Plugin
											if($media["media_control"] == "true") { 
													$controls = "\n<form name='" .$randomId . "form' id='". $randomID . "form' action='#' method='get'>\n<input type='button' value='&nbsp;&nbsp;>&nbsp;&nbsp;' onclick='" . $randomID . "play();' />\n<input type='button' value='&nbsp;&nbsp;||&nbsp;&nbsp;' onclick='" .$randomID . "stop();' />\n<input type='button' value='&nbsp;|<<&nbsp;' onclick='". $randomID . "rewind();' /><br /></form>\n\n";
													$js = "\n<script>\n";
													$js .= "function " .$randomID . "play()\n";
													$js .= "{\n";
													$js .= "  if (!document.$randomID.IsPlaying())\n";
													$js .= "    document.$randomID.Play();\n";
													$js .= "}\n";
													$js .= "function " . $randomID . "stop()\n";
													$js .= "{\n";
													$js .= "  if (document.$randomID.IsPlaying())\n";
													$js .= "    document.$randomID.StopPlay();\n";
													$js .= "}\n";
													$js .= "function " . $randomID . "rewind()\n";
													$js .= "{\n";
													$js .= "  if (document.$randomID.IsPlaying())\n";
													$js .= "    document.$randomID.StopPlay();\n";
													$js .= "  document.$randomID.Rewind();\n";
													$js .= "}\n";
													$js .= "</script>\n\n";
											}

													$media["width"]  = ($media["media_width"]) ? "width=\"".$media["media_width"]."\" " : "";
													$media["height"] = ($media["media_height"]) ? "height=\"".$media["media_height"]."\" " : "";
													$media["code"]	= $js . "<OBJECT CLASSID=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" ";
													$media["code"] .= $media["width"].$media["height"]." border=\"0\" id=\"$randomID\"";
													$media["code"] .= "CODEBASE=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\">\n";
													$media["code"] .= "<PARAM name=\"movie\" VALUE=\"". $media_controller . $media["source"]."\">\n";
													$media["code"] .= "<PARAM name=\"quality\" VALUE=\"high\">\n";
													$media["code"] .= "<PARAM name=\"SCALE\" VALUE=\"noborder\">\n";
													$media["code"] .= "<PARAM name=\"LOOP\" VALUE=\"true\">\n";
													$media["code"] .= "<PARAM name=\"PLAY\" VALUE=\"".$media["media_auto"]."\">\n";
													$media["code"] .= "<EMBED SRC=\"". $media_controller . $media["source"]."\" BORDER=\"0\" ";
													$media["code"] .= $media["width"].$media["height"]." name=\"" . $randomID ."\"";
													$media["code"] .= "TYPE=\"application/x-shockwave-flash\" play=\"".$media["media_auto"]."\" ";
													$media["code"] .= "quality=\"high\" scale=\"noborder\" pluginspace=\"http://www.macromedia.com/go/getflashplayer/\"></EMBED>\n";
													$media["code"] .= "</OBJECT>\n";
													$media["code"] .= $controls;
This change creates three video type player buttons below the flash video, if "controls" is activated. This even works for several videos in the same article, as the $randomID was used to personalize each instance. If controls is not activated the flash file is displayed in the same way as before. I have tested this to work on IE and FireFox, i.e. using the <OBJECT> and the <EMBED> tags.

hope this is helpful to some of you.

regards,
Leone
Ibis Fernandez
Posts: 67
Joined: Tue 22. Jun 2004, 19:54
Contact:

Post by Ibis Fernandez »

there is no way that I know of of controlling the fps of flash natively. Although the use of streaming audio can be used to control the FPS of the flash file.

So if the loader file was created to play at 12fps and it is used to load 30fps file, then the loaded file will play at 12fps since this is the speed of the parent swf file.

You can work around this simply by making sure that at least one file in your movie is set to stream. Flash will always adhere to the requirements of propper sound playback. So if the master swf file is 12fps and it us used to load a 30fps file that contains streamin audio, in order for the audio to play back propperly, flash will force itself to play at the fps setting of the loaded file, which is 30fps.

So in your case you dont have to worry abloout adhering to the fps of my loader file, at most you just have to drop in a little silent mp3 file and set it to stream. Kind of like inserting a blank image to use as a place holder in an html file... but this will insure that the fps of your movie is not changed when ever it is loaded by another movie.
Ibis Fernandez
Cinestar Filmworks
http://flashfilmmaker.com
http://cinestarfilmworks.com
Author of Macromedia Flash Animation and Cartooning: A Creative Guide
Post Reply