/** * PLUGIN FRAMEWORK, Version 0.4 * For details, see the Knallgrau web site: http://www.knallgrau.code/prototype/plugins_js * Copyright (c) 2006 Matthias Platzer * This code is freely distributable under the terms of an MIT-style license. * *********************************************************************************** * Copyright (c) 2006 Matthias Platzer * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * *********************************************************************************** * * inspired by Prototype JavaScript framework * * Provides the following functions * // name accepts: * // Acrobat, QuickTime, DivX, Director, * // 'Windows Media', Flash, Java, RealPlayer, VLC * Plugin.isInstalled(String name) * Plugin.getVersion(String name) * Plugin.getPluginsForMimeType(String mimeType) // returns Array of Plugin Names * Plugin.getPluginsForFileSuffix(String suffix) // returns Array of Plugin Names * Plugin.embed(pluginName, options, target) * Plugin.getInfo(String name) * // Result Object contains informations about the plugin * Boolean isInstalled * String version * String description * Array progID to be used with new ActiveXObject() * String classID for ActiveX * String pluginsPage URL to download the plugin * Array acceptedMimeTypes provides MimeType info for IE * * CHANGELOG: * 17.12.2005: Version 0.1 * initial version * 18.12.2005: Version 0.2 * added mimetypes for divx & co. * added VLC support (detection for IE is missing) * renamed getPluginsForMimeType, getPluginsForFileSuffix -> returns Array, instead of String * dropped support vor Adobe SVG (IE) * tested and debugged RealPlayer -> still reports a strange version number * fixed bugs where script did break on unknown name attribute * added experimental Plugin.embed * 20.12.2005: Version 0.3 * added docs * added license * rewrote Plugin.embed -> now it's easier to add new formats * downloadURL became pluginsPage * added mimeType, activeXType and codeBase to Plugin.PLUGINS * Plugin.embed accepts strings as target (id) * Added Plugin.embed support for Flash, RealPlayer and VLC * 23.03.2006: Version 0.4 * Fixed a few warnings reported by firefox in javascript strict mode (reported by Olav Roth) * * you may remove the comments section, but please leave the copyright /*--------------------------------------------------------------------------*/ var PluginFactory = function() { // Returns if plugin with identifier name is installed // @see Plugin.getInfo this.isInstalled = function(name) { return Plugin.getInfo(name).isInstalled; } // Returns version number of plugin if available // @see Plugin.getInfo this.getVersion = function(name) { return Plugin.getInfo(name).version; } // Returns an Array of plugin identifier names, // that can handle this mimeType. this.getPluginsForMimeType = function(mimeType) { var result = []; if (supportsNavigatorPlugins()) { // navigator.mimeTypes for (var i=0; i\n'; html += (src) ? ' \n' : ''; for (var i in embedOptions) { html += ' '; } html += '\n'; } if (target) { if (typeof target == "string") target = document.getElementById(target); target.innerHTML = html; } else { document.write(html); } } var getAttributeHtml = function(name, value) { return (value) ? (" " + name + "=\"" + value + "\"") : ""; } // Info about known plugins this.PLUGINS = { "Acrobat": { description: "Adobe Acrobat Plugin", progID: ["PDF.PdfCtrl.7", "PDF.PdfCtrl.6", "PDF.PdfCtrl.5", "PDF.PdfCtrl.4", "PDF.PdfCtrl.3", "AcroPDF.PDF.1"], classID: "CA8A9780-280D-11CF-A24D-444553540000", pluginsPage: "http://www.adobe.com/products/acrobat/readstep2.html", acceptedMimeTypes: [ { type: "application/pdf", suffixes: "pdf" }, { type: "application/vnd.fdf", suffixes: "fdf" }, { type: "application/vnd.adobe.xfdf", suffixes: "xfdf" }, { type: "application/vnd.adobe.xdp+xml", suffixes: "xdp" }, { type: "application/vnd.adobe.xfd+xml", suffixes: "xfd" } ] }, "QuickTime": { description: "QuickTime Plug-in", progID: ["QuickTimeCheckObject.QuickTimeCheck.1", "QuickTime.QuickTime"], classID: "02BF25D5-8C17-4B23-BC80-D3488ABDDC6B", pluginsPage: "http://www.apple.com/quicktime/download/", codeBase: "http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0", mimeType: "video/quicktime", standardEmbedAttributes: { autoplay: "false" }, // embedInfo: http://www.apple.com/quicktime/tutorials/embed.html // http://developer.apple.com/quicktime/compatibility.html getActiveXVersionInfo: function() { var progID = getProgIdForActiveXObject(Plugin.PLUGINS["QuickTime"].progID); var obj = new ActiveXObject(progID); var version = (obj && obj.QuickTimeVersion) ? obj.QuickTimeVersion.toString(16) : ""; return version.substring(0,1) + '.' + version.substring(1,2) + '.' + version.substring(2,3); }, acceptedMimeTypes: [ { type: "image/tiff", suffixes: "tif,tiff" }, { type: "image/x-tiff", suffixes: "tif,tiff" }, { type: "video/x-m4v", suffixes: "m4v" }, { type: "image/x-macpaint", suffixes: "pntg,pnt,mac" }, { type: "image/pict", suffixes: "pict,pic,pct" }, { type: "image/x-pict", suffixes: "pict,pic,pct" }, { type: "image/x-quicktime", suffixes: "qtif,qti" }, { type: "image/x-sgi", suffixes: "sgi,rgb" }, { type: "image/x-targa", suffixes: "targa,tga" }, { type: "audio/3gpp", suffixes: "3gp,3gpp" }, { type: "video/3gpp2", suffixes: "3g2,3gp2" }, { type: "audio/3gpp2", suffixes: "3g2,3gp2" }, { type: "video/sd-video", suffixes: "sdv" }, { type: "application/x-mpeg", suffixes: "amc" }, { type: "video/mp4", suffixes: "mp4" }, { type: "audio/mp4", suffixes: "mp4" }, { type: "audio/x-m4a", suffixes: "m4a" }, { type: "audio/x-m4p", suffixes: "m4p" }, { type: "audio/x-m4b", suffixes: "m4b" }, { type: "video/mpeg", suffixes: "mpeg,mpg,m1s,m1v,m1a,m75,m15,mp2,mpm,mpv,mpa" }, { type: "audio/mpeg", suffixes: "mpeg,mpg,m1s,m1a,mp2,mpm,mpa,m2a" }, { type: "audio/x-mpeg", suffixes: "mpeg,mpg,m1s,m1a,mp2,mpm,mpa,m2a" }, { type: "video/3gpp", suffixes: "3gp,3gpp" }, { type: "audio/x-gsm", suffixes: "gsm" }, { type: "audio/AMR", suffixes: "AMR" }, { type: "audio/aac", suffixes: "aac,adts" }, { type: "audio/x-aac", suffixes: "aac,adts" }, { type: "audio/x-caf", suffixes: "caf" }, { type: "video/x-mpeg", suffixes: "mpeg,mpg,m1s,m1v,m1a,m75,m15,mp2,mpm,mpv,mpa" }, { type: "audio/aiff", suffixes: "aiff,aif,aifc,cdda" }, { type: "audio/x-aiff", suffixes: "aiff,aif,aifc,cdda" }, { type: "audio/basic", suffixes: "au,snd,ulw" }, { type: "audio/mid", suffixes: "mid,midi,smf,kar" }, { type: "audio/x-midi", suffixes: "mid,midi,smf,kar" }, { type: "audio/midi", suffixes: "mid,midi,smf,kar" }, { type: "audio/vnd.qcelp", suffixes: "qcp" }, { type: "application/sdp", suffixes: "sdp" }, { type: "application/x-sdp", suffixes: "sdp" }, { type: "application/x-rtsp", suffixes: "rtsp,rts" }, { type: "video/quicktime", suffixes: "mov,qt,mqv" }, { type: "video/flc", suffixes: "flc,fli,cel" }, { type: "audio/x-wav", suffixes: "wav,bwf" }, { type: "audio/wav", suffixes: "wav,bwf" } ] }, "DivX": { description: "DivX Browser Plugin", progID: ["npdivx.DivXBrowserPlugin.1", "npdivx.DivXBrowserPlugin"], classID: "67DABFBF-D0AB-41fa-9C46-CC0F21721616", codeBase: "http://go.divx.com/plugin/DivXBrowserPlugin.cab", pluginsPage: "http://go.divx.com/plugin/download/", mimeType: "video/divx", standardEmbedAttributes: { mode: "mini", autoplay: "false" }, // embedInfo: Beta1: http://labs.divx.com/archives/000072.html // SDK&Doc: http://download.divx.com/labs/Webmaster_SDK.zip getActiveXVersionInfo2: function() { var progID = getProgIdForActiveXObject(Plugin.PLUGINS["DivX"].progID); return "0.9.0"; // that's the only currently available }, acceptedMimeTypes: [ { type: "video/divx", suffixes: "dvx,divx" } ] }, "Director": { description: "Macromedia Director", progID: ["SWCtl.SWCtl.11","SWCtl.SWCtl.10","SWCtl.SWCtl.9","SWCtl.SWCtl.8","SWCtl.SWCtl.7","SWCtl.SWCtl.6","SWCtl.SWCtl.5","SWCtl.SWCtl.4"], classID: "166B1BCA-3F9C-11CF-8075-444553540000", pluginsPage: "http://www.macromedia.com/shockwave/download/", codeBase: "http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0", mimeType: "application/x-director" }, "Flash": { description: "Macromedia Shockwave Flash", progID: ["ShockwaveFlash.ShockwaveFlash.9", "ShockwaveFlash.ShockwaveFlash.8.5", "ShockwaveFlash.ShockwaveFlash.8", "ShockwaveFlash.ShockwaveFlash.7", "ShockwaveFlash.ShockwaveFlash.6", "ShockwaveFlash.ShockwaveFlash.5", "ShockwaveFlash.ShockwaveFlash.4"], classID: "D27CDB6E-AE6D-11CF-96B8-444553540000", pluginsPage: "http://www.macromedia.com/go/getflashplayer", codeBase: "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0", mimeType: "application/x-shockwave-flash", standardEmbedAttributes: { quality: "high" }, // embedInfo: http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_4150 // http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_12701 acceptedMimeTypes: [ { type: "application/x-shockwave-flash", suffixes: "swf" }, { type: "application/futuresplash", suffixes: "spl" } ] }, "VLC": { description: "VLC multimedia plugin", progID: [], classID: "", pluginsPage: "http://www.videolan.org/doc/play-howto/en/ch02.html#id287569", codeBase: "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0", mimeType: "application/x-vlc-plugin", standardEmbedAttributes: { quality: "high", autoplay: "no" }, // embedInfo: http://www.videolan.org/doc/vlc-user-guide/en/ch07.html acceptedMimeTypes: [ { type: "audio/mpeg", suffixes: "mp2,mp3,mpga,mpega" }, { type: "audio/x-mpeg", suffixes: "mp2,mp3,mpga,mpega" }, { type: "video/mpeg", suffixes: "mpg,mpeg,mpe" }, { type: "video/x-mpeg", suffixes: "mpg,mpeg,mpe" }, { type: "video/mpeg-system", suffixes: "mpg,mpeg,vob" }, { type: "video/x-mpeg-system", suffixes: "mpg,mpeg,vob" }, { type: "video/mpeg4", suffixes: "mp4,mpg4" }, { type: "audio/mpeg4", suffixes: "mp4,mpg4" }, { type: "application/mpeg4-iod", suffixes: "mp4,mpg4" }, { type: "application/mpeg4-muxcodetable", suffixes: "mp4,mpg4" }, { type: "video/x-msvideo", suffixes: "avi" }, { type: "video/quicktime", suffixes: "mov,qt" }, { type: "application/x-ogg", suffixes: "ogg" }, { type: "application/x-vlc-plugin", suffixes: "*" }, { type: "video/x-ms-asf-plugin", suffixes: "asf,asx,*" }, { type: "video/x-ms-asf", suffixes: "asf,asx,*" }, { type: "application/x-mplayer2", suffixes: "dvx,divx,ivx,xvid,ivf,*" }, { type: "video/x-ms-wmv", suffixes: "wmv,*" }, { type: "application/x-google-vlc-plugin", suffixes: "*" } ] }, "Windows Media": { description: "Windows Media Player Plug-in Dynamic Link Library", progID: ["WMPlayer.OCX", "MediaPlayer.MediaPlayer.1"], classID: "22d6f312-b0f6-11d0-94ab-0080c74c7e95", // WMP7+ pluginsPage: "http://www.microsoft.com/windows/windowsmedia/", codeBase: "http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902", mimeType: "application/x-mplayer2", activeXType: "application/x-oleobject", standardEmbedAttributes: { autoplay: "false" }, // embedInfo: http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/internet/imedia/netshow/crossbrowserembed/default.asp getActiveXVersionInfo: function() { var progID = getProgIdForActiveXObject(Plugin.PLUGINS["Windows Media"].progID); var obj = new ActiveXObject(progID); return (obj && obj.versionInfo) ? obj.versionInfo : ""; }, acceptedMimeTypes: [ { type: "application/asx", suffixes: "*" }, { type: "video/x-ms-asf-plugin", suffixes: "*" }, { type: "application/x-mplayer2", suffixes: "dvx,divx,ivx,xvid,ivf,*" }, { type: "video/x-ms-asf", suffixes: "asf,asx,*" }, { type: "video/x-ms-wm", suffixes: "wm,*" }, { type: "audio/x-ms-wma", suffixes: "wma,*" }, { type: "audio/x-ms-wax", suffixes: "wax,*" }, { type: "video/x-ms-wmv", suffixes: "wmv,*" }, { type: "audio/mpeg", suffixes: "mp2,mp3,mpga,mpega" }, { type: "video/x-ms-wvx", suffixes: "wvx,*" } ] }, "Java": { description: "Java Virtual Machine", progID: [], classID: "08B0E5C0-4FCB-11CF-AAA5-00401C608500", pluginsPage: "http://www.java.com/de/download/manual.jsp", acceptedMimeTypes: [ { type: "application/x-java-applet", suffixes: "" }, { type: "application/x-java-bean", suffixes: "" }, { type: "application/x-java-vm", suffixes: " " } ] }, "RealPlayer": { description: "RealPlayer Version Plugin", progID: ["RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)", "RealVideo.RealVideo(tm) ActiveX Control (32-bit)", "rmocx.RealPlayer G2 Control"], classID: "CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA", mimeType: "audio/x-pn-realaudio-plugin", pluginsPage: "http://www.real.com/freeplayer/?rppr=rnwk", forceEmbedTag: true, standardEmbedAttributes: { controls: "ControlPanel", nojava: "true", autostart: "false" }, // embedInfo: http://service.real.com/help/library/guides/realone/ProductionGuide/HTML/realpgd.htm?page=htmfiles/embed.htm // couldn't find any info about the object tag! getActiveXVersionInfo: function() { var progID = getProgIdForActiveXObject(Plugin.PLUGINS["RealPlayer"].progID); var obj = new ActiveXObject(progID); var version = (obj) ? obj.GetVersionInfo() : ""; return version; }, acceptedMimeTypes: [ { type: "audio/x-pn-realaudio-plugin", suffixes: "rpm" }, { type: "application/vnd.rn-realplayer-javascript", suffixes: "rpj" } ] } } var supportsNavigatorPlugins = function() { return (navigator.plugins && (navigator.plugins.length > 0)); } var supportsActiveX = function() { return ((typeof 'ActiveXObject' != 'undefined') && (navigator.userAgent.indexOf('Win') != -1)); } var findNavigatorPluginByName = function(name) { if (supportsNavigatorPlugins()) { for(var i=0;i", ">"); str = str.replace("\"", """); str = str.replace("\n", ""); return str; } if (window.updateProgress)updateProgress(); // Copyright (c) 2006, Fabrik, Inc. All Rights Reserved.