Some folks have been asking lately about how we display the media on the the home page of ourmedia.org. Here is the file that does that. It is just a PHP script, not even Drupal specific (although we keep it in our theme). I am working to replace this with the emfield module. The main value of this old code is that it contains embed information for quite a few types, all in one example.
Many people have contributed to this file over the past few years, not the least of which is Michael Sullivan of http://vlogdir.com. We owe him many thanks for getting this off the ground.
A call to this services might look like this:
<iframe id="featuredVideo" border="2" bordercolor="#fff" frameborder="0" scrolling="no"
src="sites/www.ourmedia.org/themes/ourmedia-downes/featured_video.php
?video=http%3A%2F%2Fwww.archive.org%2Fdownload%2F
GeorgetePereiraCrossingtheTocantinsRiver%2FRioTocantinsByGeorgete.flv
&bigscreenshot=http%3A%2F%2Fchannels.ourmedia.org%2Ffiles%2Ftocantins-dimensions.jpg
¬es=Found+on+Ourmedia&width=642&height=478&autostart=false" width="642" height="478"></iframe>
The parameters should be self-explanatory. Note that the urls should be encoded.
One of the advantages of emfield is that we can avoid the use of an IFRAME element, which is better for sizing and style control.
Note that this is separate from the thumbnail slider code. This is just the display of an image which is replaced by an embeded media object when clicked.
<?php
function display() {
$mediaURL = urldecode($_GET['video']);
$screenshotURL = urldecode($_GET['bigscreenshot']);
$extension = '';
$parts = split('\.', $mediaURL);
if (count($parts) > 1)
$extension = end($parts);
if (!$extension && count($parts) > 2)
$extension = prev($parts);
$extension = strtolower($extension);
$height = ($_GET['height']);
$width = ($_GET['width']);
$autostart = ($_GET['autostart']);
$notes = urldecode($_GET['notes']);
if (strlen($mediaURL) > 0) {
if (($extension == "jpg") || ($extension == "jpeg") || ($extension == "gif") || ($extension == "png") || ($extension == "tiff") || ($extension == "bmp") || ($extension == "svg")) {
$output = "<p align=\"center\"><img border=\"0\" src=\"$mediaURL\" ></p>";
} else {
if ((strlen($screenshotURL) > 0) && ($autostart == 'false')) {
$mediaURL = "featured_video.php?video=" . $_GET['video'] . "&bigscreenshot=" . $_GET['bigscreenshot'] . "¬es=" . $_GET['notes'] . "&height=$height&width=$width&autostart=true";
$output = "<p align=\"center\"><a href=\"$mediaURL\" target=\"_self\"><img border=\"0\" src=\"$screenshotURL\" ></a></p>";
} else
$output = displayMedia($mediaURL, $extension, $height, $width, $autostart);
}
} else {
if ((strlen($screenshotURL) > 0) && (strpos($notes, $screenshotURL)===false))
$output = "<p align=\"center\"><img border=\"0\" src=\"$screenshotURL\" ></p>";
}
if (strlen($notes) > 0)
$output .= "<div id=\"medianotes\">$notes</div>";
return $output;
}
function
displayMedia($mediaURL, $extension, $height, $width, $autostart) {
if ((
$extension == "mov") || ($extension == "mp4") || ($extension == "m4v")) {
if (strlen($height)==0)
$height = "260";
if (strlen($width)==0)
$width = "320";
if (strlen($autostart)==0)
$autostart = "true";
$output = "<embed PLUGINSPAGE=\"http://www.apple.com/quicktime/download/\" src=\"players/QT.mov\" QTSRC=\"$mediaURL\" width=\"$width\" height=\"$height\" autoplay=\"$autostart\" controller=\"true\" enablejavascript=\"true\"></embed>";
return $output;
}
if ($extension == "avi") {
if (strlen($height)==0)
$height = "260";
if (strlen($width)==0)
$width = "320";
if (strlen($autostart)==0)
$autostart = "true";
$output = "<EMBED type=\"application/x-mplayer2\" pluginspage=\"http://microsoft.com/windows/mediaplayer/en/download/\" id=\"mediaPlayer\" name=\"mediaPlayer\" displaysize=\"4\" autosize=\"-1\" bgcolor=\"darkblue\" showcontrols=\"true\" showtracker=\"-1\" showdisplay=\"0\" showstatusbar=\"-1\" videoborder3d=\"-1\" width=\"$width\" height=\"$height\" src=\"$mediaURL\" autostart=\"$autostart\" designtimesp=\"5311\ loop=\"true\"></EMBED>";
return $output;
}
if (
$extension == "divx") {
if (strlen($height)==0)
$height = "212";
if (strlen($width)==0)
$width = "320";
if (strlen($autostart)==0)
$autostart = "true";
$output = "<object classid=\"clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616\" width=\"$width\" height=\"$height\" codebase=\"http://go.divx.com/plugin/DivXBrowserPlugin.cab\"><param name=\"src\" value=\"$mediaURL\" /><embed type=\"video/divx\" src=\"$mediaURL\" autoPlay=\"$autostart\" width=\"$width\" height=\"$height\" pluginspage=\"http://go.divx.com/plugin/download/\"></embed></object>";
return $output;
}
if (
$extension == "wmv") {
if (strlen($height)==0)
$height = "260";
if (strlen($width)==0)
$width = "320";
if (strlen($autostart)==0)
$autostart = "true";
$output = "<embed src=\"$mediaURL\" width=\"$width\" height=\"$height\" autoplay=\"$autostart\" controller=\"true\" enablejavascript=\"true\"></embed>";
return $output;
}
if (
$extension == "mp3") {
if (strlen($height)==0)
$height = "15";
if (strlen($width)==0)
$width = "320";
if (strlen($autostart)==0)
$autostart = "true";
$output = "<img src='images/audio320x240.gif'/><br/><embed pluginspage=\"http://www.apple.com/quicktime/download/\" src=\"players/QT.mov\" QTSRC=\"$mediaURL\" width=\"$width\" height=\"$height\" autoplay=\"$autostart\" controller=\"true\" enablejavascript=\"true\"></embed>";
return $output;
}
if (
$extension == "mpeg" || $extension == "mpg") {
if (strlen($height)==0)
$height = "260";
if (strlen($width)==0)
$width = "320";
if (strlen($autostart)==0)
$autostart = "true";
$output = "<embed PLUGINSPAGE=\"http://www.apple.com/quicktime/download/\" src=\"Sample.mov\" QTSRC=\"$mediaURL\" width=\"$width\" height=\"$height\" autoplay=\"$autostart\" controller=\"true\" enablejavascript=\"true\"></embed>";
return $output;
}
if ((
$extension == "rm") || ($extension == "ram")) {
if (strlen($height)==0)
$height = "260";
if (strlen($width)==0)
$width = "320";
if (strlen($autostart)==0)
$autostart = "true";
$output = "<embed type=\"audio/x-pn-realaudio-plugin\" src=\"$mediaURL\" width=\"$width\" height=\"$height\" controls=\"ImageWindow\" console=\"one\" autostart=\"$autostart\"></embed>";
return $output;
}
if (
$extension == "ra") {
if (strlen($height)==0)
$height = "260";
if (strlen($width)==0)
$width = "320";
if (strlen($autostart)==0)
$autostart = "false";
$output = "add real media audio code";
return $output;
}
if (
$extension == "swf") {
if (strlen($height)==0)
$height = "260";
if (strlen($width)==0)
$width = "320";
if (strlen($autostart)==0)
$autostart = "false";
$output = "<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"$width\" height=\"$height\"> <param name=\"movie\" value=\"$mediaURL\"> <param name=\"quality\" value=\"high\"><param name=\"bgcolor\" value=\"#FFFFFF\"> <param name=\"loop\" value=\"true\"> <EMBED src=\"$mediaURL\" quality=\"high\" bgcolor=\"#FFFFFF\" width=\"$width\" height=\"$height\" loop=\"true\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"></EMBED></OBJECT>";
return $output;
}
if (
$extension == "flv") {
if (strlen($height)==0)
$height = "268";
if (strlen($width)==0)
$width = "320";
if (strlen($autostart)==0)
$autostart = "true";
$output = <<<ENDOFPLAYER
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="$width" height="$height" id="320x268_v6" align="middle" wmode="transparent">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="players/flvplayer.swf?file=$mediaURL&autostart=$autostart" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<embed src="players/flvplayer.swf?file=$mediaURL&autostart=$autostart" swliveconnect="true" quality="high" width="$width" height="$height" name="320x268_v6" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></embed>
</object>
ENDOFPLAYER;
return
$output;
}
}
?>
<html>
<head>
<style>
* {padding:0;margin:0;}
body {}
</style>
</head>
<body>
<center><?php echo display() ?></center>
</body>
</html>
Recent comments
2 years 34 weeks ago
2 years 36 weeks ago
2 years 39 weeks ago
2 years 39 weeks ago
2 years 41 weeks ago
2 years 42 weeks ago
2 years 45 weeks ago
2 years 46 weeks ago