scratch – Blame information for rev 73

Subversion Repositories:
Rev:
Rev Author Line No. Line
73 office 1 /*!
2 * SoundJS
3 * Visit http://createjs.com/ for documentation, updates and examples.
4 *
5 * Copyright (c) 2010 gskinner.com, inc.
6 *
7 * Permission is hereby granted, free of charge, to any person
8 * obtaining a copy of this software and associated documentation
9 * files (the "Software"), to deal in the Software without
10 * restriction, including without limitation the rights to use,
11 * copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following
14 * conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 * OTHER DEALINGS IN THE SOFTWARE.
27 */
28  
29  
30 //##############################################################################
31 // swfobject.js
32 //##############################################################################
33  
34 /*! SWFObject v2.2 <http://code.google.com/p/swfobject/>
35 is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
36 */
37  
38 var swfobject = function() {
39  
40 var UNDEF = "undefined",
41 OBJECT = "object",
42 SHOCKWAVE_FLASH = "Shockwave Flash",
43 SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
44 FLASH_MIME_TYPE = "application/x-shockwave-flash",
45 EXPRESS_INSTALL_ID = "SWFObjectExprInst",
46 ON_READY_STATE_CHANGE = "onreadystatechange",
47  
48 win = window,
49 doc = document,
50 nav = navigator,
51  
52 plugin = false,
53 domLoadFnArr = [main],
54 regObjArr = [],
55 objIdArr = [],
56 listenersArr = [],
57 storedAltContent,
58 storedAltContentId,
59 storedCallbackFn,
60 storedCallbackObj,
61 isDomLoaded = false,
62 isExpressInstallActive = false,
63 dynamicStylesheet,
64 dynamicStylesheetMedia,
65 autoHideShow = true,
66  
67 /* Centralized function for browser feature detection
68 - User agent string detection is only used when no good alternative is possible
69 - Is executed directly for optimal performance
70 */
71 ua = function() {
72 var w3cdom = typeof doc.getElementById != UNDEF && typeof doc.getElementsByTagName != UNDEF && typeof doc.createElement != UNDEF,
73 u = nav.userAgent.toLowerCase(),
74 p = nav.platform.toLowerCase(),
75 windows = p ? /win/.test(p) : /win/.test(u),
76 mac = p ? /mac/.test(p) : /mac/.test(u),
77 webkit = /webkit/.test(u) ? parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : false, // returns either the webkit version or false if not webkit
78 ie = !+"\v1", // feature detection based on Andrea Giammarchi's solution: http://webreflection.blogspot.com/2009/01/32-bytes-to-know-if-your-browser-is-ie.html
79 playerVersion = [0,0,0],
80 d = null;
81 if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
82 d = nav.plugins[SHOCKWAVE_FLASH].description;
83 if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
84 plugin = true;
85 ie = false; // cascaded feature detection for Internet Explorer
86 d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
87 playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
88 playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
89 playerVersion[2] = /[a-zA-Z]/.test(d) ? parseInt(d.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0;
90 }
91 }
92 else if (typeof win.ActiveXObject != UNDEF) {
93 try {
94 var a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
95 if (a) { // a will return null when ActiveX is disabled
96 d = a.GetVariable("$version");
97 if (d) {
98 ie = true; // cascaded feature detection for Internet Explorer
99 d = d.split(" ")[1].split(",");
100 playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
101 }
102 }
103 }
104 catch(e) {}
105 }
106 return { w3:w3cdom, pv:playerVersion, wk:webkit, ie:ie, win:windows, mac:mac };
107 }(),
108  
109 /* Cross-browser onDomLoad
110 - Will fire an event as soon as the DOM of a web page is loaded
111 - Internet Explorer workaround based on Diego Perini's solution: http://javascript.nwbox.com/IEContentLoaded/
112 - Regular onload serves as fallback
113 */
114 onDomLoad = function() {
115 if (!ua.w3) { return; }
116 if ((typeof doc.readyState != UNDEF && doc.readyState == "complete") || (typeof doc.readyState == UNDEF && (doc.getElementsByTagName("body")[0] || doc.body))) { // function is fired after onload, e.g. when script is inserted dynamically
117 callDomLoadFunctions();
118 }
119 if (!isDomLoaded) {
120 if (typeof doc.addEventListener != UNDEF) {
121 doc.addEventListener("DOMContentLoaded", callDomLoadFunctions, false);
122 }
123 if (ua.ie && ua.win) {
124 doc.attachEvent(ON_READY_STATE_CHANGE, function() {
125 if (doc.readyState == "complete") {
126 doc.detachEvent(ON_READY_STATE_CHANGE, arguments.callee);
127 callDomLoadFunctions();
128 }
129 });
130 if (win == top) { // if not inside an iframe
131 (function(){
132 if (isDomLoaded) { return; }
133 try {
134 doc.documentElement.doScroll("left");
135 }
136 catch(e) {
137 setTimeout(arguments.callee, 0);
138 return;
139 }
140 callDomLoadFunctions();
141 })();
142 }
143 }
144 if (ua.wk) {
145 (function(){
146 if (isDomLoaded) { return; }
147 if (!/loaded|complete/.test(doc.readyState)) {
148 setTimeout(arguments.callee, 0);
149 return;
150 }
151 callDomLoadFunctions();
152 })();
153 }
154 addLoadEvent(callDomLoadFunctions);
155 }
156 }();
157  
158 function callDomLoadFunctions() {
159 if (isDomLoaded) { return; }
160 try { // test if we can really add/remove elements to/from the DOM; we don't want to fire it too early
161 var t = doc.getElementsByTagName("body")[0].appendChild(createElement("span"));
162 t.parentNode.removeChild(t);
163 }
164 catch (e) { return; }
165 isDomLoaded = true;
166 var dl = domLoadFnArr.length;
167 for (var i = 0; i < dl; i++) {
168 domLoadFnArr[i]();
169 }
170 }
171  
172 function addDomLoadEvent(fn) {
173 if (isDomLoaded) {
174 fn();
175 }
176 else {
177 domLoadFnArr[domLoadFnArr.length] = fn; // Array.push() is only available in IE5.5+
178 }
179 }
180  
181 /* Cross-browser onload
182 - Based on James Edwards' solution: http://brothercake.com/site/resources/scripts/onload/
183 - Will fire an event as soon as a web page including all of its assets are loaded
184 */
185 function addLoadEvent(fn) {
186 if (typeof win.addEventListener != UNDEF) {
187 win.addEventListener("load", fn, false);
188 }
189 else if (typeof doc.addEventListener != UNDEF) {
190 doc.addEventListener("load", fn, false);
191 }
192 else if (typeof win.attachEvent != UNDEF) {
193 addListener(win, "onload", fn);
194 }
195 else if (typeof win.onload == "function") {
196 var fnOld = win.onload;
197 win.onload = function() {
198 fnOld();
199 fn();
200 };
201 }
202 else {
203 win.onload = fn;
204 }
205 }
206  
207 /* Main function
208 - Will preferably execute onDomLoad, otherwise onload (as a fallback)
209 */
210 function main() {
211 if (plugin) {
212 testPlayerVersion();
213 }
214 else {
215 matchVersions();
216 }
217 }
218  
219 /* Detect the Flash Player version for non-Internet Explorer browsers
220 - Detecting the plug-in version via the object element is more precise than using the plugins collection item's description:
221 a. Both release and build numbers can be detected
222 b. Avoid wrong descriptions by corrupt installers provided by Adobe
223 c. Avoid wrong descriptions by multiple Flash Player entries in the plugin Array, caused by incorrect browser imports
224 - Disadvantage of this method is that it depends on the availability of the DOM, while the plugins collection is immediately available
225 */
226 function testPlayerVersion() {
227 var b = doc.getElementsByTagName("body")[0];
228 var o = createElement(OBJECT);
229 o.setAttribute("type", FLASH_MIME_TYPE);
230 var t = b.appendChild(o);
231 if (t) {
232 var counter = 0;
233 (function(){
234 if (typeof t.GetVariable != UNDEF) {
235 var d = t.GetVariable("$version");
236 if (d) {
237 d = d.split(" ")[1].split(",");
238 ua.pv = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
239 }
240 }
241 else if (counter < 10) {
242 counter++;
243 setTimeout(arguments.callee, 10);
244 return;
245 }
246 b.removeChild(o);
247 t = null;
248 matchVersions();
249 })();
250 }
251 else {
252 matchVersions();
253 }
254 }
255  
256 /* Perform Flash Player and SWF version matching; static publishing only
257 */
258 function matchVersions() {
259 var rl = regObjArr.length;
260 if (rl > 0) {
261 for (var i = 0; i < rl; i++) { // for each registered object element
262 var id = regObjArr[i].id;
263 var cb = regObjArr[i].callbackFn;
264 var cbObj = {success:false, id:id};
265 if (ua.pv[0] > 0) {
266 var obj = getElementById(id);
267 if (obj) {
268 if (hasPlayerVersion(regObjArr[i].swfVersion) && !(ua.wk && ua.wk < 312)) { // Flash Player version >= published SWF version: Houston, we have a match!
269 setVisibility(id, true);
270 if (cb) {
271 cbObj.success = true;
272 cbObj.ref = getObjectById(id);
273 cb(cbObj);
274 }
275 }
276 else if (regObjArr[i].expressInstall && canExpressInstall()) { // show the Adobe Express Install dialog if set by the web page author and if supported
277 var att = {};
278 att.data = regObjArr[i].expressInstall;
279 att.width = obj.getAttribute("width") || "0";
280 att.height = obj.getAttribute("height") || "0";
281 if (obj.getAttribute("class")) { att.styleclass = obj.getAttribute("class"); }
282 if (obj.getAttribute("align")) { att.align = obj.getAttribute("align"); }
283 // parse HTML object param element's name-value pairs
284 var par = {};
285 var p = obj.getElementsByTagName("param");
286 var pl = p.length;
287 for (var j = 0; j < pl; j++) {
288 if (p[j].getAttribute("name").toLowerCase() != "movie") {
289 par[p[j].getAttribute("name")] = p[j].getAttribute("value");
290 }
291 }
292 showExpressInstall(att, par, id, cb);
293 }
294 else { // Flash Player and SWF version mismatch or an older Webkit engine that ignores the HTML object element's nested param elements: display alternative content instead of SWF
295 displayAltContent(obj);
296 if (cb) { cb(cbObj); }
297 }
298 }
299 }
300 else { // if no Flash Player is installed or the fp version cannot be detected we let the HTML object element do its job (either show a SWF or alternative content)
301 setVisibility(id, true);
302 if (cb) {
303 var o = getObjectById(id); // test whether there is an HTML object element or not
304 if (o && typeof o.SetVariable != UNDEF) {
305 cbObj.success = true;
306 cbObj.ref = o;
307 }
308 cb(cbObj);
309 }
310 }
311 }
312 }
313 }
314  
315 function getObjectById(objectIdStr) {
316 var r = null;
317 var o = getElementById(objectIdStr);
318 if (o && o.nodeName == "OBJECT") {
319 if (typeof o.SetVariable != UNDEF) {
320 r = o;
321 }
322 else {
323 var n = o.getElementsByTagName(OBJECT)[0];
324 if (n) {
325 r = n;
326 }
327 }
328 }
329 return r;
330 }
331  
332 /* Requirements for Adobe Express Install
333 - only one instance can be active at a time
334 - fp 6.0.65 or higher
335 - Win/Mac OS only
336 - no Webkit engines older than version 312
337 */
338 function canExpressInstall() {
339 return !isExpressInstallActive && hasPlayerVersion("6.0.65") && (ua.win || ua.mac) && !(ua.wk && ua.wk < 312);
340 }
341  
342 /* Show the Adobe Express Install dialog
343 - Reference: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75
344 */
345 function showExpressInstall(att, par, replaceElemIdStr, callbackFn) {
346 isExpressInstallActive = true;
347 storedCallbackFn = callbackFn || null;
348 storedCallbackObj = {success:false, id:replaceElemIdStr};
349 var obj = getElementById(replaceElemIdStr);
350 if (obj) {
351 if (obj.nodeName == "OBJECT") { // static publishing
352 storedAltContent = abstractAltContent(obj);
353 storedAltContentId = null;
354 }
355 else { // dynamic publishing
356 storedAltContent = obj;
357 storedAltContentId = replaceElemIdStr;
358 }
359 att.id = EXPRESS_INSTALL_ID;
360 if (typeof att.width == UNDEF || (!/%$/.test(att.width) && parseInt(att.width, 10) < 310)) { att.width = "310"; }
361 if (typeof att.height == UNDEF || (!/%$/.test(att.height) && parseInt(att.height, 10) < 137)) { att.height = "137"; }
362 doc.title = doc.title.slice(0, 47) + " - Flash Player Installation";
363 var pt = ua.ie && ua.win ? "ActiveX" : "PlugIn",
364 fv = "MMredirectURL=" + encodeURI(window.location).toString().replace(/&/g,"%26") + "&MMplayerType=" + pt + "&MMdoctitle=" + doc.title;
365 if (typeof par.flashvars != UNDEF) {
366 par.flashvars += "&" + fv;
367 }
368 else {
369 par.flashvars = fv;
370 }
371 // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
372 // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
373 if (ua.ie && ua.win && obj.readyState != 4) {
374 var newObj = createElement("div");
375 replaceElemIdStr += "SWFObjectNew";
376 newObj.setAttribute("id", replaceElemIdStr);
377 obj.parentNode.insertBefore(newObj, obj); // insert placeholder div that will be replaced by the object element that loads expressinstall.swf
378 obj.style.display = "none";
379 (function(){
380 if (obj.readyState == 4) {
381 obj.parentNode.removeChild(obj);
382 }
383 else {
384 setTimeout(arguments.callee, 10);
385 }
386 })();
387 }
388 createSWF(att, par, replaceElemIdStr);
389 }
390 }
391  
392 /* Functions to abstract and display alternative content
393 */
394 function displayAltContent(obj) {
395 if (ua.ie && ua.win && obj.readyState != 4) {
396 // IE only: when a SWF is loading (AND: not available in cache) wait for the readyState of the object element to become 4 before removing it,
397 // because you cannot properly cancel a loading SWF file without breaking browser load references, also obj.onreadystatechange doesn't work
398 var el = createElement("div");
399 obj.parentNode.insertBefore(el, obj); // insert placeholder div that will be replaced by the alternative content
400 el.parentNode.replaceChild(abstractAltContent(obj), el);
401 obj.style.display = "none";
402 (function(){
403 if (obj.readyState == 4) {
404 obj.parentNode.removeChild(obj);
405 }
406 else {
407 setTimeout(arguments.callee, 10);
408 }
409 })();
410 }
411 else {
412 obj.parentNode.replaceChild(abstractAltContent(obj), obj);
413 }
414 }
415  
416 function abstractAltContent(obj) {
417 var ac = createElement("div");
418 if (ua.win && ua.ie) {
419 ac.innerHTML = obj.innerHTML;
420 }
421 else {
422 var nestedObj = obj.getElementsByTagName(OBJECT)[0];
423 if (nestedObj) {
424 var c = nestedObj.childNodes;
425 if (c) {
426 var cl = c.length;
427 for (var i = 0; i < cl; i++) {
428 if (!(c[i].nodeType == 1 && c[i].nodeName == "PARAM") && !(c[i].nodeType == 8)) {
429 ac.appendChild(c[i].cloneNode(true));
430 }
431 }
432 }
433 }
434 }
435 return ac;
436 }
437  
438 /* Cross-browser dynamic SWF creation
439 */
440 function createSWF(attObj, parObj, id) {
441 var r, el = getElementById(id);
442 if (ua.wk && ua.wk < 312) { return r; }
443 if (el) {
444 if (typeof attObj.id == UNDEF) { // if no 'id' is defined for the object element, it will inherit the 'id' from the alternative content
445 attObj.id = id;
446 }
447 if (ua.ie && ua.win) { // Internet Explorer + the HTML object element + W3C DOM methods do not combine: fall back to outerHTML
448 var att = "";
449 for (var i in attObj) {
450 if (attObj[i] != Object.prototype[i]) { // filter out prototype additions from other potential libraries
451 if (i.toLowerCase() == "data") {
452 parObj.movie = attObj[i];
453 }
454 else if (i.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
455 att += ' class="' + attObj[i] + '"';
456 }
457 else if (i.toLowerCase() != "classid") {
458 att += ' ' + i + '="' + attObj[i] + '"';
459 }
460 }
461 }
462 var par = "";
463 for (var j in parObj) {
464 if (parObj[j] != Object.prototype[j]) { // filter out prototype additions from other potential libraries
465 par += '<param name="' + j + '" value="' + parObj[j] + '" />';
466 }
467 }
468 el.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + att + '>' + par + '</object>';
469 objIdArr[objIdArr.length] = attObj.id; // stored to fix object 'leaks' on unload (dynamic publishing only)
470 r = getElementById(attObj.id);
471 }
472 else { // well-behaving browsers
473 var o = createElement(OBJECT);
474 o.setAttribute("type", FLASH_MIME_TYPE);
475 for (var m in attObj) {
476 if (attObj[m] != Object.prototype[m]) { // filter out prototype additions from other potential libraries
477 if (m.toLowerCase() == "styleclass") { // 'class' is an ECMA4 reserved keyword
478 o.setAttribute("class", attObj[m]);
479 }
480 else if (m.toLowerCase() != "classid") { // filter out IE specific attribute
481 o.setAttribute(m, attObj[m]);
482 }
483 }
484 }
485 for (var n in parObj) {
486 if (parObj[n] != Object.prototype[n] && n.toLowerCase() != "movie") { // filter out prototype additions from other potential libraries and IE specific param element
487 createObjParam(o, n, parObj[n]);
488 }
489 }
490 el.parentNode.replaceChild(o, el);
491 r = o;
492 }
493 }
494 return r;
495 }
496  
497 function createObjParam(el, pName, pValue) {
498 var p = createElement("param");
499 p.setAttribute("name", pName);
500 p.setAttribute("value", pValue);
501 el.appendChild(p);
502 }
503  
504 /* Cross-browser SWF removal
505 - Especially needed to safely and completely remove a SWF in Internet Explorer
506 */
507 function removeSWF(id) {
508 var obj = getElementById(id);
509 if (obj && obj.nodeName == "OBJECT") {
510 if (ua.ie && ua.win) {
511 obj.style.display = "none";
512 (function(){
513 if (obj.readyState == 4) {
514 removeObjectInIE(id);
515 }
516 else {
517 setTimeout(arguments.callee, 10);
518 }
519 })();
520 }
521 else {
522 obj.parentNode.removeChild(obj);
523 }
524 }
525 }
526  
527 function removeObjectInIE(id) {
528 var obj = getElementById(id);
529 if (obj) {
530 for (var i in obj) {
531 if (typeof obj[i] == "function") {
532 obj[i] = null;
533 }
534 }
535 obj.parentNode.removeChild(obj);
536 }
537 }
538  
539 /* Functions to optimize JavaScript compression
540 */
541 function getElementById(id) {
542 var el = null;
543 try {
544 el = doc.getElementById(id);
545 }
546 catch (e) {}
547 return el;
548 }
549  
550 function createElement(el) {
551 return doc.createElement(el);
552 }
553  
554 /* Updated attachEvent function for Internet Explorer
555 - Stores attachEvent information in an Array, so on unload the detachEvent functions can be called to avoid memory leaks
556 */
557 function addListener(target, eventType, fn) {
558 target.attachEvent(eventType, fn);
559 listenersArr[listenersArr.length] = [target, eventType, fn];
560 }
561  
562 /* Flash Player and SWF content version matching
563 */
564 function hasPlayerVersion(rv) {
565 var pv = ua.pv, v = rv.split(".");
566 v[0] = parseInt(v[0], 10);
567 v[1] = parseInt(v[1], 10) || 0; // supports short notation, e.g. "9" instead of "9.0.0"
568 v[2] = parseInt(v[2], 10) || 0;
569 return (pv[0] > v[0] || (pv[0] == v[0] && pv[1] > v[1]) || (pv[0] == v[0] && pv[1] == v[1] && pv[2] >= v[2])) ? true : false;
570 }
571  
572 /* Cross-browser dynamic CSS creation
573 - Based on Bobby van der Sluis' solution: http://www.bobbyvandersluis.com/articles/dynamicCSS.php
574 */
575 function createCSS(sel, decl, media, newStyle) {
576 if (ua.ie && ua.mac) { return; }
577 var h = doc.getElementsByTagName("head")[0];
578 if (!h) { return; } // to also support badly authored HTML pages that lack a head element
579 var m = (media && typeof media == "string") ? media : "screen";
580 if (newStyle) {
581 dynamicStylesheet = null;
582 dynamicStylesheetMedia = null;
583 }
584 if (!dynamicStylesheet || dynamicStylesheetMedia != m) {
585 // create dynamic stylesheet + get a global reference to it
586 var s = createElement("style");
587 s.setAttribute("type", "text/css");
588 s.setAttribute("media", m);
589 dynamicStylesheet = h.appendChild(s);
590 if (ua.ie && ua.win && typeof doc.styleSheets != UNDEF && doc.styleSheets.length > 0) {
591 dynamicStylesheet = doc.styleSheets[doc.styleSheets.length - 1];
592 }
593 dynamicStylesheetMedia = m;
594 }
595 // add style rule
596 if (ua.ie && ua.win) {
597 if (dynamicStylesheet && typeof dynamicStylesheet.addRule == OBJECT) {
598 dynamicStylesheet.addRule(sel, decl);
599 }
600 }
601 else {
602 if (dynamicStylesheet && typeof doc.createTextNode != UNDEF) {
603 dynamicStylesheet.appendChild(doc.createTextNode(sel + " {" + decl + "}"));
604 }
605 }
606 }
607  
608 function setVisibility(id, isVisible) {
609 if (!autoHideShow) { return; }
610 var v = isVisible ? "visible" : "hidden";
611 if (isDomLoaded && getElementById(id)) {
612 getElementById(id).style.visibility = v;
613 }
614 else {
615 createCSS("#" + id, "visibility:" + v);
616 }
617 }
618  
619 /* Filter to avoid XSS attacks
620 */
621 function urlEncodeIfNecessary(s) {
622 var regex = /[\\\"<>\.;]/;
623 <> var hasBadChars = regex.exec(s) != null;
624 <> return hasBadChars && typeof encodeURIComponent != UNDEF ? encodeURIComponent(s) : s;
625 <> }
626  
627 <> /* Release memory to avoid memory leaks caused by closures, fix hanging audio/video threads and force open sockets/NetConnections to disconnect (Internet Explorer only)
628 <> */
629 <> var cleanup = function() {
630 <> if (ua.ie && ua.win) {
631 <> window.attachEvent("onunload", function() {
632 <> // remove listeners to avoid memory leaks
633 <> var ll = listenersArr.length;
634 <> for (var i = 0; i < ll; i++) {
635 <> listenersArr[i][0].detachEvent(listenersArr[i][1], listenersArr[i][2]);
636 <> }
637 <> // cleanup dynamically embedded objects to fix audio/video threads and force open sockets and NetConnections to disconnect
638 <> var il = objIdArr.length;
639 <> for (var j = 0; j < il; j++) {
640 <> removeSWF(objIdArr[j]);
641 <> }
642 <> // cleanup library's main closures to avoid memory leaks
643 <> for (var k in ua) {
644 <> ua[k] = null;
645 <> }
646 <> ua = null;
647 <> for (var l in swfobject) {
648 <> swfobject[l] = null;
649 <> }
650 <> swfobject = null;
651 <> });
652 <> }
653 <> }();
654  
655 <> return {
656 <> /* Public API
657 <> - Reference: http://code.google.com/p/swfobject/wiki/documentation
658 <> */
659 <> registerObject: function(objectIdStr, swfVersionStr, xiSwfUrlStr, callbackFn) {
660 <> if (ua.w3 && objectIdStr && swfVersionStr) {
661 <> var regObj = {};
662 <> regObj.id = objectIdStr;
663 <> regObj.swfVersion = swfVersionStr;
664 <> regObj.expressInstall = xiSwfUrlStr;
665 <> regObj.callbackFn = callbackFn;
666 <> regObjArr[regObjArr.length] = regObj;
667 <> setVisibility(objectIdStr, false);
668 <> }
669 <> else if (callbackFn) {
670 <> callbackFn({success:false, id:objectIdStr});
671 <> }
672 <> },
673  
674 <> getObjectById: function(objectIdStr) {
675 <> if (ua.w3) {
676 <> return getObjectById(objectIdStr);
677 <> }
678 <> },
679  
680 <> embedSWF: function(swfUrlStr, replaceElemIdStr, widthStr, heightStr, swfVersionStr, xiSwfUrlStr, flashvarsObj, parObj, attObj, callbackFn) {
681 <> var callbackObj = {success:false, id:replaceElemIdStr};
682 <> if (ua.w3 && !(ua.wk && ua.wk < 312) && swfUrlStr && replaceElemIdStr && widthStr && heightStr && swfVersionStr) {
683 <> setVisibility(replaceElemIdStr, false);
684 <> addDomLoadEvent(function() {
685 <> widthStr += ""; // auto-convert to string
686 <> heightStr += "";
687 <> var att = {};
688 <> if (attObj && typeof attObj === OBJECT) {
689 <> for (var i in attObj) { // copy object to avoid the use of references, because web authors often reuse attObj for multiple SWFs
690 <> att[i] = attObj[i];
691 <> }
692 <> }
693 <> att.data = swfUrlStr;
694 <> att.width = widthStr;
695 <> att.height = heightStr;
696 <> var par = {};
697 <> if (parObj && typeof parObj === OBJECT) {
698 <> for (var j in parObj) { // copy object to avoid the use of references, because web authors often reuse parObj for multiple SWFs
699 <> par[j] = parObj[j];
700 <> }
701 <> }
702 <> if (flashvarsObj && typeof flashvarsObj === OBJECT) {
703 <> for (var k in flashvarsObj) { // copy object to avoid the use of references, because web authors often reuse flashvarsObj for multiple SWFs
704 <> if (typeof par.flashvars != UNDEF) {
705 <> par.flashvars += "&" + k + "=" + flashvarsObj[k];
706 <> }
707 <> else {
708 <> par.flashvars = k + "=" + flashvarsObj[k];
709 <> }
710 <> }
711 <> }
712 <> if (hasPlayerVersion(swfVersionStr)) { // create SWF
713 <> var obj = createSWF(att, par, replaceElemIdStr);
714 <> if (att.id == replaceElemIdStr) {
715 <> setVisibility(replaceElemIdStr, true);
716 <> }
717 <> callbackObj.success = true;
718 <> callbackObj.ref = obj;
719 <> }
720 <> else if (xiSwfUrlStr && canExpressInstall()) { // show Adobe Express Install
721 <> att.data = xiSwfUrlStr;
722 <> showExpressInstall(att, par, replaceElemIdStr, callbackFn);
723 <> return;
724 <> }
725 <> else { // show alternative content
726 <> setVisibility(replaceElemIdStr, true);
727 <> }
728 <> if (callbackFn) { callbackFn(callbackObj); }
729 <> });
730 <> }
731 <> else if (callbackFn) { callbackFn(callbackObj); }
732 <> },
733  
734 <> switchOffAutoHideShow: function() {
735 <> autoHideShow = false;
736 <> },
737  
738 <> ua: ua,
739  
740 <> getFlashPlayerVersion: function() {
741 <> return { major:ua.pv[0], minor:ua.pv[1], release:ua.pv[2] };
742 <> },
743  
744 <> hasFlashPlayerVersion: hasPlayerVersion,
745  
746 <> createSWF: function(attObj, parObj, replaceElemIdStr) {
747 <> if (ua.w3) {
748 <> return createSWF(attObj, parObj, replaceElemIdStr);
749 <> }
750 <> else {
751 <> return undefined;
752 <> }
753 <> },
754  
755 <> showExpressInstall: function(att, par, replaceElemIdStr, callbackFn) {
756 <> if (ua.w3 && canExpressInstall()) {
757 <> showExpressInstall(att, par, replaceElemIdStr, callbackFn);
758 <> }
759 <> },
760  
761 <> removeSWF: function(objElemIdStr) {
762 <> if (ua.w3) {
763 <> removeSWF(objElemIdStr);
764 <> }
765 <> },
766  
767 <> createCSS: function(selStr, declStr, mediaStr, newStyleBoolean) {
768 <> if (ua.w3) {
769 <> createCSS(selStr, declStr, mediaStr, newStyleBoolean);
770 <> }
771 <> },
772  
773 <> addDomLoadEvent: addDomLoadEvent,
774  
775 <> addLoadEvent: addLoadEvent,
776  
777 <> getQueryParamValue: function(param) {
778 <> var q = doc.location.search || doc.location.hash;
779 <> if (q) {
780 <> if (/\?/.test(q)) { q = q.split("?")[1]; } // strip question mark
781 <> if (param == null) {
782 <> return urlEncodeIfNecessary(q);
783 <> }
784 <> var pairs = q.split("&");
785 <> for (var i = 0; i < pairs.length; i++) {
786 <> if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
787 <> return urlEncodeIfNecessary(pairs[i].substring((pairs[i].indexOf("=") + 1)));
788 <> }
789 <> }
790 <> }
791 <> return "";
792 <> },
793  
794 <> // For internal usage only
795 <> expressInstallCallback: function() {
796 <> if (isExpressInstallActive) {
797 <> var obj = getElementById(EXPRESS_INSTALL_ID);
798 <> if (obj && storedAltContent) {
799 <> obj.parentNode.replaceChild(storedAltContent, obj);
800 <> if (storedAltContentId) {
801 <> setVisibility(storedAltContentId, true);
802 <> if (ua.ie && ua.win) { storedAltContent.style.display = "block"; }
803 <> }
804 <> if (storedCallbackFn) { storedCallbackFn(storedCallbackObj); }
805 <> }
806 <> isExpressInstallActive = false;
807 <> }
808 <> }
809 <> };
810 <>}();
811  
812 <>//##############################################################################
813 <>// FlashAudioLoader.js
814 <>//##############################################################################
815  
816 <>this.createjs = this.createjs || {};
817  
818 <>(function () {
819 <> "use strict";
820  
821 <> /**
822 <> * Loader provides a mechanism to preload Flash content via PreloadJS or internally. Instances are returned to
823 <> * the preloader, and the load method is called when the asset needs to be requested.
824 <> *
825 <> * @class FlashAudioLoader
826 <> * @param {String} loadItem The item to be loaded
827 <> * @param {Object} flash The flash instance that will do the preloading.
828 <> * @extends AbstractLoader
829 <> * @protected
830 <> */
831 <> function Loader(loadItem) {
832 <> this.AbstractLoader_constructor(loadItem, false, createjs.AbstractLoader.SOUND);
833  
834  
835 <>// Public properties
836 <> /**
837 <> * ID used to facilitate communication with flash.
838 <> * Not doc'd because this should not be altered externally
839 <> * @property flashId
840 <> * @type {String}
841 <> */
842 <> this.flashId = null;
843  
844 <> }
845 <> var p = createjs.extend(Loader, createjs.AbstractLoader);
846  
847 <> // TODO: deprecated
848 <> // p.initialize = function() {}; // searchable for devs wondering where it is. REMOVED. See docs for details.
849  
850  
851 <>// Static Properties
852 <> var s = Loader;
853 <> /**
854 <> * A reference to the Flash instance that gets created.
855 <> * @property flash
856 <> * @type {Object | Embed}
857 <> * @protected
858 <> */
859 <> s._flash = null;
860  
861 <> /**
862 <> * A list of loader instances that tried to load before _flash was set
863 <> * @property _preloadInstances
864 <> * @type {Array}
865 <> * @protected
866 <> */
867 <> s._preloadInstances = [];
868  
869 <> /**
870 <> * Set the Flash instance on the class, and start loading on any instances that had load called
871 <> * before flash was ready
872 <> * @method setFlash
873 <> * @param flash Flash instance that handles loading and playback
874 <> */
875 <> s.setFlash = function(flash) {
876 <> s._flash = flash;
877 <> for(var i = s._preloadInstances.length; i--; ) {
878 <> var loader = s._preloadInstances.pop();
879 <> loader.load();
880 <> }
881 <> };
882  
883 <>// public methods
884 <> p.load = function () {
885 <> if (s._flash == null) {
886 <> // register for future preloading
887 <> s._preloadInstances.push(this);
888 <> return;
889 <> }
890  
891 <> this.flashId = s._flash.preload(this._item.src);
892 <> // Associate this preload instance with the FlashID, so callbacks can route here.
893 <> var e = new createjs.Event(createjs.FlashAudioPlugin._REG_FLASHID);
894 <> this.dispatchEvent(e);
895 <> };
896  
897 <> /**
898 <> * called from flash when loading has progress
899 <> * @method handleProgress
900 <> * @param loaded
901 <> * @param total
902 <> * @protected
903 <> */
904 <> p.handleProgress = function (loaded, total) {
905 <> this._sendProgress(loaded/total);
906 <> };
907  
908 <> /**
909 <> * Called from Flash when sound is loaded. Set our ready state and fire callbacks / events
910 <> * @method handleComplete
911 <> * @protected
912 <> */
913 <> p.handleComplete = function () {
914 <> this._result = this._item.src;
915 <> this._sendComplete();
916 <> };
917  
918 <> /**
919 <> * Receive error event from flash and pass it to callback.
920 <> * @method handleError
921 <> * @param {Event} error
922 <> * @protected
923 <> */
924 <> p.handleError = function (error) {
925 <> this._handleError(error);
926 <> };
927  
928 <> p.destroy = function () {
929 <> var e = new createjs.Event(createjs.FlashAudioPlugin._UNREG_FLASHID);
930 <> this.dispatchEvent(e);
931 <> this.AbstractLoader_destroy();
932 <> };
933  
934 <> p.toString = function () {
935 <> return "[FlashAudioLoader]";
936 <> };
937  
938 <> createjs.FlashAudioLoader = createjs.promote(Loader, "AbstractLoader");
939  
940 <>}());
941  
942 <>//##############################################################################
943 <>// FlashAudioSoundInstance.js
944 <>//##############################################################################
945  
946 <>this.createjs = this.createjs || {};
947  
948 <>(function () {
949 <> "use strict";
950  
951 <> /**
952 <> * FlashAudioSoundInstance extends the base api of {{#crossLink "AbstractSoundInstance"}}{{/crossLink}} and is used by
953 <> * {{#crossLink "FlashAudioPlugin"}}{{/crossLink}}.
954 <> *
955 <> * NOTE audio control is shuttled to a flash player instance via the flash reference.
956 <> *
957 <> * @param {String} src The path to and file name of the sound.
958 <> * @param {Number} startTime Audio sprite property used to apply an offset, in milliseconds.
959 <> * @param {Number} duration Audio sprite property used to set the time the clip plays for, in milliseconds.
960 <> * @param {Object} playbackResource Any resource needed by plugin to support audio playback.
961 <> * @class FlashAudioSoundInstance
962 <> * @extends AbstractSoundInstance
963 <> * @constructor
964 <> */
965 <> function FlashAudioSoundInstance(src, startTime, duration, playbackResource) {
966 <> this.AbstractSoundInstance_constructor(src, startTime, duration, playbackResource);
967  
968  
969 <>// Public Properties
970 <> /**
971 <> * ID used to facilitate communication with flash.
972 <> * Not doc'd because this should not be altered externally
973 <> * #property flashId
974 <> * @type {String}
975 <> */
976 <> this.flashId = null; // To communicate with Flash
977  
978 <> if(s._flash == null) { s._instances.push(this); }
979 <> };
980 <> var p = createjs.extend(FlashAudioSoundInstance, createjs.AbstractSoundInstance);
981  
982 <> // TODO: deprecated
983 <> // p.initialize = function() {}; // searchable for devs wondering where it is. REMOVED. See docs for details.
984  
985  
986 <>// Static Propeties
987 <> var s = FlashAudioSoundInstance;
988 <> /**
989 <> * A reference to the Flash instance that gets created.
990 <> * #property flash
991 <> * @type {Object | Embed}
992 <> */
993 <> s._flash = null;
994  
995 <> /**
996 <> * A list of loader instances that tried to load before _flash was set
997 <> * #property _preloadInstances
998 <> * @type {Array}
999 <> * @private
1000 <> */
1001 <> s._instances = [];
1002  
1003 <> /**
1004 <> * Set the Flash instance on the class, and start loading on any instances that had load called
1005 <> * before flash was ready
1006 <> * #method setFlash
1007 <> * @param flash Flash instance that handles loading and playback
1008 <> */
1009 <> s.setFlash = function(flash) {
1010 <> s._flash = flash;
1011 <> for(var i = s._instances.length; i--; ) {
1012 <> var o = s._instances.pop();
1013 <> o._setDurationFromSource();
1014 <> }
1015 <> };
1016  
1017  
1018 <>// Public Methods
1019 <> // TODO change flash.setLoop to mimic remove and add??
1020 <> p.setLoop = function (value) {
1021 <> if(this.flashId!= null) {
1022 <> s._flash.setLoop(this.flashId, value);
1023 <> }
1024 <> this._loop = value;
1025 <> };
1026  
1027 <> p.toString = function () {
1028 <> return "[FlashAudioSoundInstance]"
1029 <> };
1030  
1031  
1032 <>// Private Methods
1033 <> p._updateVolume = function() {
1034 <> if (this.flashId == null) { return; }
1035 <> s._flash.setVolume(this.flashId, this._volume)
1036 <> };
1037  
1038 <> p._updatePan = function () {
1039 <> if (this.flashId == null) { return; }
1040 <> s._flash.setPan(this.flashId, this._pan);
1041 <> };
1042  
1043 <> p._setDurationFromSource = function() {
1044 <> this._duration = s._flash.getDurationBySrc(this.src);
1045 <> };
1046  
1047 <> p._interrupt = function () {
1048 <> if(this.flashId == null) { return; }
1049 <> s._flash.interrupt(this.flashId); // OJR this is redundant, cleanup calls stop that does the same thing anyway
1050 <> this.AbstractSoundInstance__interrupt();
1051 <> };
1052  
1053 <> p._handleCleanUp = function () {
1054 <> s._flash.stopSound(this.flashId);
1055  
1056 <> this._sendEvent(createjs.FlashAudioPlugin._UNREG_FLASHID);
1057 <> this.flashId = null;
1058 <> };
1059  
1060 <> p._beginPlaying = function (playProps) {
1061 <> if (s._flash == null) { return false; }
1062  
1063 <> this.setPosition(playProps.offset);
1064 <> this.setLoop(playProps.loop);
1065 <> this.setVolume(playProps.volume);
1066 <> this.setPan(playProps.pan);
1067 <> if (playProps.startTime != null) {
1068 <> this.setStartTime(playProps.startTime);
1069 <> this.setDuration(playProps.duration);
1070 <> }
1071 <> this._paused = false;
1072  
1073 <> this.flashId = s._flash.playSound(this.src, this._position, this._loop, this._volume, this._pan, this._startTime, this._duration);
1074 <> if (this.flashId == null) {
1075 <> this._playFailed();
1076 <> return false;
1077 <> }
1078  
1079 <> if (this._muted) {this.setMute(true);}
1080 <> this._sendEvent(createjs.FlashAudioPlugin._REG_FLASHID);
1081  
1082 <> this.playState = createjs.Sound.PLAY_SUCCEEDED;
1083 <> this._sendEvent("succeeded");
1084 <> return true;
1085 <> };
1086  
1087 <> p._pause = function () {
1088 <> if(this.flashId == null) { return; }
1089 <> this._position = this._calculateCurrentPosition();
1090 <> s._flash.pauseSound(this.flashId);
1091 <> };
1092  
1093 <> p._resume = function () {
1094 <> if(this.flashId == null) { return; }
1095 <> s._flash.resumeSound(this.flashId);
1096 <> };
1097  
1098 <> p._handleStop = function () {
1099 <> if(this.flashId == null) { return; }
1100 <> s._flash.stopSound(this.flashId);
1101 <> };
1102  
1103 <> p._updateVolume = function () {
1104 <> var newVolume = this._muted ? 0 : this._volume;
1105 <> s._flash.setVolume(this.flashId, newVolume);
1106 <> };
1107 <> // TODO remove unused .muteSound and .unmuteSound from Flash
1108  
1109 <> p._calculateCurrentPosition = function() {
1110 <> return s._flash.getPosition(this.flashId);
1111 <> };
1112  
1113 <> p._updatePosition = function() {
1114 <> if(this.flashId == null) { return; }
1115 <> s._flash.setPosition(this.flashId, this._position);
1116 <> };
1117  
1118 <>// Flash callbacks, only exist in FlashAudioPlugin
1119 <> /**
1120 <> * Called from Flash. Lets us know flash has finished playing a sound.
1121 <> * #method handleSoundFinished
1122 <> * @protected
1123 <> */
1124 <> p.handleSoundFinished = function () {
1125 <> this._loop = 0;
1126 <> this._handleSoundComplete();
1127 <> };
1128  
1129 <> /**
1130 <> * Called from Flash. Lets us know that flash has played a sound to completion and is looping it.
1131 <> * #method handleSoundLoop
1132 <> * @protected
1133 <> */
1134 <> p.handleSoundLoop = function () {
1135 <> this._loop--;
1136 <> this._sendEvent("loop");
1137 <> };
1138  
1139 <> createjs.FlashAudioSoundInstance = createjs.promote(FlashAudioSoundInstance, "AbstractSoundInstance");
1140 <>}());
1141  
1142 <>//##############################################################################
1143 <>// FlashAudioPlugin.js
1144 <>//##############################################################################
1145  
1146 <>this.createjs = this.createjs || {};
1147  
1148 <>(function () {
1149  
1150 <> "use strict";
1151  
1152 <> /**
1153 <> * Play sounds using a Flash instance. This plugin is not used by default, and must be registered manually in
1154 <> * {{#crossLink "Sound"}}{{/crossLink}} using the {{#crossLink "Sound/registerPlugins"}}{{/crossLink}} method. This
1155 <> * plugin is recommended to be included if sound support is required in older browsers such as IE8.
1156 <> *
1157 <> * This plugin requires FlashAudioPlugin.swf and swfObject.js, which is compiled
1158 <> * into the minified FlashAudioPlugin-X.X.X.min.js file. You must ensure that {{#crossLink "FlashAudioPlugin/swfPath:property"}}{{/crossLink}}
1159 <> * is set when using this plugin, so that the script can find the swf.
1160 <> *
1161 <> * <h4>Example</h4>
1162 <> *
1163 <> * createjs.FlashAudioPlugin.swfPath = "../src/soundjs/flashaudio";
1164 <> * createjs.Sound.registerPlugins([createjs.WebAudioPlugin, createjs.HTMLAudioPlugin, createjs.FlashAudioPlugin]);
1165 <> * // Adds FlashAudioPlugin as a fallback if WebAudio and HTMLAudio do not work.
1166 <> *
1167 <> * Note that the SWF is embedded into a container DIV (with an id and classname of "SoundJSFlashContainer"), and
1168 <> * will have an id of "flashAudioContainer". The container DIV is positioned 1 pixel off-screen to the left to avoid
1169 <> * showing the 1x1 pixel white square.
1170 <> *
1171 <> * <h4>Known Browser and OS issues for Flash Audio</h4>
1172 <> * <b>All browsers</b><br />
1173 <> * <ul><li> There can be a delay in flash player starting playback of audio. This has been most noticeable in Firefox.
1174 <> * Unfortunely this is an issue with the flash player and the browser and therefore cannot be addressed by SoundJS.</li></ul>
1175 <> *
1176 <> * @class FlashAudioPlugin
1177 <> * @extends AbstractPlugin
1178 <> * @constructor
1179 <> */
1180 <> function FlashAudioPlugin() {
1181 <> this.AbstractPlugin_constructor();
1182  
1183  
1184 <>// Public Properties
1185 <> /**
1186 <> * A developer flag to output all flash events to the console (if it exists). Used for debugging.
1187 <> *
1188 <> * createjs.Sound.activePlugin.showOutput = true;
1189 <> *
1190 <> * @property showOutput
1191 <> * @type {Boolean}
1192 <> * @default false
1193 <> */
1194 <> this.showOutput = false;
1195  
1196  
1197 <>//Private Properties
1198 <> /**
1199 <> * The id name of the DIV that gets created for Flash content.
1200 <> * @property _CONTAINER_ID
1201 <> * @type {String}
1202 <> * @default flashAudioContainer
1203 <> * @protected
1204 <> */
1205 <> this._CONTAINER_ID = "flashAudioContainer";
1206  
1207 <> /**
1208 <> * The id name of the DIV wrapper that contains the Flash content.
1209 <> * @property _WRAPPER_ID
1210 <> * @type {String}
1211 <> * @default SoundJSFlashContainer
1212 <> * @protected
1213 <> * @since 0.4.1
1214 <> */
1215 <> this._WRAPPER_ID = "SoundJSFlashContainer";
1216  
1217 <> /**
1218 <> * A reference to the DIV container that gets created to hold the Flash instance.
1219 <> * @property _container
1220 <> * @type {HTMLDivElement}
1221 <> * @protected
1222 <> */
1223 <> this._container = null,
1224  
1225 <> /**
1226 <> * A reference to the Flash instance that gets created.
1227 <> * @property flash
1228 <> * @type {Object | Embed}
1229 <> * @protected
1230 <> */
1231 <> this._flash = null;
1232  
1233 <> /**
1234 <> * Determines if the Flash object has been created and initialized. This is required to make <code>ExternalInterface</code>
1235 <> * calls from JavaScript to Flash.
1236 <> * @property flashReady
1237 <> * @type {Boolean}
1238 <> * @default false
1239 <> */
1240 <> this.flashReady = false;
1241  
1242 <> /**
1243 <> * A hash of SoundInstances indexed by the related ID in Flash. This lookup is required to connect sounds in
1244 <> * JavaScript to their respective instances in Flash.
1245 <> * @property _flashInstances
1246 <> * @type {Object}
1247 <> * @protected
1248 <> */
1249 <> this._flashInstances = {};
1250  
1251 <> /**
1252 <> * A hash of Sound Preload instances indexed by the related ID in Flash. This lookup is required to connect
1253 <> * a preloading sound in Flash with its respective instance in JavaScript.
1254 <> * @property _flashPreloadInstances
1255 <> * @type {Object}
1256 <> * @protected
1257 <> */
1258 <> this._flashPreloadInstances = {};
1259 <> //TODO consider combining _flashInstances and _flashPreloadInstances into a single hash
1260  
1261 <> this._capabilities = s._capabilities;
1262  
1263 <> this._loaderClass = createjs.FlashAudioLoader;
1264 <> this._soundInstanceClass = createjs.FlashAudioSoundInstance;
1265  
1266 <> // Create DIV
1267 <> var w = this.wrapper = document.createElement("div");
1268 <> w.id = this._WRAPPER_ID;
1269 <> w.style.position = "absolute";
1270 <> w.style.marginLeft = "-1px";
1271 <> w.className = this._WRAPPER_ID;
1272 <> document.body.appendChild(w);
1273  
1274 <> // Create Placeholder
1275 <> var c = this._container = document.createElement("div");
1276 <> c.id = this._CONTAINER_ID;
1277 <> c.appendChild(document.createTextNode("SoundJS Flash Container"));
1278 <> w.appendChild(c);
1279  
1280 <> var path = s.swfPath;
1281 <> var val = swfobject.embedSWF(path + "FlashAudioPlugin.swf", this._CONTAINER_ID, "1", "1",
1282 <> "9.0.0", null, null, {"AllowScriptAccess" : "always"}, null,
1283 <> createjs.proxy(this._handleSWFReady, this)
1284 <> );
1285 <> };
1286  
1287 <> var p = createjs.extend(FlashAudioPlugin, createjs.AbstractPlugin);
1288 <> var s = FlashAudioPlugin;
1289  
1290 <> // TODO: deprecated
1291 <> // p.initialize = function() {}; // searchable for devs wondering where it is. REMOVED. See docs for details.
1292  
1293  
1294 <>// Static properties
1295 <> /**
1296 <> * Event constant for the "registerFlashID" event for cleaner code.
1297 <> * @property _REG_FLASHID
1298 <> * @type {String}
1299 <> * @default registerflashid
1300 <> * @static
1301 <> * @protected
1302 <> */
1303 <> s._REG_FLASHID = "registerflashid";
1304  
1305 <> /**
1306 <> * Event constant for the "unregisterFlashID" event for cleaner code.
1307 <> * @property _UNREG_FLASHID
1308 <> * @type {String}
1309 <> * @default unregisterflashid
1310 <> * @static
1311 <> * @protected
1312 <> */
1313 <> s._UNREG_FLASHID = "unregisterflashid";
1314  
1315 <> /**
1316 <> * The capabilities of the plugin. This is generated via the {{#crossLink "WebAudioPlugin/_generateCapabilities"}}{{/crossLink}}
1317 <> * method. Please see the Sound {{#crossLink "Sound/getCapabilities"}}{{/crossLink}} method for a list of available
1318 <> * capabilities.
1319 <> * @property _capabilities
1320 <> * @type {Object}
1321 <> * @protected
1322 <> * @static
1323 <> */
1324 <> s._capabilities = null;
1325  
1326 <> /**
1327 <> * The path relative to the HTML page that the FlashAudioPlugin.swf resides. Note if this is not correct, this
1328 <> * plugin will not work.
1329 <> * @property swfPath
1330 <> * @type {String}
1331 <> * @default src/SoundJS
1332 <> * @static
1333 <> * @since 0.5.2
1334 <> */
1335 <> s.swfPath = "src/soundjs/flashaudio/";
1336  
1337  
1338 <>// Static Methods
1339 <> /**
1340 <> * Determine if the plugin can be used in the current browser/OS.
1341 <> * @method isSupported
1342 <> * @return {Boolean} If the plugin can be initialized.
1343 <> * @static
1344 <> */
1345 <> s.isSupported = function () {
1346 <> // there is no flash player on mobile devices
1347 <> if (createjs.BrowserDetect.isIOS || createjs.BrowserDetect.isAndroid || createjs.BrowserDetect.isBlackberry || createjs.BrowserDetect.isWindowsPhone) {return false;}
1348 <> s._generateCapabilities();
1349 <> if (swfobject == null) {return false;}
1350 <> return swfobject.hasFlashPlayerVersion("9.0.0");
1351 <> };
1352  
1353 <> /**
1354 <> * Determine the capabilities of the plugin. Used internally. Please see the Sound API {{#crossLink "Sound/getCapabilities"}}{{/crossLink}}
1355 <> * method for an overview of plugin capabilities.
1356 <> * @method _generateCapabilities
1357 <> * @static
1358 <> * @protected
1359 <> */
1360 <> s._generateCapabilities = function () {
1361 <> if (s._capabilities != null) {return;}
1362 <> var c = s._capabilities = {
1363 <> panning:true,
1364 <> volume:true,
1365 <> tracks:-1,
1366 <> mp3:true,
1367 <> ogg:false,
1368 <> mpeg:true,
1369 <> wav:true,
1370 <> // our current implementation cannot support mp4 http://forums.adobe.com/thread/825408
1371 <> m4a:false,
1372 <> mp4:false,
1373 <> aiff:false, // not listed in player but is Supported by Flash so this may be true
1374 <> wma:false,
1375 <> mid:false
1376 <> };
1377 <> };
1378  
1379  
1380 <>//public methods
1381 <> p.register = function (src, instances) {
1382 <> var loader = this.AbstractPlugin_register(src, instances);
1383 <> loader.addEventListener(s._REG_FLASHID, createjs.proxy(this.registerPreloadInstance, this));
1384 <> loader.addEventListener(s._UNREG_FLASHID, createjs.proxy(this.unregisterPreloadInstance, this));
1385 <> return loader;
1386 <> };
1387  
1388 <> p.removeAllSounds = function () {
1389 <> this._flashInstances = {};
1390 <> this._flashPreloadInstances = {};
1391 <> // NOTE sound cannot be removed from a swf
1392  
1393 <> this.AbstractPlugin_removeAllSounds();
1394 <> };
1395  
1396 <> p.create = function (src, startTime, duration) {
1397 <> var si = this.AbstractPlugin_create(src, startTime, duration);
1398 <> si.on(s._REG_FLASHID, this.registerSoundInstance, this);
1399 <> si.on(s._UNREG_FLASHID, this.unregisterSoundInstance, this);
1400 <> return si;
1401 <> };
1402  
1403 <> p.toString = function () {
1404 <> return "[FlashAudioPlugin]";
1405 <> };
1406  
1407  
1408 <>// private methods
1409 <> /**
1410 <> * The SWF used for sound preloading and playback has been initialized.
1411 <> * @method _handleSWFReady
1412 <> * @param {Object} event Contains a reference to the swf.
1413 <> * @protected
1414 <> */
1415 <> p._handleSWFReady = function (event) {
1416 <> this._flash = event.ref;
1417 <> };
1418  
1419 <> /**
1420 <> * The Flash application that handles preloading and playback is ready. We wait for a callback from Flash to
1421 <> * ensure that everything is in place before playback begins.
1422 <> * @method _handleFlashReady
1423 <> * @protected
1424 <> */
1425 <> p._handleFlashReady = function () {
1426 <> this.flashReady = true;
1427  
1428 <> this._loaderClass.setFlash(this._flash);
1429 <> this._soundInstanceClass.setFlash(this._flash);
1430 <> };
1431  
1432 <> /**
1433 <> * Internal function used to set the gain value for master audio. Should not be called externally.
1434 <> * @method _updateVolume
1435 <> * @return {Boolean}
1436 <> * @protected
1437 <> * @since 0.4.0
1438 <> */
1439 <> p._updateVolume = function () {
1440 <> var newVolume = createjs.Sound._masterMute ? 0 : this._volume;
1441 <> return this._flash.setMasterVolume(newVolume);
1442 <> };
1443  
1444  
1445 <>// Flash Communication
1446 <>// Note we have decided not to include these in the docs
1447 <> /*
1448 <> * Used to couple a Flash loader instance with a <code>Loader</code> instance
1449 <> * @method registerPreloadInstance
1450 <> * @param {String} flashId Used to identify the Loader.
1451 <> * @param {Loader} instance The actual instance.
1452 <> */
1453 <> p.registerPreloadInstance = function (event) {
1454 <> this._flashPreloadInstances[event.target.flashId] = event.target;
1455 <> };
1456  
1457 <> /*
1458 <> * Used to decouple a <code>Loader</code> instance from Flash.
1459 <> * @method unregisterPreloadInstance
1460 <> * @param {String} flashId Used to identify the Loader.
1461 <> */
1462 <> p.unregisterPreloadInstance = function (event) {
1463 <> delete this._flashPreloadInstances[event.target.flashId];
1464 <> };
1465  
1466 <> /*
1467 <> * Used to couple a Flash sound instance with a {{#crossLink "FlashAudioSoundInstance"}}{{/crossLink}}.
1468 <> * @method registerSoundInstance
1469 <> * @param {String} flashId Used to identify the FlashAudioSoundInstance.
1470 <> * @param {Loader} instance The actual instance.
1471 <> */
1472 <> p.registerSoundInstance = function (event) {
1473 <> this._flashInstances[event.target.flashId] = event.target;
1474 <> };
1475  
1476 <> /*
1477 <> * Used to decouple a {{#crossLink "FlashAudioSoundInstance"}}{{/crossLink}} from Flash.
1478 <> * instance.
1479 <> * @method unregisterSoundInstance
1480 <> * @param {String} flashId Used to identify the FlashAudioSoundInstance.
1481 <> * @param {Loader} instance The actual instance.
1482 <> */
1483 <> p.unregisterSoundInstance = function (event) {
1484 <> delete this._flashInstances[event.target.flashId];
1485 <> };
1486  
1487 <> /*
1488 <> * Used to output traces from Flash to the console, if {{#crossLink "FlashAudioPlugin/showOutput"}}{{/crossLink}} is
1489 <> * <code>true</code>.
1490 <> * @method flashLog
1491 <> * @param {String} data The information to be output.
1492 <> */
1493 <> p.flashLog = function (data) {
1494 <> try {
1495 <> this.showOutput && console.log(data);
1496 <> } catch (error) {
1497 <> // older IE will cause error if console is not open
1498 <> }
1499 <> };
1500  
1501 <> /*
1502 <> * Handles events from Flash, and routes communication to a {{#crossLink "FlashAudioSoundInstance"}}{{/crossLink}} via
1503 <> * the Flash ID. The method and arguments from Flash are run directly on the loader or sound instance.
1504 <> * @method handleSoundEvent
1505 <> * @param {String} flashId Used to identify the FlashAudioSoundInstance.
1506 <> * @param {String} method Indicates the method to run.
1507 <> */
1508 <> p.handleSoundEvent = function (flashId, method) {
1509 <> var instance = this._flashInstances[flashId];
1510 <> if (instance == null) {return;}
1511 <> var args = [];
1512 <> for (var i = 2, l = arguments.length; i < l; i++) {
1513 <> args.push(arguments[i]);
1514 <> }
1515 <> try {
1516 <> if (args.length == 0) {
1517 <> instance[method]();
1518 <> } else {
1519 <> instance[method].apply(instance, args);
1520 <> }
1521 <> } catch (error) {
1522 <> }
1523 <> };
1524  
1525 <> /*
1526 <> * Handles events from Flash and routes communication to a <code>Loader</code> via the Flash ID. The method
1527 <> * and arguments from Flash are run directly on the sound loader.
1528 <> * @method handlePreloadEvent
1529 <> * @param {String} flashId Used to identify the loader instance.
1530 <> * @param {String} method Indicates the method to run.
1531 <> */
1532 <> p.handlePreloadEvent = function (flashId, method) {
1533 <> var instance = this._flashPreloadInstances[flashId];
1534 <> if (instance == null) {
1535 <> return;
1536 <> }
1537 <> var args = [];
1538 <> for (var i = 2, l = arguments.length; i < l; i++) {
1539 <> args.push(arguments[i]);
1540 <> }
1541 <> try {
1542 <> if (args.length == 0) {
1543 <> instance[method]();
1544 <> } else {
1545 <> instance[method].apply(instance, args);
1546 <> }
1547 <> } catch (error) {
1548 <> }
1549 <> };
1550  
1551 <> /*
1552 <> * Handles events from Flash intended for the FlashAudioPlugin class. Currently only a "ready" event is processed.
1553 <> * @method handleEvent
1554 <> * @param {String} method Indicates the method to run.
1555 <> */
1556 <> p.handleEvent = function (method) {
1557 <> switch (method) {
1558 <> case "ready":
1559 <> this._handleFlashReady();
1560 <> break;
1561 <> }
1562 <> };
1563  
1564 <> /*
1565 <> * Handles error events from Flash. Note this function currently does not process any events.
1566 <> * @method handleErrorEvent
1567 <> * @param {String} error Indicates the error.
1568 <> */
1569 <> p.handleErrorEvent = function (error) {
1570  
1571 <> };
1572  
1573 <> createjs.FlashAudioPlugin = createjs.promote(FlashAudioPlugin, "AbstractPlugin");
1574 <>}());
1575  
1576 <>//##############################################################################
1577 <>// version_flashplugin.js
1578 <>//##############################################################################
1579  
1580 <>this.createjs = this.createjs || {};
1581  
1582 <>(function () {
1583  
1584 <> var s = createjs.FlashAudioPlugin = createjs.FlashAudioPlugin || {};
1585  
1586 <> /**
1587 <> * The version string for this release.
1588 <> * @for FlashAudioPlugin
1589 <> * @property version
1590 <> * @type String
1591 <> * @static
1592 <> **/
1593 <> s.version = /*=version*/"0.6.2"; // injected by build process
1594  
1595 <> /**
1596 <> * The build date for this release in UTC format.
1597 <> * @for FlashAudioPlugin
1598 <> * @property buildDate
1599 <> * @type String
1600 <> * @static
1601 <> **/
1602 <> s.buildDate = /*=date*/"Thu, 26 Nov 2015 20:44:31 GMT"; // injected by build process
1603  
1604 <>})();