AUTOMATICALLY PUBLISH THE CORRECT CODE TO PLAY VARIOUS TYPES OF FLASH FILES - Aug 3rd, 2010


Einslistir wanted to know how to automatically publish the appropriate code for playing various flash and other media
files. Dave Edis, from Interactive tools offered.

When you generate a page viewer, the regular upload display code looks something like this. I've added some code in red.
(dougdrury added the code in blue to expand the options. See his note at the end of this entry) There’s also an mp3
option (with an orange background) below that.

FOR A LIST VIEWER



<!-- Display Uploads for field 'your_upload_field' (Paste this anywhere inside STEP2 to display uploads) -->

<?php foreach ($your_tableRecords as $record): ?> <?php foreach ($record['your_upload_field'] as $upload): ?>

<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo
$upload['thumbHeight'] ?>" /><br />

<?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo
$upload['height'] ?>" /><br />

<?php elseif ($upload['extension'] == 'swf'): ?>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="350"
height="220">
<param name="movie" value="<?php echo $upload['urlPath'] ?>">
<param name="quality" value="high">
<embed src="<?php echo $upload['urlPath'] ?>" quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="350" height="220"></embed>
</object>

<?php elseif ($upload['extension'] == 'wmv'): ?>
<object classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" width="320" height="290">
<param name="FileName" value="<?php echo $upload['urlPath'] ?>">
<param name="AutoStart" value="True">
<param name="ShowControls" value="True">
<param name="ShowStatusBar" value="False">
<param name="ShowDisplay" value="False">
<param name="AutoRewind" value="True">
<embed type="application/x-mplayer2"
pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/"
autostart="True" filename="<?php echo $upload['urlPath'] ?>"
src="<?php echo $upload['urlPath'] ?>"
width="320" height="290" showcontrols="True" showstatusbar="False" showdisplay="False" autorewind="True">
</embed>
</object>

<?php elseif ($upload['extension'] == 'flv'):
$fileURL=$upload['urlPath'];
?>
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
WIDTH="320" HEIGHT="240" id="myMovieName"><PARAM NAME=movie VALUE="player.swf">
<PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF>
<PARAM NAME=flashvars VALUE=movie=<?=$fileURL?>>
<EMBED src="player.swf?movie=<?=$fileURL?>" quality=high bgcolor=#FFFFFF WIDTH="320" HEIGHT="240"
NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>
<?php elseif ($upload['extension'] == 'mp3'):
$fileURL=$upload['urlPath'];
?>
<object width="300" height="42">
<param name="src" value="<?php echo $upload['urlPath'] ?>">
<param name="autoplay" value="false">
<param name="controller" value="true">
<param name="bgcolor" value="#FF9900">
<embed src="<?php echo $upload['urlPath'] ?>" autostart="false" loop="false" width="300" height="42"
controller="true" bgcolor="#FF9900"></embed>
</object>

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br />

<?php endif ?>
<?php endforeach ?> <?php endforeach ?>



FOR A DETAIL VIEWER

Just replace the first 2 lines of code:



<?php foreach ($your_tableRecords as $record): ?> <?php foreach ($record['your_upload_field'] as $upload): ?>



with:



<?php foreach ($your_tableRecord['your_upload_field'] as $upload): ?>



(And don’t forget to remove one of the <?php endforeach ?> lines at the end.)

Note: To play flv files you’ll have to have an flv player stored on your site. An open source flv player is available
here,

http://www.osflv.com/

dougdrury says: It seems a bit old (since it is saying codebase 6,0,40...) but whatever the latest version you have
loaded on you machine will run anyways, or you could write your own.

If you want to use other types of media files, like .mov, just do a Google search for mov+embed+code and you’ll find
what you need.



The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service