/* JS file for putting custom per-project code into */ /** * MediaObject: factory for either windows media player or quicktime player embedding * * MediaObject is made by Marc Worrell with sample code from Apple: * http://developer.apple.com/internet/webcontent/examples/detectplugins_source.html * * $Id: mediaobjectfactory.js 36948 2008-07-14 10:08:33Z arjan $ */ /* */ // initialize global variables var detectableWithVB = false; var didWriteVBScript = false; function mediaObjectFactory () { if (mediaObjectFactory.caller != mediaObjectFactory.createObject) { throw new Error("There is no public constructor for mediaObjectFactory."); } } mediaObjectFactory.createObject = function ( file, id, w, h, mime ) { this.createVBScriptTester(); var has_wmp = this.detectWindowsMedia(); var has_qt = this.detectQuickTime(); var has_flash = this.detectFlash(); var is_windows = navigator.userAgent.indexOf('Windows') > 0; // Prefer QT unless we run into problems with some mime types that QT does not understand if (this.playWithFlash(mime) && has_flash) { var qo = new SWFObject("/lib/embed/player.swf", id, w, h); qo.addParam("flashvars", "file="+file); return qo; } if (this.playWithQT(mime) && has_qt) { return new QTObject(file, id, w, h); } else if (has_wmp || is_windows) { return new winObject(file, id, w, h, mime); } else if (has_qt) { return new QTObject(file, id, w, h); } else { // No media player found - should include a dummy object that writes an error message return null; } } mediaObjectFactory.playWithFlash = function ( mime ) { switch (mime) { case 'video/x-flv': return true; } return false; } mediaObjectFactory.playWithQT = function ( mime ) { switch (mime) { // Microsoft specific formats case 'audio/wma': case 'audio/x-ms-wma': case 'video/avi': case 'video/wmv': case 'video/asf': case 'video/x-msvideo': case 'video/x-ms-wmv': case 'video/x-ms-wvx': case 'video/x-ms-asf': case 'application/x-mplayer2': // Real specific formats case 'audio/x-realaudio': case 'audio/x-pn-realaudio-plugin': return false; } return true; } // The code below comes is derived from Apple sample code mediaObjectFactory.detectFlash = function () { var pluginFound = this.detectPlugin('Shockwave','Flash'); if (!pluginFound && detectableWithVB) { pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1'); } return pluginFound; } mediaObjectFactory.detectDirector = function () { var pluginFound = this.detectPlugin('Shockwave','Director'); if (!pluginFound && detectableWithVB) { pluginFound = detectActiveXControl('SWCtl.SWCtl.1'); } return pluginFound; } mediaObjectFactory.detectWindowsMedia = function () { var pluginFound = this.detectPlugin('Windows Media Player'); if (!pluginFound && detectableWithVB) { pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1'); } return pluginFound; } mediaObjectFactory.detectQuickTime = function () { var pluginFound = this.detectPlugin('QuickTime'); if (!pluginFound && detectableWithVB) { pluginFound = detectQuickTimeActiveXControl(); } return pluginFound; } mediaObjectFactory.detectReal = function () { var pluginFound = this.detectPlugin('RealPlayer'); if(!pluginFound && detectableWithVB) { pluginFound = ( detectActiveXControl('rmocx.RealPlayer G2 Control') || detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') || detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)')); } return pluginFound; } mediaObjectFactory.detectPlugin = function() { var daPlugins = mediaObjectFactory.detectPlugin.arguments; var pluginFound = false; if (navigator.plugins && navigator.plugins.length > 0) { var pluginsArrayLength = navigator.plugins.length; for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) { // loop through all desired names and check each against the current plugin name var numFound = 0; for (namesCounter=0; namesCounter < daPlugins.length; namesCounter++) { // if desired plugin name is found in either plugin name or description if ( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) { // this name was found numFound++; } } // now that we have checked all the required names against this one plugin, // if the number we found matches the total number provided then we were successful if (numFound == daPlugins.length) { pluginFound = true; // if we've found the plugin, we can stop looking through at the rest of the plugins break; } } } return pluginFound; } // Here we write out the VBScript block for MSIE Windows mediaObjectFactory.createVBScriptTester = function () { if (!didWriteVBScript && (navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) { didWriteVBScript = true; document.writeln('