[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 /* 2 DynAPI Distribution 3 FlashSound Class - for sonifying web pages with the flash player 4 Based on the FlashSound API (1.8) Copyright 2001 Hayden Porter, hayden@aviarts.com 5 6 For more information please see the FlashSound Quick Reference 7 8 The DynAPI Distribution is distributed under the terms of the GNU LGPL license. 9 10 Requires: DynLayer 11 12 */ 13 14 function FlashSound(swfURL,loop,autostart){ 15 16 this.DynLayer = DynLayer; 17 this.DynLayer(null,-10,-10,1,1); 18 19 // add layer to document 20 dynapi.document.addChild(this); 21 22 // instance properties 23 this.playerID = this.id + "SWF"; 24 FlashSound.players[FlashSound.players.length] = this; 25 26 // instance embed properties 27 this.autostart = true; 28 this.base = null; 29 this.bgcolor = null; 30 this.loop = (loop)? loop:false; 31 this.src = null; 32 33 // setup flash plugin 34 this.setSWF(swfURL); 35 36 }; 37 38 39 /* ============== FlashSound Instance methods =============== */ 40 41 /* 42 javascript embed --------------------------------- 43 embeds swf if user has a supported browser and minimum player. 44 script sets swf bgcolor attribute to document.bgcolor if no custom color specified. 45 */ 46 var p = dynapi.setPrototype('FlashSound','DynLayer'); 47 48 p._recognizeMethod = function (objstr){ 49 // check for player readiness ---------------------- 50 // check for javascript DOM object first then check to see if any frames are loaded in maintimeline 51 if(typeof(this.doc[this.playerID][objstr]) == "undefined") return false; 52 else return true; 53 }; 54 55 p._checkForInstance = function() { 56 if(!FlashSound.supportedBrowser || !FlashSound.checkForMinPlayer()) return false; 57 if (this.doc[this.playerID] == null) return false; 58 return true; 59 }; 60 61 // Public Methods ------------------- 62 63 p.isPlayerReady = function(){ 64 if(!FlashSound.engage) return false; 65 if(!this._checkForInstance()) return false; 66 // block browsers that do not recognize Flash javascript methods 67 if(!this._recognizeMethod("PercentLoaded")) return false; 68 if(this.percentLoaded() > 0) return true; 69 return false; 70 }; 71 72 p.getFramesLoaded = function(target){ 73 if(!this._checkForInstance()) {return 0;} 74 if(target == null) target = "/"; 75 var framesloaded = this.doc[this.playerID].TGetProperty(target,12); 76 return parseInt(framesloaded); 77 }; 78 79 p.getTotalFrames = function(target){ 80 if(!this.isPlayerReady()) {return 0;} 81 if(target == null) target = "/"; 82 var totalframes = this.doc[this.playerID].TGetProperty(target,5); 83 return parseInt(totalframes); 84 }; 85 86 // check to see if all frames are loaded for a given timeline. 87 // check before moving playhead to a frame/label incase the frame/label is not yet loaded. 88 p.isLoaded = function(target){ 89 if(!this.isPlayerReady()) return false; 90 if(target == null) target = "/"; 91 if (this.getFramesLoaded(target) == this.getTotalFrames(target)) return true; 92 return false; 93 }; 94 95 /* flash javascript api functions ------------------------ */ 96 97 p.gotoAndPlay = function(target,frame){ 98 if(!this.isPlayerReady()) return; 99 if(typeof(frame) == "number") { 100 this.doc[this.playerID].TGotoFrame(target,frame - 1); 101 this.doc[this.playerID].TPlay(target); 102 } 103 if(typeof(frame) == "string") { 104 this.doc[this.playerID].TGotoLabel(target,frame); 105 this.doc[this.playerID].TPlay(target); 106 } 107 }; 108 109 p.gotoAndStop = function(target,frame){ 110 if(!this.isPlayerReady()) return; 111 if(typeof(frame) == "number") { 112 this.doc[this.playerID].TGotoFrame(target,frame - 1); 113 } 114 if(typeof(frame) == "string") { 115 this.doc[this.playerID].TGotoLabel(target,frame); 116 } 117 }; 118 119 // Is Playing (IsPlaying) 120 p.isPlaying = function(){ 121 if(!this.isPlayerReady()) return false; 122 return this.doc[this.playerID].IsPlaying(); 123 }; 124 125 // Load Movie 126 p.loadMovie = function(layerNumber,url){ 127 if(!this.isPlayerReady()) return; 128 this.doc[this.playerID].LoadMovie(layerNumber,url); 129 }; 130 131 p.percentLoaded = function(){ 132 if(!this._checkForInstance()) return 0; 133 var percentLoaded = this.doc[this.playerID].PercentLoaded(); 134 return parseInt(percentLoaded); 135 }; 136 137 p.play = function(target){ 138 if(!this.isPlayerReady()) return; 139 if(target == null) target = "/"; 140 this.doc[this.playerID].TPlay(target); 141 }; 142 143 // Set SWF 144 p.setSWF = function(swfURL){ 145 if (!FlashSound.supportedBrowser || !FlashSound.checkForMinPlayer()) return; 146 147 var defaultColor = (document.bgColor != null) ? document.bgColor : "#ffffff"; 148 var defaultBase = "."; 149 swfURL=(swfURL)? swfURL:''; 150 this.bgcolor = (this.bgcolor == null) ? defaultColor : this.bgcolor; 151 this.base = (this.base == null) ? defaultBase : this.base; 152 this.src = (swfURL.charAt(0) == "/") ? "http://" + location.host+swfURL : swfURL; 153 this.setHTML( 154 '<OBJECT ' + 155 'CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' + 156 'CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" ' + 157 'WIDTH="1" ' + 158 'HEIGHT="1" ' + 159 'ID="' + this.playerID + '">\n' + 160 '<PARAM NAME="movie" VALUE="' + this.src + '">\n' + 161 '<PARAM NAME="play" VALUE="' + this.autostart + '">\n' + 162 '<PARAM NAME="loop" VALUE="' + this.loop + '">\n' + 163 '<PARAM NAME="quality" VALUE="low">\n' + 164 '<PARAM NAME="wmode" VALUE="transparent">\n' + 165 '<PARAM NAME="bgcolor" VALUE="' + this.bgcolor + '">\n' + 166 '<PARAM NAME="base" VALUE="' + this.base + '">\n' + 167 '<EMBED \n' + 168 'name="' + this.playerID + '"\n' + 169 'swLiveConnect="true"\n' + 170 'src="' + this.src + '\"' + '\n' + 171 'play="' + this.autostart + '\"' + '\n' + 172 'loop="' + this.loop + '\"' + '\n' + 173 'quality="low"\n' + 174 'wmode="transparent"\n' + 175 'base="' + this.base + '"\n' + 176 'bgcolor="' + this.bgcolor + '"\n' + 177 'WIDTH="1"\n' + 178 'HEIGHT="2"\n' + 179 'TYPE="application/x-shockwave-flash"\n' + 180 'PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">\n' + 181 '</EMBED>\n' + 182 '</OBJECT>' 183 ); 184 }; 185 186 // Stop Play (TStopPlay) 187 p.stopPlay = function(target){ 188 if(!this.isPlayerReady()) return; 189 if(target == null) target = "/"; 190 this.doc[this.playerID].TStopPlay(target); 191 }; 192 193 194 /* Static Functions & Properties --------------------------- */ 195 196 var fs = FlashSound; 197 fs.engage = true; // engage 198 fs.playerCount = 0; // player count 199 fs.players = new Array(); // players[] 200 fs.playerVersion = 0; // set playerVersion to 0 for unsupported browsers 201 202 203 // check for LiveConnect - Opera version 6.x with Java Enabled and Netscape versions 4.x but not greater 204 fs.LiveConnect = ((navigator.javaEnabled() && 205 (dynapi.ua.ns4 && dynapi.ua.v<5)) || dynapi.ua.opera6); 206 207 // browser compatibility check ----------------- 208 fs.supportedBrowser = ((dynapi.ua.ie && dynapi.ua.win32) || 209 dynapi.ua.ns6 || FlashSound.LiveConnect) ? true : false; 210 211 // player compatibility ------------------ 212 213 // checkForMinPlayer sets playerVersion for supported browsers 214 fs.checkForMinPlayer = function(){ 215 if(!this.supportedBrowser) return false; 216 if(dynapi.ua.ns6) { 217 // xpconnect works with version 6 r40 or greater 218 this.playerVersion = this.getPlugInVers(); // get version 219 releaseVers = this.getPlugInReleaseVers(); // get release version 220 //check release vers only for vers 6 221 if(this.playerVersion == 6 && releaseVers >=40) return true; 222 } 223 224 if(this.LiveConnect) this.playerVersion = this.getPlugInVers(); 225 if(dynapi.ua.ie) this.playerVersion = (Flash_getActiveXVersion()); 226 227 if(this.playerVersion >= this.minPlayer) return true; 228 else return false; 229 }; 230 231 // check for flash plug-in in netscape 232 fs.checkForPlugIn = function(){ 233 var flashmimeType = "application/x-shockwave-flash"; 234 var hasplugin = (navigator.mimeTypes && navigator.mimeTypes[flashmimeType]) ? navigator.mimeTypes[flashmimeType].enabledPlugin : 0; 235 return hasplugin; 236 }; 237 238 // Get Plugin Version 239 fs.getPlugInVers = function(){ 240 if(this.checkForPlugIn()){ 241 var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin; 242 var pluginversion = parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)); 243 return pluginversion; 244 }else{ 245 return 0; 246 } 247 }; 248 249 // Get Plugin Release Version 250 fs.getPlugInReleaseVers = function(){ 251 if(this.checkForPlugIn()){ 252 var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin; 253 var pluginversion = parseInt(plugin.description.substring(plugin.description.indexOf("r")+1, plugin.description.length)); 254 return pluginversion; 255 }else{ 256 return 0; 257 } 258 }; 259 260 // vers is integer 261 fs.setMinPlayer = function(vers){ 262 if(!this.supportedBrowser) return; 263 this.minPlayer = (vers != null && vers >= 4) ? vers : 4; 264 if(dynapi.ua.ns6) { 265 this.minPlayer = 6; // set min player to 6 for XPConnect 266 } 267 this.checkForMinPlayer(); 268 }; 269 270 // vbscript get Flash ActiveX control version for windows IE 271 if(dynapi.ua.ie && dynapi.ua.win32){ 272 var h='<scr' + 'ipt language="VBScript">' + '\n' + 273 'Function Flash_getActiveXVersion()' + '\n' + 274 'On Error Resume Next' + '\n' + 275 'Dim hasPlayer, playerversion' + '\n' + 276 'hasPlayer = false' + '\n' + 277 'playerversion = 15' + '\n' + 278 'Do While playerversion > 0' + '\n' + 279 'hasPlayer = (IsObject(CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" & playerversion)))' + '\n' + 280 'If hasPlayer Then Exit Do' + '\n' + 281 'playerversion = playerversion - 1' + '\n' + 282 'Loop' + '\n' + 283 'Flash_getActiveXVersion = playerversion' + '\n' + 284 'End Function' + '\n' + 285 '<\/scr' + 'ipt>'; 286 287 if(!dynapi.loaded) document.write(h); 288 else { 289 dynapi.document.addChild(new DynLayer({w:0,h:0,visible:false,html:'<iframe name="FSVBS"></iframe'})); 290 var elm=document.frames['FSVBS']; 291 var doc = elm.document; 292 doc.open();doc.write(h);doc.close(); 293 dynapi.frame.Flash_getActiveXVersion = function() { 294 return elm.Flash_getActiveXVersion(); 295 }; 296 } 297 }; 298 299 // set minimum player version - default is 4 300 fs.setMinPlayer();
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |