PageSourceSearch

https://phish.com/wp-content/themes/phish/assets/js/soundmanager2/soundmanager2-nodebug.js?ver=4.3

js phish.com collected 2026-10-02 02:53:54 UTC 79,936 bytes, 2,643 lines download raw bytes

1/** @license
2 *
3 * SoundManager 2: JavaScript Sound for the Web
4 * ----------------------------------------------
5 * http://schillmania.com/projects/soundmanager2/
6 *
7 * Copyright (c) 2007, Scott Schiller. All rights reserved.
8 * Code provided under the BSD License:
9 * http://schillmania.com/projects/soundmanager2/license.txt
10 *
11 * V2.97a.20130512
12 */
13
14/*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio, opera */
15/*jslint regexp: true, sloppy: true, white: true, nomen: true, plusplus: true, todo: true */
16
17(function(window, _undefined) {
18"use strict";
19var soundManager = null;
20function SoundManager(smURL, smID) {
21  this.setupOptions = {
22    'url': (smURL || null),
23    'flashVersion': 8,
24    'debugMode': true,
25    'debugFlash': false,
26    'useConsole': true,
27    'consoleOnly': true,
28    'waitForWindowLoad': false,
29    'bgColor': '#ffffff',
30    'useHighPerformance': false,
31    'flashPollingInterval': null,
32    'html5PollingInterval': null,
33    'flashLoadTimeout': 1000,
34    'wmode': null,
35    'allowScriptAccess': 'always',
36    'useFlashBlock': false,
37    'useHTML5Audio': true,
38    'html5Test': /^(probably|maybe)$/i,
39    'preferFlash': true,
40    'noSWFCache': false,
41    'idPrefix': 'sound'
42  };
43  this.defaultOptions = {
44    'autoLoad': false,
45    'autoPlay': false,
46    'from': null,
47    'loops': 1,
48    'onid3': null,
49    'onload': null,
50    'whileloading': null,
51    'onplay': null,
52    'onpause': null,
53    'onresume': null,
54    'whileplaying': null,
55    'onposition': null,
56    'onstop': null,
57    'onfailure': null,
58    'onfinish': null,
59    'multiShot': true,
60    'multiShotEvents': false,
61    'position': null,
62    'pan': 0,
63    'stream': true,
64    'to': null,
65    'type': null,
66    'usePolicyFile': false,
67    'volume': 100
68  };
69  this.flash9Options = {
70    'isMovieStar': null,
71    'usePeakData': false,
72    'useWaveformData': false,
73    'useEQData': false,
74    'onbufferchange': null,
75    'ondataerror': null
76  };
77  this.movieStarOptions = {
78    'bufferTime': 3,
79    'serverURL': null,
80    'onconnect': null,
81    'duration': null
82  };
83  this.audioFormats = {
84    'mp3': {
85      'type': ['audio/mpeg; codecs="mp3"', 'audio/mpeg', 'audio/mp3', 'audio/MPA', 'audio/mpa-robust'],
86      'required': true
87    },
88    'mp4': {
89      'related': ['aac','m4a','m4b'],
90      'type': ['audio/mp4; codecs="mp4a.40.2"', 'audio/aac', 'audio/x-m4a', 'audio/MP4A-LATM', 'audio/mpeg4-generic'],
91      'required': false
92    },
93    'ogg': {
94      'type': ['audio/ogg; codecs=vorbis'],
95      'required': false
96    },
97    'opus': {
98      'type': ['audio/ogg; codecs=opus', 'audio/opus'],
99      'required': false
100    },
101    'wav': {
102      'type': ['audio/wav; codecs="1"', 'audio/wav', 'audio/wave', 'audio/x-wav'],
103      'required': false
104    }
105  };
106  this.movieID = 'sm2-container';
107  this.id = (smID || 'sm2movie');
108  this.debugID = 'soundmanager-debug';
109  this.debugURLParam = /([#?&])debug=1/i;
110  this.versionNumber = 'V2.97a.20130512';
111  this.version = null;
112  this.movieURL = null;
113  this.altURL = null;
114  this.swfLoaded = false;
115  this.enabled = false;
116  this.oMC = null;
117  this.sounds = {};
118  this.soundIDs = [];
119  this.muted = false;
120  this.didFlashBlock = false;
121  this.filePattern = null;
122  this.filePatterns = {
123    'flash8': /\.mp3(\?.*)?$/i,
124    'flash9': /\.mp3(\?.*)?$/i
125  };
126  this.features = {
127    'buffering': false,
128    'peakData': false,
129    'waveformData': false,
130    'eqData': false,
131    'movieStar': false
132  };
133  this.sandbox = {
134  };
135  this.html5 = {
136    'usingFlash': null
137  };
138  this.flash = {};
139  this.html5Only = false;
140  this.ignoreFlash = false;
141  var SMSound,
142  sm2 = this, globalHTML5Audio = null, flash = null, sm = 'soundManager', smc = sm + ': ', h5 = 'HTML5::', id, ua = navigator.userAgent, wl = window.location.href.toString(), doc = document, doNothing, setProperties, init, fV, on_queue = [], debugOpen = true, debugTS, didAppend = false, appendSuccess = false, didInit = false, disabled = false, windowLoaded = false, _wDS, wdCount = 0, initComplete, mixin, assign, extraOptions, addOnEvent, processOnEvents, initUserOnload, delayWaitForEI, waitForEI, setVersionInfo, handleFocus, strings, initMovie, preInit, domContentLoaded, winOnLoad, didDCLoaded, getDocument, createMovie, catchError, setPolling, initDebug, debugLevels = ['log', 'info', 'warn', 'error'], defaultFlashVersion = 8, disableObject, failSafely, normalizeMovieURL, oRemoved = null, oRemovedHTML = null, str, flashBlockHandler, getSWFCSS, swfCSS, toggleDebug, loopFix, policyFix, complain, idCheck, waitingForEI = false, initPending = false, startTimer, stopTimer, timerExecute, h5TimerCount = 0, h5IntervalTimer = null, parseURL, messages = [],
143  canIgnoreFlash, needsFlash = null, featureCheck, html5OK, html5CanPlay, html5Ext, html5Unload, domContentLoadedIE, testHTML5, event, slice = Array.prototype.slice, useGlobalHTML5Audio = false, lastGlobalHTML5URL, hasFlash, detectFlash, badSafariFix, html5_events, showSupport, flushMessages, wrapCallback, idCounter = 0,
144  is_iDevice = ua.match(/(ipad|iphone|ipod)/i), isAndroid = ua.match(/android/i), isIE = ua.match(/msie/i), isWebkit = ua.match(/webkit/i), isSafari = (ua.match(/safari/i) && !ua.match(/chrome/i)), isOpera = (ua.match(/opera/i)), isFirefox = (ua.match(/firefox/i)),
145  mobileHTML5 = (ua.match(/(mobile|pre\/|xoom)/i) || is_iDevice || isAndroid),
146  isBadSafari = (!wl.match(/usehtml5audio/i) && !wl.match(/sm2\-ignorebadua/i) && isSafari && !ua.match(/silk/i) && ua.match(/OS X 10_6_([3-7])/i)),
147  hasConsole = (window.console !== _undefined && console.log !== _undefined), isFocused = (doc.hasFocus !== _undefined?doc.hasFocus():null), tryInitOnFocus = (isSafari && (doc.hasFocus === _undefined || !doc.hasFocus())), okToDisable = !tryInitOnFocus, flashMIME = /(mp3|mp4|mpa|m4a|m4b)/i, msecScale = 1000,
148  emptyURL = 'about:blank',
149  overHTTP = (doc.location?doc.location.protocol.match(/http/i):null),
150  http = (!overHTTP ? 'http:/'+'/' : ''),
151  netStreamMimeTypes = /^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i,
152  netStreamTypes = ['mpeg4', 'aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', 'm4b', 'mp4v', '3gp', '3g2'],
153  netStreamPattern = new RegExp('\\.(' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i');
154  this.mimePattern = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;
155  this.useAltURL = !overHTTP;
156  swfCSS = {
157    'swfBox': 'sm2-object-box',
158    'swfDefault': 'movieContainer',
159    'swfError': 'swf_error',
160    'swfTimedout': 'swf_timedout',
161    'swfLoaded': 'swf_loaded',
162    'swfUnblocked': 'swf_unblocked',
163    'sm2Debug': 'sm2_debug',
164    'highPerf': 'high_performance',
165    'flashDebug': 'flash_debug'
166  };
167  this.hasHTML5 = (function() {
168    try {
169      return (Audio !== _undefined && (isOpera && opera !== _undefined && opera.version() < 10 ? new Audio(null) : new Audio()).canPlayType !== _undefined);
170    } catch(e) {
171      return false;
172    }
173  }());
174  this.setup = function(options) {
175    var noURL = (!sm2.url);
176    if (options !== _undefined && didInit && needsFlash && sm2.ok() && (options.flashVersion !== _undefined || options.url !== _undefined || options.html5Test !== _undefined)) {
177    }
178    assign(options);
179    if (options) {
180      if (noURL && didDCLoaded && options.url !== _undefined) {
181        sm2.beginDelayedInit();
182      }
183      if (!didDCLoaded && options.url !== _undefined && doc.readyState === 'complete') {
184        setTimeout(domContentLoaded, 1);
185      }
186    }
187    return sm2;
188  };
189  this.ok = function() {
190    return (needsFlash ? (didInit && !disabled) : (sm2.useHTML5Audio && sm2.hasHTML5));
191  };
192  this.supported = this.ok;
193  this.getMovie = function(smID) {
194    return id(smID) || doc[smID] || window[smID];
195  };
196  this.createSound = function(oOptions, _url) {
197    var cs, cs_string, options, oSound = null;
198    if (!didInit || !sm2.ok()) {
199      return false;
200    }
201    if (_url !== _undefined) {
202      oOptions = {
203        'id': oOptions,
204        'url': _url
205      };
206    }
207    options = mixin(oOptions);
208    options.url = parseURL(options.url);
209    if (options.id === undefined) {
210      options.id = sm2.setupOptions.idPrefix + (idCounter++);
211    }
212    if (idCheck(options.id, true)) {
213      return sm2.sounds[options.id];
214    }
215    function make() {
216      options = loopFix(options);
217      sm2.sounds[options.id] = new SMSound(options);
218      sm2.soundIDs.push(options.id);
219      return sm2.sounds[options.id];
220    }
221    if (html5OK(options)) {
222      oSound = make();
223      oSound._setup_html5(options);
224    } else {
225      if (sm2.html5Only) {
226        return make();
227      }
228      if (sm2.html5.usingFlash && options.url && options.url.match(/data\:/i)) {
229        return make();
230      }
231      if (fV > 8) {
232        if (options.isMovieStar === null) {
233          options.isMovieStar = !!(options.serverURL || (options.type ? options.type.match(netStreamMimeTypes) : false) || (options.url && options.url.match(netStreamPattern)));
234        }
235      }
236      options = policyFix(options, cs);
237      oSound = make();
238      if (fV === 8) {
239        flash._createSound(options.id, options.loops||1, options.usePolicyFile);
240      } else {
241        flash._createSound(options.id, options.url, options.usePeakData, options.useWaveformData, options.useEQData, options.isMovieStar, (options.isMovieStar?options.bufferTime:false), options.loops||1, options.serverURL, options.duration||null, options.autoPlay, true, options.autoLoad, options.usePolicyFile);
242        if (!options.serverURL) {
243          oSound.connected = true;
244          if (options.onconnect) {
245            options.onconnect.apply(oSound);
246          }
247        }
248      }
249      if (!options.serverURL && (options.autoLoad || options.autoPlay)) {
250        oSound.load(options);
251      }
252    }
253    if (!options.serverURL && options.autoPlay) {
254      oSound.play();
255    }
256    return oSound;
257  };
258  this.destroySound = function(sID, _bFromSound) {
259    if (!idCheck(sID)) {
260      return false;
261    }
262    var oS = sm2.sounds[sID], i;
263    oS._iO = {};
264    oS.stop();
265    oS.unload();
266    for (i = 0; i < sm2.soundIDs.length; i++) {
267      if (sm2.soundIDs[i] === sID) {
268        sm2.soundIDs.splice(i, 1);
269        break;
270      }
271    }
272    if (!_bFromSound) {
273      oS.destruct(true);
274    }
275    oS = null;
276    delete sm2.sounds[sID];
277    return true;
278  };
279  this.load = function(sID, oOptions) {
280    if (!idCheck(sID)) {
281      return false;
282    }
283    return sm2.sounds[sID].load(oOptions);
284  };
285  this.unload = function(sID) {
286    if (!idCheck(sID)) {
287      return false;
288    }
289    return sm2.sounds[sID].unload();
290  };
291  this.onPosition = function(sID, nPosition, oMethod, oScope) {
292    if (!idCheck(sID)) {
293      return false;
294    }
295    return sm2.sounds[sID].onposition(nPosition, oMethod, oScope);
296  };
297  this.onposition = this.onPosition;
298  this.clearOnPosition = function(sID, nPosition, oMethod) {
299    if (!idCheck(sID)) {
300      return false;
301    }
302    return sm2.sounds[sID].clearOnPosition(nPosition, oMethod);
303  };
304  this.play = function(sID, oOptions) {
305    var result = null,
306        overloaded = (oOptions && !(oOptions instanceof Object));
307    if (!didInit || !sm2.ok()) {
308      return false;
309    }
310    if (!idCheck(sID, overloaded)) {
311      if (!overloaded) {
312        return false;
313      }
314      if (overloaded) {
315        oOptions = {
316          url: oOptions
317        };
318      }
319      if (oOptions && oOptions.url) {
320        oOptions.id = sID;
321        result = sm2.createSound(oOptions).play();
322      }
323    } else if (overloaded) {
324      oOptions = {
325        url: oOptions
326      };
327    }
328    if (result === null) {
329      result = sm2.sounds[sID].play(oOptions);
330    }
331    return result;
332  };
333  this.start = this.play;
334  this.setPosition = function(sID, nMsecOffset) {
335    if (!idCheck(sID)) {
336      return false;
337    }
338    return sm2.sounds[sID].setPosition(nMsecOffset);
339  };
340  this.stop = function(sID) {
341    if (!idCheck(sID)) {
342      return false;
343    }
344    return sm2.sounds[sID].stop();
345  };
346  this.stopAll = function() {
347    var oSound;
348    for (oSound in sm2.sounds) {
349      if (sm2.sounds.hasOwnProperty(oSound)) {
350        sm2.sounds[oSound].stop();
351      }
352    }
353  };
354  this.pause = function(sID) {
355    if (!idCheck(sID)) {
356      return false;
357    }
358    return sm2.sounds[sID].pause();
359  };
360  this.pauseAll = function() {
361    var i;
362    for (i = sm2.soundIDs.length-1; i >= 0; i--) {
363      sm2.sounds[sm2.soundIDs[i]].pause();
364    }
365  };
366  this.resume = function(sID) {
367    if (!idCheck(sID)) {
368      return false;
369    }
370    return sm2.sounds[sID].resume();
371  };
372  this.resumeAll = function() {
373    var i;
374    for (i = sm2.soundIDs.length-1; i >= 0; i--) {
375      sm2.sounds[sm2.soundIDs[i]].resume();
376    }
377  };
378  this.togglePause = function(sID) {
379    if (!idCheck(sID)) {
380      return false;
381    }
382    return sm2.sounds[sID].togglePause();
383  };
384  this.setPan = function(sID, nPan) {
385    if (!idCheck(sID)) {
386      return false;
387    }
388    return sm2.sounds[sID].setPan(nPan);
389  };
390  this.setVolume = function(sID, nVol) {
391    if (!idCheck(sID)) {
392      return false;
393    }
394    return sm2.sounds[sID].setVolume(nVol);
395  };
396  this.mute = function(sID) {
397    var i = 0;
398    if (sID instanceof String) {
399      sID = null;
400    }
401    if (!sID) {
402      for (i = sm2.soundIDs.length-1; i >= 0; i--) {
403        sm2.sounds[sm2.soundIDs[i]].mute();
404      }
405      sm2.muted = true;
406    } else {
407      if (!idCheck(sID)) {
408        return false;
409      }
410      return sm2.sounds[sID].mute();
411    }
412    return true;
413  };
414  this.muteAll = function() {
415    sm2.mute();
416  };
417  this.unmute = function(sID) {
418    var i;
419    if (sID instanceof String) {
420      sID = null;
421    }
422    if (!sID) {
423      for (i = sm2.soundIDs.length-1; i >= 0; i--) {
424        sm2.sounds[sm2.soundIDs[i]].unmute();
425      }
426      sm2.muted = false;
427    } else {
428      if (!idCheck(sID)) {
429        return false;
430      }
431      return sm2.sounds[sID].unmute();
432    }
433    return true;
434  };
435  this.unmuteAll = function() {
436    sm2.unmute();
437  };
438  this.toggleMute = function(sID) {
439    if (!idCheck(sID)) {
440      return false;
441    }
442    return sm2.sounds[sID].toggleMute();
443  };
444  this.getMemoryUse = function() {
445    var ram = 0;
446    if (flash && fV !== 8) {
447      ram = parseInt(flash._getMemoryUse(), 10);
448    }
449    return ram;
450  };
451  this.disable = function(bNoDisable) {
452    var i;
453    if (bNoDisable === _undefined) {
454      bNoDisable = false;
455    }
456    if (disabled) {
457      return false;
458    }
459    disabled = true;
460    for (i = sm2.soundIDs.length-1; i >= 0; i--) {
461      disableObject(sm2.sounds[sm2.soundIDs[i]]);
462    }
463    initComplete(bNoDisable);
464    event.remove(window, 'load', initUserOnload);
465    return true;
466  };
467  this.canPlayMIME = function(sMIME) {
468    var result;
469    if (sm2.hasHTML5) {
470      result = html5CanPlay({type:sMIME});
471    }
472    if (!result && needsFlash) {
473      result = (sMIME && sm2.ok() ? !!((fV > 8 ? sMIME.match(netStreamMimeTypes) : null) || sMIME.match(sm2.mimePattern)) : null);
474    }
475    return result;
476  };
477  this.canPlayURL = function(sURL) {
478    var result;
479    if (sm2.hasHTML5) {
480      result = html5CanPlay({url: sURL});
481    }
482    if (!result && needsFlash) {
483      result = (sURL && sm2.ok() ? !!(sURL.match(sm2.filePattern)) : null);
484    }
485    return result;
486  };
487  this.canPlayLink = function(oLink) {
488    if (oLink.type !== _undefined && oLink.type) {
489      if (sm2.canPlayMIME(oLink.type)) {
490        return true;
491      }
492    }
493    return sm2.canPlayURL(oLink.href);
494  };
495  this.getSoundById = function(sID, _suppressDebug) {
496    if (!sID) {
497      return null;
498    }
499    var result = sm2.sounds[sID];
500    return result;
501  };
502  this.onready = function(oMethod, oScope) {
503    var sType = 'onready',
504        result = false;
505    if (typeof oMethod === 'function') {
506      if (!oScope) {
507        oScope = window;
508      }
509      addOnEvent(sType, oMethod, oScope);
510      processOnEvents();
511      result = true;
512    } else {
513      throw str('needFunction', sType);
514    }
515    return result;
516  };
517  this.ontimeout = function(oMethod, oScope) {
518    var sType = 'ontimeout',
519        result = false;
520    if (typeof oMethod === 'function') {
521      if (!oScope) {
522        oScope = window;
523      }
524      addOnEvent(sType, oMethod, oScope);
525      processOnEvents({type:sType});
526      result = true;
527    } else {
528      throw str('needFunction', sType);
529    }
530    return result;
531  };
532  this._writeDebug = function(sText, sTypeOrObject) {
533    return true;
534  };
535  this._wD = this._writeDebug;
536  this._debug = function() {
537  };
538  this.reboot = function(resetEvents, excludeInit) {
539    var i, j, k;
540    for (i = sm2.soundIDs.length-1; i >= 0; i--) {
541      sm2.sounds[sm2.soundIDs[i]].destruct();
542    }
543    if (flash) {
544      try {
545        if (isIE) {
546          oRemovedHTML = flash.innerHTML;
547        }
548        oRemoved = flash.parentNode.removeChild(flash);
549      } catch(e) {
550      }
551    }
552    oRemovedHTML = oRemoved = needsFlash = flash = null;
553    sm2.enabled = didDCLoaded = didInit = waitingForEI = initPending = didAppend = appendSuccess = disabled = useGlobalHTML5Audio = sm2.swfLoaded = false;
554    sm2.soundIDs = [];
555    sm2.sounds = {};
556    idCounter = 0;
557    if (!resetEvents) {
558      for (i in on_queue) {
559        if (on_queue.hasOwnProperty(i)) {
560          for (j = 0, k = on_queue[i].length; j < k; j++) {
561            on_queue[i][j].fired = false;
562          }
563        }
564      }
565    } else {
566      on_queue = [];
567    }
568    sm2.html5 = {
569      'usingFlash': null
570    };
571    sm2.flash = {};
572    sm2.html5Only = false;
573    sm2.ignoreFlash = false;
574    window.setTimeout(function() {
575      preInit();
576      if (!excludeInit) {
577        sm2.beginDelayedInit();
578      }
579    }, 20);
580    return sm2;
581  };
582  this.reset = function() {
583    return sm2.reboot(true, true);
584  };
585  this.getMoviePercent = function() {
586    return (flash && 'PercentLoaded' in flash ? flash.PercentLoaded() : null);
587  };
588  this.beginDelayedInit = function() {
589    windowLoaded = true;
590    domContentLoaded();
591    setTimeout(function() {
592      if (initPending) {
593        return false;
594      }
595      createMovie();
596      initMovie();
597      initPending = true;
598      return true;
599    }, 20);
600    delayWaitForEI();
601  };
602  this.destruct = function() {
603    sm2.disable(true);
604  };
605  SMSound = function(oOptions) {
606    var s = this, resetProperties, add_html5_events, remove_html5_events, stop_html5_timer, start_html5_timer, attachOnPosition, onplay_called = false, onPositionItems = [], onPositionFired = 0, detachOnPosition, applyFromTo, lastURL = null, lastHTML5State, urlOmitted;
607    lastHTML5State = {
608      duration: null,
609      time: null
610    };
611    this.id = oOptions.id;
612    this.sID = this.id;
613    this.url = oOptions.url;
614    this.options = mixin(oOptions);
615    this.instanceOptions = this.options;
616    this._iO = this.instanceOptions;
617    this.pan = this.options.pan;
618    this.volume = this.options.volume;
619    this.isHTML5 = false;
620    this._a = null;
621    urlOmitted = (this.url ? false : true);
622    this.id3 = {};
623    this._debug = function() {
624    };
625    this.load = function(oOptions) {
626      var oSound = null, instanceOptions;
627      if (oOptions !== _undefined) {
628        s._iO = mixin(oOptions, s.options);
629      } else {
630        oOptions = s.options;
631        s._iO = oOptions;
632        if (lastURL && lastURL !== s.url) {
633          s._iO.url = s.url;
634          s.url = null;
635        }
636      }
637      if (!s._iO.url) {
638        s._iO.url = s.url;
639      }
640      s._iO.url = parseURL(s._iO.url);
641      s.instanceOptions = s._iO;
642      instanceOptions = s._iO;
643      if (!instanceOptions.url && !s.url) {
644        return s;
645      }
646      if (instanceOptions.url === s.url && s.readyState !== 0 && s.readyState !== 2) {
647        if (s.readyState === 3 && instanceOptions.onload) {
648          wrapCallback(s, function() {
649            instanceOptions.onload.apply(s, [(!!s.duration)]);
650          });
651        }
652        return s;
653      }
654      s.loaded = false;
655      s.readyState = 1;
656      s.playState = 0;
657      s.id3 = {};
658      if (html5OK(instanceOptions)) {
659        oSound = s._setup_html5(instanceOptions);
660        if (!oSound._called_load) {
661          s._html5_canplay = false;
662          if (s.url !== instanceOptions.url) {
663            s._a.src = instanceOptions.url;
664            s.setPosition(0);
665          }
666          s._a.autobuffer = 'auto';
667          s._a.preload = 'auto';
668          s._a._called_load = true;
669          if (instanceOptions.autoPlay) {
670            s.play();
671          }
672        } else {
673        }
674      } else {
675        if (sm2.html5Only) {
676          return s;
677        }
678        if (s._iO.url && s._iO.url.match(/data\:/i)) {
679          return s;
680        }
681        try {
682          s.isHTML5 = false;
683          s._iO = policyFix(loopFix(instanceOptions));
684          instanceOptions = s._iO;
685          if (fV === 8) {
686            flash._load(s.id, instanceOptions.url, instanceOptions.stream, instanceOptions.autoPlay, instanceOptions.usePolicyFile);
687          } else {
688            flash._load(s.id, instanceOptions.url, !!(instanceOptions.stream), !!(instanceOptions.autoPlay), instanceOptions.loops||1, !!(instanceOptions.autoLoad), instanceOptions.usePolicyFile);
689          }
690        } catch(e) {
691          catchError({type:'SMSOUND_LOAD_JS_EXCEPTION', fatal:true});
692        }
693      }
694      s.url = instanceOptions.url;
695      return s;
696    };
697    this.unload = function() {
698      if (s.readyState !== 0) {
699        if (!s.isHTML5) {
700          if (fV === 8) {
701            flash._unload(s.id, emptyURL);
702          } else {
703            flash._unload(s.id);
704          }
705        } else {
706          stop_html5_timer();
707          if (s._a) {
708            s._a.pause();
709            lastURL = html5Unload(s._a);
710          }
711        }
712        resetProperties();
713      }
714      return s;
715    };
716    this.destruct = function(_bFromSM) {
717      if (!s.isHTML5) {
718        s._iO.onfailure = null;
719        flash._destroySound(s.id);
720      } else {
721        stop_html5_timer();
722        if (s._a) {
723          s._a.pause();
724          html5Unload(s._a);
725          if (!useGlobalHTML5Audio) {
726            remove_html5_events();
727          }
728          s._a._s = null;
729          s._a = null;
730        }
731      }
732      if (!_bFromSM) {
733        sm2.destroySound(s.id, true);
734      }
735    };
736    this.play = function(oOptions, _updatePlayState) {
737      var fN, allowMulti, a, onready,
738          audioClone, onended, oncanplay,
739          startOK = true,
740          exit = null;
741      _updatePlayState = (_updatePlayState === _undefined ? true : _updatePlayState);
742      if (!oOptions) {
743        oOptions = {};
744      }
745      if (s.url) {
746        s._iO.url = s.url;
747      }
748      s._iO = mixin(s._iO, s.options);
749      s._iO = mixin(oOptions, s._iO);
750      s._iO.url = parseURL(s._iO.url);
751      s.instanceOptions = s._iO;
752      if (!s.isHTML5 && s._iO.serverURL && !s.connected) {
753        if (!s.getAutoPlay()) {
754          s.setAutoPlay(true);
755        }
756        return s;
757      }
758      if (html5OK(s._iO)) {
759        s._setup_html5(s._iO);
760        start_html5_timer();
761      }
762      if (s.playState === 1 && !s.paused) {
763        allowMulti = s._iO.multiShot;
764        if (!allowMulti) {
765          if (s.isHTML5) {
766            s.setPosition(s._iO.position);
767          }
768          exit = s;
769        } else {
770        }
771      }
772      if (exit !== null) {
773        return exit;
774      }
775      if (oOptions.url && oOptions.url !== s.url) {
776        if (!s.readyState && !s.isHTML5 && fV === 8 && urlOmitted) {
777          urlOmitted = false;
778        } else {
779          s.load(s._iO);
780        }
781      }
782      if (!s.loaded) {
783        if (s.readyState === 0) {
784          if (!s.isHTML5 && !sm2.html5Only) {
785            s._iO.autoPlay = true;
786            s.load(s._iO);
787          } else if (s.isHTML5) {
788            s.load(s._iO);
789          } else {
790            exit = s;
791          }
792          s.instanceOptions = s._iO;
793        } else if (s.readyState === 2) {
794          exit = s;
795        } else {
796        }
797      } else {
798      }
799      if (exit !== null) {
800        return exit;
801      }
802      if (!s.isHTML5 && fV === 9 && s.position > 0 && s.position === s.duration) {
803        oOptions.position = 0;
804      }
805      if (s.paused && s.position >= 0 && (!s._iO.serverURL || s.position >
805 0)) {
806        s.resume();
807      } else {
808        s._iO = mixin(oOptions, s._iO);
809        if (s._iO.from !== null && s._iO.to !== null && s.instanceCount === 0 && s.playState === 0 && !s._iO.serverURL) {
810          onready = function() {
811            s._iO = mixin(oOptions, s._iO);
812            s.play(s._iO);
813          };
814          if (s.isHTML5 && !s._html5_canplay) {
815            s.load({
816              oncanplay: onready
817            });
818            exit = false;
819          } else if (!s.isHTML5 && !s.loaded && (!s.readyState || s.readyState !== 2)) {
820            s.load({
821              onload: onready
822            });
823            exit = false;
824          }
825          if (exit !== null) {
826            return exit;
827          }
828          s._iO = applyFromTo();
829        }
830        if (!s.instanceCount || s._iO.multiShotEvents || (s.isHTML5 && s._iO.multiShot && !useGlobalHTML5Audio) || (!s.isHTML5 && fV > 8 && !s.getAutoPlay())) {
831          s.instanceCount++;
832        }
833        if (s._iO.onposition && s.playState === 0) {
834          attachOnPosition(s);
835        }
836        s.playState = 1;
837        s.paused = false;
838        s.position = (s._iO.position !== _undefined && !isNaN(s._iO.position) ? s._iO.position : 0);
839        if (!s.isHTML5) {
840          s._iO = policyFix(loopFix(s._iO));
841        }
842        if (s._iO.onplay && _updatePlayState) {
843          s._iO.onplay.apply(s);
844          onplay_called = true;
845        }
846        s.setVolume(s._iO.volume, true);
847        s.setPan(s._iO.pan, true);
848        if (!s.isHTML5) {
849          startOK = flash._start(s.id, s._iO.loops || 1, (fV === 9 ? s.position : s.position / msecScale), s._iO.multiShot || false);
850          if (fV === 9 && !startOK) {
851            if (s._iO.onplayerror) {
852              s._iO.onplayerror.apply(s);
853            }
854          }
855        } else {
856          if (s.instanceCount < 2) {
857            start_html5_timer();
858            a = s._setup_html5();
859            s.setPosition(s._iO.position);
860            a.play();
861          } else {
862            audioClone = new Audio(s._iO.url);
863            onended = function() {
864              event.remove(audioClone, 'onended', onended);
865              s._onfinish(s);
866              html5Unload(audioClone);
867              audioClone = null;
868            };
869            oncanplay = function() {
870              event.remove(audioClone, 'canplay', oncanplay);
871              try {
872                audioClone.currentTime = s._iO.position/msecScale;
873              } catch(err) {
874              }
875              audioClone.play();
876            };
877            event.add(audioClone, 'ended', onended);
878            if (s._iO.position) {
879              event.add(audioClone, 'canplay', oncanplay);
880            } else {
881              audioClone.play();
882            }
883          }
884        }
885      }
886      return s;
887    };
888    this.start = this.play;
889    this.stop = function(bAll) {
890      var instanceOptions = s._iO,
891          originalPosition;
892      if (s.playState === 1) {
893        s._onbufferchange(0);
894        s._resetOnPosition(0);
895        s.paused = false;
896        if (!s.isHTML5) {
897          s.playState = 0;
898        }
899        detachOnPosition();
900        if (instanceOptions.to) {
901          s.clearOnPosition(instanceOptions.to);
902        }
903        if (!s.isHTML5) {
904          flash._stop(s.id, bAll);
905          if (instanceOptions.serverURL) {
906            s.unload();
907          }
908        } else {
909          if (s._a) {
910            originalPosition = s.position;
911            s.setPosition(0);
912            s.position = originalPosition;
913            s._a.pause();
914            s.playState = 0;
915            s._onTimer();
916            stop_html5_timer();
917          }
918        }
919        s.instanceCount = 0;
920        s._iO = {};
921        if (instanceOptions.onstop) {
922          instanceOptions.onstop.apply(s);
923        }
924      }
925      return s;
926    };
927    this.setAutoPlay = function(autoPlay) {
928      s._iO.autoPlay = autoPlay;
929      if (!s.isHTML5) {
930        flash._setAutoPlay(s.id, autoPlay);
931        if (autoPlay) {
932          if (!s.instanceCount && s.readyState === 1) {
933            s.instanceCount++;
934          }
935        }
936      }
937    };
938    this.getAutoPlay = function() {
939      return s._iO.autoPlay;
940    };
941    this.setPosition = function(nMsecOffset) {
942      if (nMsecOffset === _undefined) {
943        nMsecOffset = 0;
944      }
945      var position, position1K,
946          offset = (s.isHTML5 ? Math.max(nMsecOffset, 0) : Math.min(s.duration || s._iO.duration, Math.max(nMsecOffset, 0)));
947      s.position = offset;
948      position1K = s.position/msecScale;
949      s._resetOnPosition(s.position);
950      s._iO.position = offset;
951      if (!s.isHTML5) {
952        position = (fV === 9 ? s.position : position1K);
953        if (s.readyState && s.readyState !== 2) {
954          flash._setPosition(s.id, position, (s.paused || !s.playState), s._iO.multiSh
954ot);
955        }
956      } else if (s._a) {
957        if (s._html5_canplay) {
958          if (s._a.currentTime !== position1K) {
959            try {
960              s._a.currentTime = position1K;
961              if (s.playState === 0 || s.paused) {
962                s._a.pause();
963              }
964            } catch(e) {
965            }
966          }
967        } else if (position1K) {
968          return s;
969        }
970        if (s.paused) {
971          s._onTimer(true);
972        }
973      }
974      return s;
975    };
976    this.pause = function(_bCallFlash) {
977      if (s.paused || (s.playState === 0 && s.readyState !== 1)) {
978        return s;
979      }
980      s.paused = true;
981      if (!s.isHTML5) {
982        if (_bCallFlash || _bCallFlash === _undefined) {
983          flash._pause(s.id, s._iO.multiShot);
984        }
985      } else {
986        s._setup_html5().pause();
987        stop_html5_timer();
988      }
989      if (s._iO.onpause) {
990        s._iO.onpause.apply(s);
991      }
992      return s;
993    };
994    this.resume = function() {
995      var instanceOptions = s._iO;
996      if (!s.paused) {
997        return s;
998      }
999      s.paused = false;
1000      s.playState = 1;
1001      if (!s.isHTML5) {
1002        if (instanceOptions.isMovieStar && !instanceOptions.serverURL) {
1003          s.setPosition(s.position);
1004        }
1005        flash._pause(s.id, instanceOptions.multiShot);
1006      } else {
1007        s._setup_html5().play();
1008        start_html5_timer();
1009      }
1010      if (!onplay_called && instanceOptions.onplay) {
1011        instanceOptions.onplay.apply(s);
1012        onplay_called = true;
1013      } else if (instanceOptions.onresume) {
1014        instanceOptions.onresume.apply(s);
1015      }
1016      return s;
1017    };
1018    this.togglePause = function() {
1019      if (s.playState === 0) {
1020        s.play({
1021          position: (fV === 9 && !s.isHTML5 ? s.position : s.position / msecScale)
1022        });
1023        return s;
1024      }
1025      if (s.paused) {
1026        s.resume();
1027      } else {
1028        s.pause();
1029      }
1030      return s;
1031    };
1032    this.setPan = function(nPan, bInstanceOnly) {
1033      if (nPan === _undefined) {
1034        nPan = 0;
1035      }
1036      if (bInstanceOnly === _undefined) {
1037        bInstanceOnly = false;
1038      }
1039      if (!s.isHTML5) {
1040        flash._setPan(s.id, nPan);
1041      }
1042      s._iO.pan = nPan;
1043      if (!bInstanceOnly) {
1044        s.pan = nPan;
1045        s.options.pan = nPan;
1046      }
1047      return s;
1048    };
1049    this.setVolume = function(nVol, _bInstanceOnly) {
1050      if (nVol === _undefined) {
1051        nVol = 100;
1052      }
1053      if (_bInstanceOnly === _undefined) {
1054        _bInstanceOnly = false;
1055      }
1056      if (!s.isHTML5) {
1057        flash._setVolume(s.id, (sm2.muted && !s.muted) || s.muted?0:nVol);
1058      } else if (s._a) {
1059        s._a.volume = Math.max(0, Math.min(1, nVol/100));
1060      }
1061      s._iO.volume = nVol;
1062      if (!_bInstanceOnly) {
1063        s.volume = nVol;
1064        s.options.volume = nVol;
1065      }
1066      return s;
1067    };
1068    this.mute = function() {
1069      s.muted = true;
1070      if (!s.isHTML5) {
1071        flash._setVolume(s.id, 0);
1072      } else if (s._a) {
1073        s._a.muted = true;
1074      }
1075      return s;
1076    };
1077    this.unmute = function() {
1078      s.muted = false;
1079      var hasIO = (s._iO.volume !== _undefined);
1080      if (!s.isHTML5) {
1081        flash._setVolume(s.id, hasIO?s._iO.volume:s.options.volume);
1082      } else if (s._a) {
1083        s._a.muted = false;
1084      }
1085      return s;
1086    };
1087    this.toggleMute = function() {
1088      return (s.muted?s.unmute():s.mute());
1089    };
1090    this.onPosition = function(nPosition, oMethod, oScope) {
1091      onPositionItems.push({
1092        position: parseInt(nPosition, 10),
1093        method: oMethod,
1094        scope: (oScope !== _undefined ? oScope : s),
1095        fired: false
1096      });
1097      return s;
1098    };
1099    this.onposition = this.onPosition;
1100    this.clearOnPosition = function(nPosition, oMethod) {
1101      var i;
1102      nPosition = parseInt(nPosition, 10);
1103      if (isNaN(nPosition)) {
1104        return false;
1105      }
1106      for (i=0; i < onPositionItems.length; i++) {
1107        if (nPosition === onPositionItems[i].position) {
1108          if (!oMethod || (oMethod === onPositionItems[i].method)) {
1109            if (onPositionItems[i].fired) {
1110              onPositionFired--;
1111            }
1112            onPositionItems.splice(i, 1);
1113          }
1114        }
1115      }
1116    };
1117    this._processOnPosition = function() {
1118      var i, item, j = onPositionItems.length;
1119      if (!j || !s.playState || onPositionFired >= j) {
1120        return false;
1121      }
1122      for (i=j-1; i >= 0; i--) {
1123        item = onPositionItems[i];
1124        if (!item.fired && s.position >= item.position) {
1125          item.fired = true;
1126          onPositionFired++;
1127          item.method.apply(item.scope, [item.position]);
1128        }
1129      }
1130      return true;
1131    };
1132    this._resetOnPosition = function(nPosition) {
1133      var i, item, j = onPositionItems.length;
1134      if (!j) {
1135        return false;
1136      }
1137      for (i=j-1; i >= 0; i--) {
1138        item = onPositionItems[i];
1139        if (item.fired && nPosition <= item.position) {
1140          item.fired = false;
1141          onPositionFired--;
1142        }
1143      }
1144      return true;
1145    };
1146    applyFromTo = function() {
1147      var instanceOptions = s._iO,
1148          f = instanceOptions.from,
1149          t = instanceOptions.to,
1150          start, end;
1151      end = function() {
1152        s.clearOnPosition(t, end);
1153        s.stop();
1154      };
1155      start = function() {
1156        if (t !== null && !isNaN(t)) {
1157          s.onPosition(t, end);
1158        }
1159      };
1160      if (f !== null && !isNaN(f)) {
1161        instanceOptions.position = f;
1162        instanceOptions.multiShot = false;
1163        start();
1164      }
1165      return instanceOptions;
1166    };
1167    attachOnPosition = function() {
1168      var item,
1169          op = s._iO.onposition;
1170      if (op) {
1171        for (item in op) {
1172          if (op.hasOwnProperty(item)) {
1173            s.onPosition(parseInt(item, 10), op[item]);
1174          }
1175        }
1176      }
1177    };
1178    detachOnPosition = function() {
1179      var item,
1180          op = s._iO.onposition;
1181      if (op) {
1182        for (item in op) {
1183          if (op.hasOwnProperty(item)) {
1184            s.clearOnPosition(parseInt(item, 10));
1185          }
1186        }
1187      }
1188    };
1189    start_html5_timer = function() {
1190      if (s.isHTML5) {
1191        startTimer(s);
1192      }
1193    };
1194    stop_html5_timer = function() {
1195      if (s.isHTML5) {
1196        stopTimer(s);
1197      }
1198    };
1199    resetProperties = function(retainPosition) {
1200      if (!retainPosition) {
1201        onPositionItems = [];
1202        onPositionFired = 0;
1203      }
1204      onplay_called = false;
1205      s._hasTimer = null;
1206      s._a = null;
1207      s._html5_canplay = false;
1208      s.bytesLoaded = null;
1209      s.bytesTotal = null;
1210      s.duration = (s._iO && s._iO.duration ? s._iO.duration : null);
1211      s.durationEstimate = null;
1212      s.buffered = [];
1213      s.eqData = [];
1214      s.eqData.left = [];
1215      s.eqData.right = [];
1216      s.failures = 0;
1217      s.isBuffering = false;
1218      s.instanceOptions = {};
1219      s.instanceCount = 0;
1220      s.loaded = false;
1221      s.metadata = {};
1222      s.readyState = 0;
1223      s.muted = false;
1224      s.paused = false;
1225      s.peakData = {
1226        left: 0,
1227        right: 0
1228      };
1229      s.waveformData = {
1230        left: [],
1231        right: []
1232      };
1233      s.playState = 0;
1234      s.position = null;
1235      s.id3 = {};
1236    };
1237    resetProperties();
1238    this._onTimer = function(bForce) {
1239      var duration, isNew = false, time, x = {};
1240      if (s._hasTimer || bForce) {
1241        if (s._a && (bForce || ((s.playState > 0 || s.readyState === 1) && !s.paused))) {
1242          duration = s._get_html5_duration();
1243          if (duration !== lastHTML5State.duration) {
1244            lastHTML5State.duration = duration;
1245            s.duration = duration;
1246            isNew = true;
1247          }
1248          s.durationEstimate = s.duration;
1249          time = (s._a.currentTime * msecScale || 0);
1250          if (time !== lastHTML5State.time) {
1251            lastHTML5State.time = time;
1252            isNew = true;
1253          }
1254          if (isNew || bForce) {
1255            s._whileplaying(time,x,x,x,x);
1256          }
1257        }
1258        return isNew;
1259      }
1260    };
1261    this._get_html5_duration = function() {
1262      var instanceOptions = s._iO,
1263          d = (s._a && s._a.duration ? s._a.duration*msecScale : (instanceOptions && instanceOptions.duration ? instanceOptions.duration : null)),
1264          result = (d && !isNaN(d) && d !== Infinity ? d : null);
1265      return result;
1266    };
1267    this._apply_loop = function(a, nLoops) {
1268      a.loop = (nLoops > 1 ? 'loop' : '');
1269    };
1270    this._setup_html5 = function(oOptions) {
1271      var instanceOptions = mixin(s._iO, oOptions),
1272          a = useGlobalHTML5Audio ? globalHTML5Audio : s._a,
1273          dURL = decodeURI(instanceOptions.url),
1274          sameURL;
1275      if (useGlobalHTML5Audio) {
1276        if (dURL === decodeURI(lastGlobalHTML5URL)) {
1277          sameURL = true;
1278        }
1279      } else if (dURL === decodeURI(lastURL)) {
1280        sameURL = true;
1281      }
1282      if (a) {
1283        if (a._s) {
1284          if (useGlobalHTML5Audio) {
1285            if (a._s && a._s.playState && !sameURL) {
1286              a._s.stop();
1287            }
1288          } else if (!useGlobalHTML5Audio && dURL === decodeURI(lastURL)) {
1289            s._apply_loop(a, instanceOptions.loops);
1290            return a;
1291          }
1292        }
1293        if (!sameURL) {
1294          resetProperties(false);
1295          a.src = instanceOptions.url;
1296          s.url = instanceOptions.url;
1297          lastURL = instanceOptions.url;
1298          lastGlobalHTML5URL = instanceOptions.url;
1299          a._called_load = false;
1300        }
1301      } else {
1302        if (instanceOptions.autoLoad || instanceOptions.autoPlay) {
1303          s._a = new Audio(instanceOptions.url);
1304        } else {
1305          s._a = (isOpera && opera.version() < 10 ? new Audio(null) : new Audio());
1306        }
1307        a = s._a;
1308        a._called_load = false;
1309        if (useGlobalHTML5Audio) {
1310          globalHTML5Audio = a;
1311        }
1312      }
1313      s.isHTML5 = true;
1314      s._a = a;
1315      a._s = s;
1316      add_html5_events();
1317      s._apply_loop(a, instanceOptions.loops);
1318      if (instanceOptions.autoLoad || instanceOptions.autoPlay) {
1319        s.load();
1320      } else {
1321        a.autobuffer = false;
1322        a.preload = 'auto';
1323      }
1324      return a;
1325    };
1326    add_html5_events = function() {
1327      if (s._a._added_events) {
1328        return false;
1329      }
1330      var f;
1331      function add(oEvt, oFn, bCapture) {
1332        return s._a ? s._a.addEventListener(oEvt, oFn, bCapture||false) : null;
1333      }
1334      s._a._added_events = true;
1335      for (f in html5_events) {
1336        if (html5_events.hasOwnProperty(f)) {
1337          add(f, html5_events[f]);
1338        }
1339      }
1340      return true;
1341    };
1342    remove_html5_events = function() {
1343      var f;
1344      function remove(oEvt, oFn, bCapture) {
1345        return (s._a ? s._a.removeEventListener(oEvt, oFn, bCapture||false) : null);
1346      }
1347      s._a._added_events = false;
1348      for (f in html5_events) {
1349        if (html5_events.hasOwnProperty(f)) {
1350          remove(f, html5_events[f]);
1351        }
1352      }
1353    };
1354    this._onload = function(nSuccess) {
1355      var fN,
1356          loadOK = !!nSuccess || (!s.isHTML5 && fV === 8 && s.duration);
1357      s.loaded = loadOK;
1358      s.readyState = loadOK?3:2;
1359      s._onbufferchange(0);
1360      if (s._iO.onload) {
1361        wrapCallback(s, function() {
1362          s._iO.onload.apply(s, [loadOK]);
1363        });
1364      }
1365      return true;
1366    };
1367    this._onbufferchange = function(nIsBuffering) {
1368      if (s.playState === 0) {
1369        return false;
1370      }
1371      if ((nIsBuffering && s.isBuffering) || (!nIsBuffering && !s.isBuffering)) {
1372        return false;
1373      }
1374      s.isBuffering = (nIsBuffering === 1);
1375      if (s._iO.onbufferchange) {
1376        s._iO.onbufferchange.apply(s);
1377      }
1378      return true;
1379    };
1380    this._onsuspend = function() {
1381      if (s._iO.onsuspend) {
1382        s._iO.onsuspend.apply(s);
1383      }
1384      return true;
1385    };
1386    this._onfailure = function(msg, level, code) {
1387      s.failures++;
1388      if (s._iO.onfailure && s.failures === 1) {
1389        s._iO.onfailure(s, msg, level, code);
1390      } else {
1391      }
1392    };
1393    this._onfinish = function() {
1394      var io_onfinish = s._iO.onfinish;
1395      s._onbufferchange(0);
1396      s._resetOnPosition(0);
1397      if (s.instanceCount) {
1398        s.instanceCount--;
1399        if (!s.instanceCount) {
1400          detachOnPosition();
1401          s.playState = 0;
1402          s.paused = false;
1403          s.instanceCount = 0;
1404          s.instanceOptions = {};
1405          s._iO = {};
1406          stop_html5_timer();
1407          if (s.isHTML5) {
1408            s.position = 0;
1409          }
1410        }
1411        if (!s.instanceCount || s._iO.multiShotEvents) {
1412          if (io_onfinish) {
1413            wrapCallback(s, function() {
1414              io_onfinish.apply(s);
1415            });
1416          }
1417        }
1418      }
1419    };
1420    this._whileloading = function(nBytesLoaded, nBytesTotal, nDuration, nBufferLength) {
1421      var instanceOptions = s._iO;
1422      s.bytesLoaded = nBytesLoaded;
1423      s.bytesTotal = nBytesTotal;
1424      s.duration = Math.floor(nDuration);
1425      s.bufferLength = nBufferLength;
1426      if (!s.isHTML5 && !instanceOptions.isMovieStar) {
1427        if (instanceOptions.duration) {
1428          s.durationEstimate = (s.duration > instanceOptions.duration) ? s.duration : instanceOptions.duration;
1429        } else {
1430          s.durationEstimate = parseInt((s.bytesTotal / s.bytesLoaded) * s.duration, 10);
1431        }
1432      } else {
1433        s.durationEstimate = s.duration;
1434      }
1435      if (!s.isHTML5) {
1436        s.buffered = [{
1437          'start': 0,
1438          'end': s.duration
1439        }];
1440      }
1441      if ((s.readyState !== 3 || s.isHTML5) && instanceOptions.whileloading) {
1442        instanceOptions.whileloading.apply(s);
1443      }
1444    };
1445    this._whileplaying = function(nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) {
1446      var instanceOptions = s._iO,
1447          eqLeft;
1448      if (isNaN(nPosition) || nPosition === null) {
1449        return false;
1450      }
1451      s.position = Math.max(0, nPosition);
1452      s._processOnPosition();
1453      if (!s.isHTML5 && fV > 8) {
1454        if (instanceOptions.usePeakData && oPeakData !== _undefined && oPeakData) {
1455          s.peakData = {
1456            left: oPeakData.leftPeak,
1457            right: oPeakData.rightPeak
1458          };
1459        }
1460        if (instanceOptions.useWaveformData && oWaveformDataLeft !== _undefined && oWaveformDataLeft) {
1461          s.waveformData = {
1462            left: oWaveformDataLeft.split(','),
1463            right: oWaveformDataRight.split(',')
1464          };
1465        }
1466        if (instanceOptions.useEQData) {
1467          if (oEQData !== _undefined && oEQData && oEQData.leftEQ) {
1468            eqLeft = oEQData.leftEQ.split(',');
1469            s.eqData = eqLeft;
1470            s.eqData.left = eqLeft;
1471            if (oEQData.rightEQ !== _undefined && oEQData.rightEQ) {
1472              s.eqData.right = oEQData.rightEQ.split(',');
1473            }
1474          }
1475        }
1476      }
1477      if (s.playState === 1) {
1478        if (!s.isHTML5 && fV === 8 && !s.position && s.isBuffering) {
1479          s._onbufferchange(0);
1480        }
1481        if (instanceOptions.whileplaying) {
1482          instanceOptions.whileplaying.apply(s);
1483        }
1484      }
1485      return true;
1486    };
1487    this._oncaptiondata = function(oData) {
1488      s.captiondata = oData;
1489      if (s._iO.oncaptiondata) {
1490        s._iO.oncaptiondata.apply(s, [oData]);
1491      }
1492    };
1493    this._onmetadata = function(oMDProps, oMDData) {
1494      var oData = {}, i, j;
1495      for (i = 0, j = oMDProps.length; i < j; i++) {
1496        oData[oMDProps[i]] = oMDData[i];
1497      }
1498      s.metadata = oData;
1499      if (s._iO.onmetadata) {
1500        s._iO.onmetadata.apply(s);
1501      }
1502    };
1503    this._onid3 = function(oID3Props, oID3Data) {
1504      var oData = [], i, j;
1505      for (i = 0, j = oID3Props.length; i < j; i++) {
1506        oData[oID3Props[i]] = oID3Data[i];
1507      }
1508      s.id3 = mixin(s.id3, oData);
1509      if (s._iO.onid3) {
1510        s._iO.onid3.apply(s);
1511      }
1512    };
1513    this._onconnect = function(bSuccess) {
1514      bSuccess = (bSuccess === 1);
1515      s.connected = bSuccess;
1516      if (bSuccess) {
1517        s.failures = 0;
1518        if (idCheck(s.id)) {
1519          if (s.getAutoPlay()) {
1520            s.play(_undefined, s.getAutoPlay());
1521          } else if (s._iO.autoLoad) {
1522            s.load();
1523          }
1524        }
1525        if (s._iO.onconnect) {
1526          s._iO.onconnect.apply(s, [bSuccess]);
1527        }
1528      }
1529    };
1530    this._ondataerror = function(sError) {
1531      if (s.playState > 0) {
1532        if (s._iO.ondataerror) {
1533          s._iO.ondataerror.apply(s);
1534        }
1535      }
1536    };
1537  };
1538  getDocument = function() {
1539    return (doc.body || doc._docElement || doc.getElementsByTagName('div')[0]);
1540  };
1541  id = function(sID) {
1542    return doc.getElementById(sID);
1543  };
1544  mixin = function(oMain, oAdd) {
1545    var o1 = (oMain || {}), o2, o;
1546    o2 = (oAdd === _undefined ? sm2.defaultOptions : oAdd);
1547    for (o in o2) {
1548      if (o2.hasOwnProperty(o) && o1[o] === _undefined) {
1549        if (typeof o2[o] !== 'object' || o2[o] === null) {
1550          o1[o] = o2[o];
1551        } else {
1552          o1[o] = mixin(o1[o], o2[o]);
1553        }
1554      }
1555    }
1556    return o1;
1557  };
1558  wrapCallback = function(oSound, callback) {
1559    if (!oSound.isHTML5 && fV === 8) {
1560      window.setTimeout(callback, 0);
1561    } else {
1562      callback();
1563    }
1564  };
1565  extraOptions = {
1566    'onready': 1,
1567    'ontimeout': 1,
1568    'defaultOptions': 1,
1569    'flash9Options': 1,
1570    'movieStarOptions': 1
1571  };
1572  assign = function(o, oParent) {
1573    var i,
1574        result = true,
1575        hasParent = (oParent !== _undefined),
1576        setupOptions = sm2.setupOptions,
1577        bonusOptions = extraOptions;
1578    for (i in o) {
1579      if (o.hasOwnProperty(i)) {
1580        if (typeof o[i] !== 'object' || o[i] === null || o[i] instanceof Array || o[i] instanceof RegExp) {
1581          if (hasParent && bonusOptions[oParent] !== _undefined) {
1582            sm2[oParent][i] = o[i];
1583          } else if (setupOptions[i] !== _undefined) {
1584            sm2.setupOptions[i] = o[i];
1585            sm2[i] = o[i];
1586          } else if (bonusOptions[i] === _undefined) {
1587            result = false;
1588          } else {
1589            if (sm2[i] instanceof Function) {
1590              sm2[i].apply(sm2, (o[i] instanceof Array? o[i] : [o[i]]));
1591            } else {
1592              sm2[i] = o[i];
1593            }
1594          }
1595        } else {
1596          if (bonusOptions[i] === _undefined) {
1597            result = false;
1598          } else {
1599            return assign(o[i], i);
1600          }
1601        }
1602      }
1603    }
1604    return result;
1605  };
1606  function preferFlashCheck(kind) {
1607    return (sm2.preferFlash && hasFlash && !sm2.ignoreFlash && (sm2.flash[kind] !== _undefined && sm2.flash[kind]));
1608  }
1609  event = (function() {
1610    var old = (window.attachEvent),
1611    evt = {
1612      add: (old?'attachEvent':'addEventListener'),
1613      remove: (old?'detachEvent':'removeEventListener')
1614    };
1615    function getArgs(oArgs) {
1616      var args = slice.call(oArgs),
1617          len = args.length;
1618      if (old) {
1619        args[1] = 'on' + args[1];
1620        if (len > 3) {
1621          args.pop();
1622        }
1623      } else if (len === 3) {
1624        args.push(false);
1625      }
1626      return args;
1627    }
1628    function apply(args, sType) {
1629      var element = args.shift(),
1630          method = [evt[sType]];
1631      if (old) {
1632        element[method](args[0], args[1]);
1633      } else {
1634        element[method].apply(element, args);
1635      }
1636    }
1637    function add() {
1638      apply(getArgs(arguments), 'add');
1639    }
1640    function remove() {
1641      apply(getArgs(arguments), 'remove');
1642    }
1643    return {
1644      'add': add,
1645      'remove': remove
1646    };
1647  }());
1648  function html5_event(oFn) {
1649    return function(e) {
1650      var s = this._s,
1651          result;
1652      if (!s || !s._a) {
1653        result = null;
1654      } else {
1655        result = oFn.call(this, e);
1656      }
1657      return result;
1658    };
1659  }
1660  html5_events = {
1661    abort: html5_event(function() {
1662    }),
1663    canplay: html5_event(function() {
1664      var s = this._s,
1665          position1K;
1666      if (s._html5_canplay) {
1667        return true;
1668      }
1669      s._html5_canplay = true;
1670      s._onbufferchange(0);
1671      position1K = (s._iO.position !== _undefined && !isNaN(s._iO.position)?s._iO.position/msecScale:null);
1672      if (s.position && this.currentTime !== position1K) {
1673        try {
1674          this.currentTime = position1K;
1675        } catch(ee) {
1676        }
1677      }
1678      if (s._iO._oncanplay) {
1679        s._iO._oncanplay();
1680      }
1681    }),
1682    canplaythrough: html5_event(function() {
1683      var s = this._s;
1684      if (!s.loaded) {
1685        s._onbufferchange(0);
1686        s._whileloading(s.bytesLoaded, s.bytesTotal, s._get_html5_duration());
1687        s._onload(true);
1688      }
1689    }),
1690    ended: html5_event(function() {
1691      var s = this._s;
1692      s._onfinish();
1693    }),
1694    error: html5_event(function() {
1695      this._s._onload(false);
1696    }),
1697    loadeddata: html5_event(function() {
1698      var s = this._s;
1699      if (!s._loaded && !isSafari) {
1700        s.duration = s._get_html5_duration();
1701      }
1702    }),
1703    loadedmetadata: html5_event(function() {
1704    }),
1705    loadstart: html5_event(function() {
1706      this._s._onbufferchange(1);
1707    }),
1708    play: html5_event(function() {
1709      this._s._onbufferchange(0);
1710    }),
1711    playing: html5_event(function() {
1712      this._s._onbufferchange(0);
1713    }),
1714    progress: html5_event(function(e) {
1715      var s = this._s,
1716          i, j, str, buffered = 0,
1717          isProgress = (e.type === 'progress'),
1718          ranges = e.target.buffered,
1719          loaded = (e.loaded||0),
1720          total = (e.total||1);
1721      s.buffered = [];
1722      if (ranges && ranges.length) {
1723        for (i=0, j=ranges.length; i<j; i++) {
1724          s.buffered.push({
1725            'start': ranges.start(i) * msecScale,
1726            'end': ranges.end(i) * msecScale
1727          });
1728        }
1729        buffered = (ranges.end(0) - ranges.start(0)) * msecScale;
1730        loaded = Math.min(1, buffered/(e.target.duration*msecScale));
1731      }
1732      if (!isNaN(loaded)) {
1733        s._onbufferchange(0);
1734        s._whileloading(loaded, total, s._get_html5_duration());
1735        if (loaded && total && loaded === total) {
1736          html5_events.canplaythrough.call(this, e);
1737        }
1738      }
1739    }),
1740    ratechange: html5_event(function() {
1741    }),
1742    suspend: html5_event(function(e) {
1743      var s = this._s;
1744      html5_events.progress.call(this, e);
1745      s._onsuspend();
1746    }),
1747    stalled: html5_event(function() {
1748    }),
1749    timeupdate: html5_event(function() {
1750      this._s._onTimer();
1751    }),
1752    waiting: html5_event(function() {
1753      var s = this._s;
1754      s._onbufferchange(1);
1755    })
1756  };
1757  html5OK = function(iO) {
1758    var result;
1759    if (!iO || (!iO.type && !iO.url && !iO.serverURL)) {
1760      result = false;
1761    } else if (iO.serverURL || (iO.type && preferFlashCheck(iO.type))) {
1762      result = false;
1763    } else {
1764      result = ((iO.type ? html5CanPlay({type:iO.type}) : html5CanPlay({url:iO.url}) || sm2.html5Only || iO.url.match(/data\:/i)));
1765    }
1766    return result;
1767  };
1768  html5Unload = function(oAudio) {
1769    var url;
1770    if (oAudio) {
1771      url = (isSafari && !is_iDevice ? null : (isFirefox ? emptyURL : null));
1772      oAudio.src = url;
1773      if (oAudio._called_unload !== undefined) {
1774        oAudio._called_load = false;
1775      }
1776    }
1777    if (useGlobalHTML5Audio) {
1778      lastGlobalHTML5URL = null;
1779    }
1780    return url;
1781  };
1782  html5CanPlay = function(o) {
1783    if (!sm2.useHTML5Audio || !sm2.hasHTML5) {
1784      return false;
1785    }
1786    var url = (o.url || null),
1787        mime = (o.type || null),
1788        aF = sm2.audioFormats,
1789        result,
1790        offset,
1791        fileExt,
1792        item;
1793    if (mime && sm2.html5[mime] !== _undefined) {
1794      return (sm2.html5[mime] && !preferFlashCheck(mime));
1795    }
1796    if (!html5Ext) {
1797      html5Ext = [];
1798      for (item in aF) {
1799        if (aF.hasOwnProperty(item)) {
1800          html5Ext.push(item);
1801          if (aF[item].related) {
1802            html5Ext = html5Ext.concat(aF[item].related);
1803          }
1804        }
1805      }
1806      html5Ext = new RegExp('\\.('+html5Ext.join('|')+')(\\?.*)?$','i');
1807    }
1808    fileExt = (url ? url.toLowerCase().match(html5Ext) : null);
1809    if (!fileExt || !fileExt.length) {
1810      if (!mime) {
1811        result = false;
1812      } else {
1813        offset = mime.indexOf(';');
1814        fileExt = (offset !== -1?mime.substr(0,offset):mime).substr(6);
1815      }
1816    } else {
1817      fileExt = fileExt[1];
1818    }
1819    if (fileExt && sm2.html5[fileExt] !== _undefined) {
1820      result = (sm2.html5[fileExt] && !preferFlashCheck(fileExt));
1821    } else {
1822      mime = 'audio/'+fileExt;
1823      result = sm2.html5.canPlayType({type:mime});
1824      sm2.html5[fileExt] = result;
1825      result = (result && sm2.html5[mime] && !preferFlashCheck(mime));
1826    }
1827    return result;
1828  };
1829  testHTML5 = function() {
1830    if (!sm2.useHTML5Audio || !sm2.hasHTML5) {
1831      sm2.html5.usingFlash = true;
1832      needsFlash = true;
1833      return false;
1834    }
1835    var a = (Audio !== _undefined ? (isOpera && opera.version() < 10 ? new Audio(null) : new Audio()) : null),
1836        item, lookup, support = {}, aF, i;
1837    function cp(m) {
1838      var canPlay, i, j,
1839          result = false,
1840          isOK = false;
1841      if (!a || typeof a.canPlayType !== 'function') {
1842        return result;
1843      }
1844      if (m instanceof Array) {
1845        for (i=0, j=m.length; i<j; i++) {
1846          if (sm2.html5[m[i]] || a.canPlayType(m[i]).match(sm2.html5Test)) {
1847            isOK = true;
1848            sm2.html5[m[i]] = true;
1849            sm2.flash[m[i]] = !!(m[i].match(flashMIME));
1850          }
1851        }
1852        result = isOK;
1853      } else {
1854        canPlay = (a && typeof a.canPlayType === 'function' ? a.canPlayType(m) : false);
1855        result = !!(canPlay && (canPlay.match(sm2.html5Test)));
1856      }
1857      return result;
1858    }
1859    aF = sm2.audioFormats;
1860    for (item in aF) {
1861      if (aF.hasOwnProperty(item)) {
1862        lookup = 'audio/' + item;
1863        support[item] = cp(aF[item].type);
1864        support[lookup] = support[item];
1865        if (item.match(flashMIME)) {
1866          sm2.flash[item] = true;
1867          sm2.flash[lookup] = true;
1868        } else {
1869          sm2.flash[item] = false;
1870          sm2.flash[lookup] = false;
1871        }
1872        if (aF[item] && aF[item].related) {
1873          for (i=aF[item].related.length-1; i >= 0; i--) {
1874            support['audio/'+aF[item].related[i]] = support[item];
1875            sm2.html5[aF[item].related[i]] = support[item];
1876            sm2.flash[aF[item].related[i]] = support[item];
1877          }
1878        }
1879      }
1880    }
1881    support.canPlayType = (a?cp:null);
1882    sm2.html5 = mixin(sm2.html5, support);
1883    sm2.html5.usingFlash = featureCheck();
1884    needsFlash = sm2.html5.usingFlash;
1885    return true;
1886  };
1887  strings = {
1888  };
1889  str = function() {
1890  };
1891  loopFix = function(sOpt) {
1892    if (fV === 8 && sOpt.loops > 1 && sOpt.stream) {
1893      sOpt.stream = false;
1894    }
1895    return sOpt;
1896  };
1897  policyFix = function(sOpt, sPre) {
1898    if (sOpt && !sOpt.usePolicyFile && (sOpt.onid3 || sOpt.usePeakData || sOpt.useWaveformData || sOpt.useEQData)) {
1899      sOpt.usePolicyFile = true;
1900    }
1901    return sOpt;
1902  };
1903  complain = function(sMsg) {
1904  };
1905  doNothing = function() {
1906    return false;
1907  };
1908  disableObject = function(o) {
1909    var oProp;
1910    for (oProp in o) {
1911      if (o.hasOwnProperty(oProp) && typeof o[oProp] === 'function') {
1912        o[oProp] = doNothing;
1913      }
1914    }
1915    oProp = null;
1916  };
1917  failSafely = function(bNoDisable) {
1918    if (bNoDisable === _undefined) {
1919      bNoDisable = false;
1920    }
1921    if (disabled || bNoDisable) {
1922      sm2.disable(bNoDisable);
1923    }
1924  };
1925  normalizeMovieURL = function(smURL) {
1926    var urlParams = null, url;
1927    if (smURL) {
1928      if (smURL.match(/\.swf(\?.*)?$/i)) {
1929        urlParams = smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?') + 4);
1930        if (urlParams) {
1931          return smURL;
1932        }
1933      } else if (smURL.lastIndexOf('/') !== smURL.length - 1) {
1934        smURL += '/';
1935      }
1936    }
1937    url = (smURL && smURL.lastIndexOf('/') !== - 1 ? smURL.substr(0, smURL.lastIndexOf('/') + 1) : './') + sm2.movieURL;
1938    if (sm2.noSWFCache) {
1939      url += ('?ts=' + new Date().getTime());
1940    }
1941    return url;
1942  };
1943  setVersionInfo = function() {
1944    fV = parseInt(sm2.flashVersion, 10);
1945    if (fV !== 8 && fV !== 9) {
1946      sm2.flashVersion = fV = defaultFlashVersion;
1947    }
1948    var isDebug = (sm2.debugMode || sm2.debugFlash?'_debug.swf':'.swf');
1949    if (sm2.useHTML5Audio && !sm2.html5Only && sm2.audioFormats.mp4.required && fV < 9) {
1950      sm2.flashVersion = fV = 9;
1951    }
1952    sm2.version = sm2.versionNumber + (sm2.html5Only?' (HTML5-only mode)':(fV === 9?' (AS3/Flash 9)':' (AS2/Flash 8)'));
1953    if (fV > 8) {
1954      sm2.defaultOptions = mixin(sm2.defaultOptions, sm2.flash9Options);
1955      sm2.features.buffering = true;
1956      sm2.defaultOptions = mixin(sm2.defaultOptions, sm2.movieStarOptions);
1957      sm2.filePatterns.flash9 = new RegExp('\\.(mp3|' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i');
1958      sm2.features.movieStar = true;
1959    } else {
1960      sm2.features.movieStar = false;
1961    }
1962    sm2.filePattern = sm2.filePatterns[(fV !== 8?'flash9':'flash8')];
1963    sm2.movieURL = (fV === 8?'soundmanager2.swf':'soundmanager2_flash9.swf').replace('.swf', isDebug);
1964    sm2.features.peakData = sm2.features.waveformData = sm2.features.eqData = (fV > 8);
1965  };
1966  setPolling = function(bPolling, bHighPerformance) {
1967    if (!flash) {
1968      return false;
1969    }
1970    flash._setPolling(bPolling, bHighPerformance);
1971  };
1972  initDebug = function() {
1973  };
1974  idCheck = this.getSoundById;
1975  getSWFCSS = function() {
1976    var css = [];
1977    if (sm2.debugMode) {
1978      css.push(swfCSS.sm2Debug);
1979    }
1980    if (sm2.debugFlash) {
1981      css.push(swfCSS.flashDebug);
1982    }
1983    if (sm2.useHighPerformance) {
1984      css.push(swfCSS.highPerf);
1985    }
1986    return css.join(' ');
1987  };
1988  flashBlockHandler = function() {
1989    var name = str('fbHandler'),
1990        p = sm2.getMoviePercent(),
1991        css = swfCSS,
1992        error = {type:'FLASHBLOCK'};
1993    if (sm2.html5Only) {
1994      return false;
1995    }
1996    if (!sm2.ok()) {
1997      if (needsFlash) {
1998        sm2.oMC.className = getSWFCSS() + ' ' + css.swfDefault + ' ' + (p === null?css.swfTimedout:css.swfError);
1999      }
2000      sm2.didFlashBlock = true;
2001      processOnEvents({type:'ontimeout', ignoreInit:true, error:error});
2002      catchError(error);
2003    } else {
2004      if (sm2.oMC) {
2005        sm2.oMC.className = [getSWFCSS(), css.swfDefault, css.swfLoaded + (sm2.didFlashBlock?' '+css.swfUnblocked:'')].join(' ');
2006      }
2007    }
2008  };
2009  addOnEvent = function(sType, oMethod, oScope) {
2010    if (on_queue[sType] === _undefined) {
2011      on_queue[sType] = [];
2012    }
2013    on_queue[sType].push({
2014      'method': oMethod,
2015      'scope': (oScope || null),
2016      'fired': false
2017    });
2018  };
2019  processOnEvents = function(oOptions) {
2020    if (!oOptions) {
2021      oOptions = {
2022        type: (sm2.ok() ? 'onready' : 'ontimeout')
2023      };
2024    }
2025    if (!didInit && oOptions && !oOptions.ignoreInit) {
2026      return false;
2027    }
2028    if (oOptions.type === 'ontimeout' && (sm2.ok() || (disabled && !oOptions.ignoreInit))) {
2029      return false;
2030    }
2031    var status = {
2032          success: (oOptions && oOptions.ignoreInit?sm2.ok():!disabled)
2033        },
2034        srcQueue = (oOptions && oOptions.type?on_queue[oOptions.type]||[]:[]),
2035        queue = [], i, j,
2036        args = [status],
2037        canRetry = (needsFlash && !sm2.ok());
2038    if (oOptions.error) {
2039      args[0].error = oOptions.error;
2040    }
2041    for (i = 0, j = srcQueue.length; i < j; i++) {
2042      if (srcQueue[i].fired !== true) {
2043        queue.push(srcQueue[i]);
2044      }
2045    }
2046    if (queue.length) {
2047      for (i = 0, j = queue.length; i < j; i++) {
2048        if (queue[i].scope) {
2049          queue[i].method.apply(queue[i].scope, args);
2050        } else {
2051          queue[i].method.apply(this, args);
2052        }
2053        if (!canRetry) {
2054          queue[i].fired = true;
2055        }
2056      }
2057    }
2058    return true;
2059  };
2060  initUserOnload = function() {
2061    window.setTimeout(function() {
2062      if (sm2.useFlashBlock) {
2063        flashBlockHandler();
2064      }
2065      processOnEvents();
2066      if (typeof sm2.onload === 'function') {
2067        sm2.onload.apply(window);
2068      }
2069      if (sm2.waitForWindowLoad) {
2070        event.add(window, 'load', initUserOnload);
2071      }
2072    },1);
2073  };
2074  detectFlash = function() {
2075    if (hasFlash !== _undefined) {
2076      return hasFlash;
2077    }
2078    var hasPlugin = false, n = navigator, nP = n.plugins, obj, type, types, AX = window.ActiveXObject;
2079    if (nP && nP.length) {
2080      type = 'application/x-shockwave-flash';
2081      types = n.mimeTypes;
2082      if (types && types[type] && types[type].enabledPlugin && types[type].enabledPlugin.description) {
2083        hasPlugin = true;
2084      }
2085    } else if (AX !== _undefined && !ua.match(/MSAppHost/i)) {
2086      try {
2087        obj = new AX('ShockwaveFlash.ShockwaveFlash');
2088      } catch(e) {
2089        obj = null;
2090      }
2091      hasPlugin = (!!obj);
2092      obj = null;
2093    }
2094    hasFlash = hasPlugin;
2095    return hasPlugin;
2096  };
2097  featureCheck = function() {
2098    var flashNeeded,
2099        item,
2100        formats = sm2.audioFormats,
2101        isSpecial = (is_iDevice && !!(ua.match(/os (1|2|3_0|3_1)/i)));
2102    if (isSpecial) {
2103      sm2.hasHTML5 = false;
2104      sm2.html5Only = true;
2105      if (sm2.oMC) {
2106        sm2.oMC.style.display = 'none';
2107      }
2108    } else {
2109      if (sm2.useHTML5Audio) {
2110        if (!sm2.html5 || !sm2.html5.canPlayType) {
2111          sm2.hasHTML5 = false;
2112        }
2113      }
2114    }
2115    if (sm2.useHTML5Audio && sm2.hasHTML5) {
2116      canIgnoreFlash = true;
2117      for (item in formats) {
2118        if (formats.hasOwnProperty(item)) {
2119          if (formats[item].required) {
2120            if (!sm2.html5.canPlayType(formats[item].type)) {
2121              canIgnoreFlash = false;
2122              flashNeeded = true;
2123            } else if (sm2.preferFlash && (sm2.flash[item] || sm2.flash[formats[item].type])) {
2124              flashNeeded = true;
2125            }
2126          }
2127        }
2128      }
2129    }
2130    if (sm2.ignoreFlash) {
2131      flashNeeded = false;
2132      canIgnoreFlash = true;
2133    }
2134    sm2.html5Only = (sm2.hasHTML5 && sm2.useHTML5Audio && !flashNeeded);
2135    return (!sm2.html5Only);
2136  };
2137  parseURL = function(url) {
2138    var i, j, urlResult = 0, result;
2139    if (url instanceof Array) {
2140      for (i=0, j=url.length; i<j; i++) {
2141        if (url[i] instanceof Object) {
2142          if (sm2.canPlayMIME(url[i].type)) {
2143            urlResult = i;
2144            break;
2145          }
2146        } else if (sm2.canPlayURL(url[i])) {
2147          urlResult = i;
2148          break;
2149        }
2150      }
2151      if (url[urlResult].url) {
2152        url[urlResult] = url[urlResult].url;
2153      }
2154      result = url[urlResult];
2155    } else {
2156      result = url;
2157    }
2158    return result;
2159  };
2160  startTimer = function(oSound) {
2161    if (!oSound._hasTimer) {
2162      oSound._hasTimer = true;
2163      if (!mobileHTML5 && sm2.html5PollingInterval) {
2164        if (h5IntervalTimer === null && h5TimerCount === 0) {
2165          h5IntervalTimer = setInterval(timerExecute, sm2.html5PollingInterval);
2166        }
2167        h5TimerCount++;
2168      }
2169    }
2170  };
2171  stopTimer = function(oSound) {
2172    if (oSound._hasTimer) {
2173      oSound._hasTimer = false;
2174      if (!mobileHTML5 && sm2.html5PollingInterval) {
2175        h5TimerCount--;
2176      }
2177    }
2178  };
2179  timerExecute = function() {
2180    var i;
2181    if (h5IntervalTimer !== null && !h5TimerCount) {
2182      clearInterval(h5IntervalTimer);
2183      h5IntervalTimer = null;
2184      return false;
2185    }
2186    for (i = sm2.soundIDs.length-1; i >= 0; i--) {
2187      if (sm2.sounds[sm2.soundIDs[i]].isHTML5 && sm2.sounds[sm2.soundIDs[i]]._hasTimer) {
2188        sm2.sounds[sm2.soundIDs[i]]._onTimer();
2189      }
2190    }
2191  };
2192  catchError = function(options) {
2193    options = (options !== _undefined ? options : {});
2194    if (typeof sm2.onerror === 'function') {
2195      sm2.onerror.apply(window, [{type:(options.type !== _undefined ? options.type : null)}]);
2196    }
2197    if (options.fatal !== _undefined && options.fatal) {
2198      sm2.disable();
2199    }
2200  };
2201  badSafariFix = function() {
2202    if (!isBadSafari || !detectFlash()) {
2203      return false;
2204    }
2205    var aF = sm2.audioFormats, i, item;
2206    for (item in aF) {
2207      if (aF.hasOwnProperty(item)) {
2208        if (item === 'mp3' || item === 'mp4') {
2209          sm2.html5[item] = false;
2210          if (aF[item] && aF[item].related) {
2211            for (i = aF[item].related.length-1; i >= 0; i--) {
2212              sm2.html5[aF[item].related[i]] = false;
2213            }
2214          }
2215        }
2216      }
2217    }
2218  };
2219  this._setSandboxType = function(sandboxType) {
2220  };
2221  this._externalInterfaceOK = function(swfVersion) {
2222    if (sm2.swfLoaded) {
2223      return false;
2224    }
2225    var e;
2226    sm2.swfLoaded = true;
2227    tryInitOnFocus = false;
2228    if (isBadSafari) {
2229      badSafariFix();
2230    }
2231    setTimeout(init, isIE ? 100 : 1);
2232  };
2233  createMovie = function(smID, smURL) {
2234    if (didAppend && appendSuccess) {
2235      return false;
2236    }
2237    function initMsg() {
2238    }
2239    if (sm2.html5Only) {
2240      setVersionInfo();
2241      initMsg();
2242      sm2.oMC = id(sm2.movieID);
2243      init();
2244      didAppend = true;
2245      appendSuccess = true;
2246      return false;
2247    }
2248    var remoteURL = (smURL || sm2.url),
2249    localURL = (sm2.altURL || remoteURL),
2250    swfTitle = 'JS/Flash audio component (SoundManager 2)',
2251    oTarget = getDocument(),
2252    extraClass = getSWFCSS(),
2253    isRTL = null,
2254    html = doc.getElementsByTagName('html')[0],
2255    oEmbed, oMovie, tmp, movieHTML, oEl, s, x, sClass;
2256    isRTL = (html && html.dir && html.dir.match(/rtl/i));
2257    smID = (smID === _undefined?sm2.id:smID);
2258    function param(name, value) {
2259      return '<param name="'+name+'" value="'+value+'" />';
2260    }
2261    setVersionInfo();
2262    sm2.url = normalizeMovieURL(overHTTP?remoteURL:localURL);
2263    smURL = sm2.url;
2264    sm2.wmode = (!sm2.wmode && sm2.useHighPerformance ? 'transparent' : sm2.wmode);
2265    if (sm2.wmode !== null && (ua.match(/msie 8/i) || (!isIE && !sm2.useHighPerformance)) && navigator.platform.match(/win32|win64/i)) {
2266       messages.push(strings.spcWmode);
2267      sm2.wmode = null;
2268    }
2269    oEmbed = {
2270      'name': smID,
2271      'id': smID,
2272      'src': smURL,
2273      'quality': 'high',
2274      'allowScriptAccess': sm2.allowScriptAccess,
2275      'bgcolor': sm2.bgColor,
2276      'pluginspage': http+'www.macromedia.com/go/getflashplayer',
2277      'title': swfTitle,
2278      'type': 'application/x-shockwave-flash',
2279      'wmode': sm2.wmode,
2280      'hasPriority': 'true'
2281    };
2282    if (sm2.debugFlash) {
2283      oEmbed.FlashVars = 'debug=1';
2284    }
2285    if (!sm2.wmode) {
2286      delete oEmbed.wmode;
2287    }
2288    if (isIE) {
2289      oMovie = doc.createElement('div');
2290      movieHTML = [
2291        '<object id="' + smID + '" data="' + smURL + '" type="' + oEmbed.type + '" title="' + oEmbed.title +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="' + http+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">',
2292        param('movie', smURL),
2293        param('AllowScriptAccess', sm2.allowScriptAccess),
2294        param('quality', oEmbed.quality),
2295        (sm2.wmode? param('wmode', sm2.wmode): ''),
2296        param('bgcolor', sm2.bgColor),
2297        param('hasPriority', 'true'),
2298        (sm2.debugFlash ? param('FlashVars', oEmbed.FlashVars) : ''),
2299        '</object>'
2300      ].join('');
2301    } else {
2302      oMovie = doc.createElement('embed');
2303      for (tmp in oEmbed) {
2304        if (oEmbed.hasOwnProperty(tmp)) {
2305          oMovie.setAttribute(tmp, oEmbed[tmp]);
2306        }
2307      }
2308    }
2309    initDebug();
2310    extraClass = getSWFCSS();
2311    oTarget = getDocument();
2312    if (oTarget) {
2313      sm2.oMC = (id(sm2.movieID) || doc.createElement('div'));
2314      if (!sm2.oMC.id) {
2315        sm2.oMC.id = sm2.movieID;
2316        sm2.oMC.className = swfCSS.swfDefault + ' ' + extraClass;
2317        s = null;
2318        oEl = null;
2319        if (!sm2.useFlashBlock) {
2320          if (sm2.useHighPerformance) {
2321            s = {
2322              'position': 'fixed',
2323              'width': '8px',
2324              'height': '8px',
2325              'bottom': '0px',
2326              'left': '0px',
2327              'overflow': 'hidden'
2328            };
2329          } else {
2330            s = {
2331              'position': 'absolute',
2332              'width': '6px',
2333              'height': '6px',
2334              'top': '-9999px',
2335              'left': '-9999px'
2336            };
2337            if (isRTL) {
2338              s.left = Math.abs(parseInt(s.left,10))+'px';
2339            }
2340          }
2341        }
2342        if (isWebkit) {
2343          sm2.oMC.style.zIndex = 10000;
2344        }
2345        if (!sm2.debugFlash) {
2346          for (x in s) {
2347            if (s.hasOwnProperty(x)) {
2348              sm2.oMC.style[x] = s[x];
2349            }
2350          }
2351        }
2352        try {
2353          if (!isIE) {
2354            sm2.oMC.appendChild(oMovie);
2355          }
2356          oTarget.appendChild(sm2.oMC);
2357          if (isIE) {
2358            oEl = sm2.oMC.appendChild(doc.createElement('div'));
2359            oEl.className = swfCSS.swfBox;
2360            oEl.innerHTML = movieHTML;
2361          }
2362          appendSuccess = true;
2363        } catch(e) {
2364          throw new Error(str('domError')+' \n'+e.toString());
2365        }
2366      } else {
2367        sClass = sm2.oMC.className;
2368        sm2.oMC.className = (sClass?sClass+' ':swfCSS.swfDefault) + (extraClass?' '+extraClass:'');
2369        sm2.oMC.appendChild(oMovie);
2370        if (isIE) {
2371          oEl = sm2.oMC.appendChild(doc.createElement('div'));
2372          oEl.className = swfCSS.swfBox;
2373          oEl.innerHTML = movieHTML;
2374        }
2375        appendSuccess = true;
2376      }
2377    }
2378    didAppend = true;
2379    initMsg();
2380    return true;
2381  };
2382  initMovie = function() {
2383    if (sm2.html5Only) {
2384      createMovie();
2385      return false;
2386    }
2387    if (flash) {
2388      return false;
2389    }
2390    if (!sm2.url) {
2391       return false;
2392    }
2393    flash = sm2.getMovie(sm2.id);
2394    if (!flash) {
2395      if (!oRemoved) {
2396        createMovie(sm2.id, sm2.url);
2397      } else {
2398        if (!isIE) {
2399          sm2.oMC.appendChild(oRemoved);
2400        } else {
2401          sm2.oMC.innerHTML = oRemovedHTML;
2402        }
2403        oRemoved = null;
2404        didAppend = true;
2405      }
2406      flash = sm2.getMovie(sm2.id);
2407    }
2408    if (typeof sm2.oninitmovie === 'function') {
2409      setTimeout(sm2.oninitmovie, 1);
2410    }
2411    return true;
2412  };
2413  delayWaitForEI = function() {
2414    setTimeout(waitForEI, 1000);
2415  };
2416  waitForEI = function() {
2417    var p,
2418        loadIncomplete = false;
2419    if (!sm2.url) {
2420      return false;
2421    }
2422    if (waitingForEI) {
2423      return false;
2424    }
2425    waitingForEI = true;
2426    event.remove(window, 'load', delayWaitForEI);
2427    if (tryInitOnFocus && !isFocused) {
2428      return false;
2429    }
2430    if (!didInit) {
2431      p = sm2.getMoviePercent();
2432      if (p > 0 && p < 100) {
2433        loadIncomplete = true;
2434      }
2435    }
2436    setTimeout(function() {
2437      p = sm2.getMoviePercent();
2438      if (loadIncomplete) {
2439        waitingForEI = false;
2440        window.setTimeout(delayWaitForEI, 1);
2441        return false;
2442      }
2443      if (!didInit && okToDisable) {
2444        if (p === null) {
2445          if (sm2.useFlashBlock || sm2.flashLoadTimeout === 0) {
2446            if (sm2.useFlashBlock) {
2447              flashBlockHandler();
2448            }
2449          } else {
2450            if (!sm2.useFlashBlock && canIgnoreFlash) {
2451              window.setTimeout(function() {
2452                sm2.setup({
2453                  preferFlash: false
2454                }).reboot();
2455                sm2.didFlashBlock = true;
2456                sm2.beginDelayedInit();
2457              }, 1);
2458            } else {
2459              processOnEvents({type:'ontimeout', ignoreInit: true});
2460            }
2461          }
2462        } else {
2463          if (sm2.flashLoadTimeout === 0) {
2464          } else {
2465            failSafely(true);
2466          }
2467        }
2468      }
2469    }, sm2.flashLoadTimeout);
2470  };
2471  handleFocus = function() {
2472    function cleanup() {
2473      event.remove(window, 'focus', handleFocus);
2474    }
2475    if (isFocused || !tryInitOnFocus) {
2476      cleanup();
2477      return true;
2478    }
2479    okToDisable = true;
2480    isFocused = true;
2481    waitingForEI = false;
2482    delayWaitForEI();
2483    cleanup();
2484    return true;
2485  };
2486  flushMessages = function() {
2487  };
2488  showSupport = function() {
2489  };
2490  initComplete = function(bNoDisable) {
2491    if (didInit) {
2492      return false;
2493    }
2494    if (sm2.html5Only) {
2495      didInit = true;
2496      initUserOnload();
2497      return true;
2498    }
2499    var wasTimeout = (sm2.useFlashBlock && sm2.flashLoadTimeout && !sm2.getMoviePercent()),
2500        result = true,
2501        error;
2502    if (!wasTimeout) {
2503      didInit = true;
2504      if (disabled) {
2505        error = {type: (!hasFlash && needsFlash ? 'NO_FLASH' : 'INIT_TIMEOUT')};
2506      }
2507    }
2508    if (disabled || bNoDisable) {
2509      if (sm2.useFlashBlock && sm2.oMC) {
2510        sm2.oMC.className = getSWFCSS() + ' ' + (sm2.getMoviePercent() === null?swfCSS.swfTimedout:swfCSS.swfError);
2511      }
2512      processOnEvents({type:'ontimeout', error:error, ignoreInit: true});
2513      catchError(error);
2514      result = false;
2515    } else {
2516    }
2517    if (!disabled) {
2518      if (sm2.waitForWindowLoad && !windowLoaded) {
2519        event.add(window, 'load', initUserOnload);
2520      } else {
2521        initUserOnload();
2522      }
2523    }
2524    return result;
2525  };
2526  setProperties = function() {
2527    var i,
2528        o = sm2.setupOptions;
2529    for (i in o) {
2530      if (o.hasOwnProperty(i)) {
2531        if (sm2[i] === _undefined) {
2532          sm2[i] = o[i];
2533        } else if (sm2[i] !== o[i]) {
2534          sm2.setupOptions[i] = sm2[i];
2535        }
2536      }
2537    }
2538  };
2539  init = function() {
2540    if (didInit) {
2541      return false;
2542    }
2543    function cleanup() {
2544      event.remove(window, 'load', sm2.beginDelayedInit);
2545    }
2546    if (sm2.html5Only) {
2547      if (!didInit) {
2548        cleanup();
2549        sm2.enabled = true;
2550        initComplete();
2551      }
2552      return true;
2553    }
2554    initMovie();
2555    try {
2556      flash._externalInterfaceTest(false);
2557      setPolling(true, (sm2.flashPollingInterval || (sm2.useHighPerformance ? 10 : 50)));
2558      if (!sm2.debugMode) {
2559        flash._disableDebug();
2560      }
2561      sm2.enabled = true;
2562      if (!sm2.html5Only) {
2563        event.add(window, 'unload', doNothing);
2564      }
2565    } catch(e) {
2566      catchError({type:'JS_TO_FLASH_EXCEPTION', fatal:true});
2567      failSafely(true);
2568      initComplete();
2569      return false;
2570    }
2571    initComplete();
2572    cleanup();
2573    return true;
2574  };
2575  domContentLoaded = function() {
2576    if (didDCLoaded) {
2577      return false;
2578    }
2579    didDCLoaded = true;
2580    setProperties();
2581    initDebug();
2582    if (!hasFlash && sm2.hasHTML5) {
2583      sm2.setup({
2584        'useHTML5Audio': true,
2585        'preferFlash': false
2586      });
2587    }
2588    testHTML5();
2589    if (!hasFlash && needsFlash) {
2590      messages.push(strings.needFlash);
2591      sm2.setup({
2592        'flashLoadTimeout': 1
2593      });
2594    }
2595    if (doc.removeEventListener) {
2596      doc.removeEventListener('DOMContentLoaded', domContentLoaded, false);
2597    }
2598    initMovie();
2599    return true;
2600  };
2601  domContentLoadedIE = function() {
2602    if (doc.readyState === 'complete') {
2603      domContentLoaded();
2604      doc.detachEvent('onreadystatechange', domContentLoadedIE);
2605    }
2606    return true;
2607  };
2608  winOnLoad = function() {
2609    windowLoaded = true;
2610    event.remove(window, 'load', winOnLoad);
2611  };
2612  preInit = function() {
2613    if (mobileHTML5) {
2614      sm2.setupOptions.useHTML5Audio = true;
2615      sm2.setupOptions.preferFlash = false;
2616      if (is_iDevice || (isAndroid && !ua.match(/android\s2\.3/i))) {
2617        if (is_iDevice) {
2618          sm2.ignoreFlash = true;
2619        }
2620        useGlobalHTML5Audio = true;
2621      }
2622    }
2623  };
2624  preInit();
2625  detectFlash();
2626  event.add(window, 'focus', handleFocus);
2627  event.add(window, 'load', delayWaitForEI);
2628  event.add(window, 'load', winOnLoad);
2629  if (doc.addEventListener) {
2630    doc.addEventListener('DOMContentLoaded', domContentLoaded, false);
2631  } else if (doc.attachEvent) {
2632    doc.attachEvent('onreadystatechange', domContentLoadedIE);
2633  } else {
2634    catchError({type:'NO_DOM2_EVENTS', fatal:true});
2635  }
2636}
2637// SM2_DEFER details: http://www.schillmania.com/projects/soundmanager2/doc/getstarted/#lazy-loading
2638if (window.SM2_DEFER === undefined || !SM2_DEFER) {
2639  soundManager = new SoundManager();
2640}
2641window.SoundManager = SoundManager;
2642window.soundManager = soundManager;
2643}(window));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.