soundmanager2-rails 2.97.20130324 → 2.97.20130512

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@
8
8
  * Code provided under the BSD License:
9
9
  * http://schillmania.com/projects/soundmanager2/license.txt
10
10
  *
11
- * V2.97a.20130324 ("Mahalo" Edition)
11
+ * V2.97a.20130512
12
12
  */
13
13
 
14
14
  /*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio, opera */
@@ -37,7 +37,8 @@ function SoundManager(smURL, smID) {
37
37
  'useHTML5Audio': true,
38
38
  'html5Test': /^(probably|maybe)$/i,
39
39
  'preferFlash': true,
40
- 'noSWFCache': false
40
+ 'noSWFCache': false,
41
+ 'idPrefix': 'sound'
41
42
  };
42
43
  this.defaultOptions = {
43
44
  'autoLoad': false,
@@ -106,7 +107,7 @@ function SoundManager(smURL, smID) {
106
107
  this.id = (smID || 'sm2movie');
107
108
  this.debugID = 'soundmanager-debug';
108
109
  this.debugURLParam = /([#?&])debug=1/i;
109
- this.versionNumber = 'V2.97a.20130324';
110
+ this.versionNumber = 'V2.97a.20130512';
110
111
  this.version = null;
111
112
  this.movieURL = null;
112
113
  this.altURL = null;
@@ -139,11 +140,11 @@ function SoundManager(smURL, smID) {
139
140
  this.ignoreFlash = false;
140
141
  var SMSound,
141
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 = [],
142
- 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,
143
- 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)),
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)),
144
145
  mobileHTML5 = (ua.match(/(mobile|pre\/|xoom)/i) || is_iDevice || isAndroid),
145
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)),
146
- 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,
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,
147
148
  emptyURL = 'about:blank',
148
149
  overHTTP = (doc.location?doc.location.protocol.match(/http/i):null),
149
150
  http = (!overHTTP ? 'http:/'+'/' : ''),
@@ -173,19 +174,20 @@ function SoundManager(smURL, smID) {
173
174
  this.setup = function(options) {
174
175
  var noURL = (!sm2.url);
175
176
  if (options !== _undefined && didInit && needsFlash && sm2.ok() && (options.flashVersion !== _undefined || options.url !== _undefined || options.html5Test !== _undefined)) {
176
- complain(str('setupLate'));
177
177
  }
178
178
  assign(options);
179
- if (noURL && didDCLoaded && options.url !== _undefined) {
180
- sm2.beginDelayedInit();
181
- }
182
- if (!didDCLoaded && options.url !== _undefined && doc.readyState === 'complete') {
183
- setTimeout(domContentLoaded, 1);
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
+ }
184
186
  }
185
187
  return sm2;
186
188
  };
187
189
  this.ok = function() {
188
- return (needsFlash?(didInit && !disabled):(sm2.useHTML5Audio && sm2.hasHTML5));
190
+ return (needsFlash ? (didInit && !disabled) : (sm2.useHTML5Audio && sm2.hasHTML5));
189
191
  };
190
192
  this.supported = this.ok;
191
193
  this.getMovie = function(smID) {
@@ -194,7 +196,6 @@ function SoundManager(smURL, smID) {
194
196
  this.createSound = function(oOptions, _url) {
195
197
  var cs, cs_string, options, oSound = null;
196
198
  if (!didInit || !sm2.ok()) {
197
- complain(cs_string);
198
199
  return false;
199
200
  }
200
201
  if (_url !== _undefined) {
@@ -205,6 +206,9 @@ function SoundManager(smURL, smID) {
205
206
  }
206
207
  options = mixin(oOptions);
207
208
  options.url = parseURL(options.url);
209
+ if (options.id === undefined) {
210
+ options.id = sm2.setupOptions.idPrefix + (idCounter++);
211
+ }
208
212
  if (idCheck(options.id, true)) {
209
213
  return sm2.sounds[options.id];
210
214
  }
@@ -218,9 +222,15 @@ function SoundManager(smURL, smID) {
218
222
  oSound = make();
219
223
  oSound._setup_html5(options);
220
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
+ }
221
231
  if (fV > 8) {
222
232
  if (options.isMovieStar === null) {
223
- options.isMovieStar = !!(options.serverURL || (options.type ? options.type.match(netStreamMimeTypes) : false) || options.url.match(netStreamPattern));
233
+ options.isMovieStar = !!(options.serverURL || (options.type ? options.type.match(netStreamMimeTypes) : false) || (options.url && options.url.match(netStreamPattern)));
224
234
  }
225
235
  }
226
236
  options = policyFix(options, cs);
@@ -292,13 +302,16 @@ function SoundManager(smURL, smID) {
292
302
  return sm2.sounds[sID].clearOnPosition(nPosition, oMethod);
293
303
  };
294
304
  this.play = function(sID, oOptions) {
295
- var result = false;
305
+ var result = null,
306
+ overloaded = (oOptions && !(oOptions instanceof Object));
296
307
  if (!didInit || !sm2.ok()) {
297
- complain(sm + '.play(): ' + str(!didInit?'notReady':'notOK'));
298
- return result;
308
+ return false;
299
309
  }
300
- if (!idCheck(sID)) {
301
- if (!(oOptions instanceof Object)) {
310
+ if (!idCheck(sID, overloaded)) {
311
+ if (!overloaded) {
312
+ return false;
313
+ }
314
+ if (overloaded) {
302
315
  oOptions = {
303
316
  url: oOptions
304
317
  };
@@ -307,9 +320,15 @@ function SoundManager(smURL, smID) {
307
320
  oOptions.id = sID;
308
321
  result = sm2.createSound(oOptions).play();
309
322
  }
310
- return result;
323
+ } else if (overloaded) {
324
+ oOptions = {
325
+ url: oOptions
326
+ };
327
+ }
328
+ if (result === null) {
329
+ result = sm2.sounds[sID].play(oOptions);
311
330
  }
312
- return sm2.sounds[sID].play(oOptions);
331
+ return result;
313
332
  };
314
333
  this.start = this.play;
315
334
  this.setPosition = function(sID, nMsecOffset) {
@@ -475,7 +494,7 @@ function SoundManager(smURL, smID) {
475
494
  };
476
495
  this.getSoundById = function(sID, _suppressDebug) {
477
496
  if (!sID) {
478
- throw new Error(sm + '.getSoundById(): sID is null/_undefined');
497
+ return null;
479
498
  }
480
499
  var result = sm2.sounds[sID];
481
500
  return result;
@@ -534,6 +553,7 @@ function SoundManager(smURL, smID) {
534
553
  sm2.enabled = didDCLoaded = didInit = waitingForEI = initPending = didAppend = appendSuccess = disabled = useGlobalHTML5Audio = sm2.swfLoaded = false;
535
554
  sm2.soundIDs = [];
536
555
  sm2.sounds = {};
556
+ idCounter = 0;
537
557
  if (!resetEvents) {
538
558
  for (i in on_queue) {
539
559
  if (on_queue.hasOwnProperty(i)) {
@@ -583,7 +603,7 @@ function SoundManager(smURL, smID) {
583
603
  sm2.disable(true);
584
604
  };
585
605
  SMSound = function(oOptions) {
586
- 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;
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;
587
607
  lastHTML5State = {
588
608
  duration: null,
589
609
  time: null
@@ -598,6 +618,7 @@ function SoundManager(smURL, smID) {
598
618
  this.volume = this.options.volume;
599
619
  this.isHTML5 = false;
600
620
  this._a = null;
621
+ urlOmitted = (this.url ? false : true);
601
622
  this.id3 = {};
602
623
  this._debug = function() {
603
624
  };
@@ -619,6 +640,9 @@ function SoundManager(smURL, smID) {
619
640
  s._iO.url = parseURL(s._iO.url);
620
641
  s.instanceOptions = s._iO;
621
642
  instanceOptions = s._iO;
643
+ if (!instanceOptions.url && !s.url) {
644
+ return s;
645
+ }
622
646
  if (instanceOptions.url === s.url && s.readyState !== 0 && s.readyState !== 2) {
623
647
  if (s.readyState === 3 && instanceOptions.onload) {
624
648
  wrapCallback(s, function() {
@@ -648,6 +672,12 @@ function SoundManager(smURL, smID) {
648
672
  } else {
649
673
  }
650
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
+ }
651
681
  try {
652
682
  s.isHTML5 = false;
653
683
  s._iO = policyFix(loopFix(instanceOptions));
@@ -676,8 +706,7 @@ function SoundManager(smURL, smID) {
676
706
  stop_html5_timer();
677
707
  if (s._a) {
678
708
  s._a.pause();
679
- html5Unload(s._a, emptyURL);
680
- lastURL = emptyURL;
709
+ lastURL = html5Unload(s._a);
681
710
  }
682
711
  }
683
712
  resetProperties();
@@ -705,7 +734,9 @@ function SoundManager(smURL, smID) {
705
734
  }
706
735
  };
707
736
  this.play = function(oOptions, _updatePlayState) {
708
- var fN, allowMulti, a, onready, startOK = true,
737
+ var fN, allowMulti, a, onready,
738
+ audioClone, onended, oncanplay,
739
+ startOK = true,
709
740
  exit = null;
710
741
  _updatePlayState = (_updatePlayState === _undefined ? true : _updatePlayState);
711
742
  if (!oOptions) {
@@ -718,7 +749,7 @@ function SoundManager(smURL, smID) {
718
749
  s._iO = mixin(oOptions, s._iO);
719
750
  s._iO.url = parseURL(s._iO.url);
720
751
  s.instanceOptions = s._iO;
721
- if (s._iO.serverURL && !s.connected) {
752
+ if (!s.isHTML5 && s._iO.serverURL && !s.connected) {
722
753
  if (!s.getAutoPlay()) {
723
754
  s.setAutoPlay(true);
724
755
  }
@@ -731,6 +762,9 @@ function SoundManager(smURL, smID) {
731
762
  if (s.playState === 1 && !s.paused) {
732
763
  allowMulti = s._iO.multiShot;
733
764
  if (!allowMulti) {
765
+ if (s.isHTML5) {
766
+ s.setPosition(s._iO.position);
767
+ }
734
768
  exit = s;
735
769
  } else {
736
770
  }
@@ -739,15 +773,21 @@ function SoundManager(smURL, smID) {
739
773
  return exit;
740
774
  }
741
775
  if (oOptions.url && oOptions.url !== s.url) {
742
- s.load(s._iO);
776
+ if (!s.readyState && !s.isHTML5 && fV === 8 && urlOmitted) {
777
+ urlOmitted = false;
778
+ } else {
779
+ s.load(s._iO);
780
+ }
743
781
  }
744
782
  if (!s.loaded) {
745
783
  if (s.readyState === 0) {
746
- if (!s.isHTML5) {
784
+ if (!s.isHTML5 && !sm2.html5Only) {
747
785
  s._iO.autoPlay = true;
748
786
  s.load(s._iO);
749
- } else {
787
+ } else if (s.isHTML5) {
750
788
  s.load(s._iO);
789
+ } else {
790
+ exit = s;
751
791
  }
752
792
  s.instanceOptions = s._iO;
753
793
  } else if (s.readyState === 2) {
@@ -787,7 +827,7 @@ function SoundManager(smURL, smID) {
787
827
  }
788
828
  s._iO = applyFromTo();
789
829
  }
790
- if (!s.instanceCount || s._iO.multiShotEvents || (!s.isHTML5 && fV > 8 && !s.getAutoPlay())) {
830
+ if (!s.instanceCount || s._iO.multiShotEvents || (s.isHTML5 && s._iO.multiShot && !useGlobalHTML5Audio) || (!s.isHTML5 && fV > 8 && !s.getAutoPlay())) {
791
831
  s.instanceCount++;
792
832
  }
793
833
  if (s._iO.onposition && s.playState === 0) {
@@ -806,17 +846,41 @@ function SoundManager(smURL, smID) {
806
846
  s.setVolume(s._iO.volume, true);
807
847
  s.setPan(s._iO.pan, true);
808
848
  if (!s.isHTML5) {
809
- startOK = flash._start(s.id, s._iO.loops || 1, (fV === 9 ? s.position : s.position / 1000), s._iO.multiShot || false);
849
+ startOK = flash._start(s.id, s._iO.loops || 1, (fV === 9 ? s.position : s.position / msecScale), s._iO.multiShot || false);
810
850
  if (fV === 9 && !startOK) {
811
851
  if (s._iO.onplayerror) {
812
852
  s._iO.onplayerror.apply(s);
813
853
  }
814
854
  }
815
855
  } else {
816
- start_html5_timer();
817
- a = s._setup_html5();
818
- s.setPosition(s._iO.position);
819
- a.play();
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
+ }
820
884
  }
821
885
  }
822
886
  return s;
@@ -878,12 +942,10 @@ function SoundManager(smURL, smID) {
878
942
  if (nMsecOffset === _undefined) {
879
943
  nMsecOffset = 0;
880
944
  }
881
- var original_pos,
882
- position, position1K,
945
+ var position, position1K,
883
946
  offset = (s.isHTML5 ? Math.max(nMsecOffset, 0) : Math.min(s.duration || s._iO.duration, Math.max(nMsecOffset, 0)));
884
- original_pos = s.position;
885
947
  s.position = offset;
886
- position1K = s.position/1000;
948
+ position1K = s.position/msecScale;
887
949
  s._resetOnPosition(s.position);
888
950
  s._iO.position = offset;
889
951
  if (!s.isHTML5) {
@@ -902,10 +964,9 @@ function SoundManager(smURL, smID) {
902
964
  } catch(e) {
903
965
  }
904
966
  }
905
- } else {
967
+ } else if (position1K) {
968
+ return s;
906
969
  }
907
- }
908
- if (s.isHTML5) {
909
970
  if (s.paused) {
910
971
  s._onTimer(true);
911
972
  }
@@ -957,7 +1018,7 @@ function SoundManager(smURL, smID) {
957
1018
  this.togglePause = function() {
958
1019
  if (s.playState === 0) {
959
1020
  s.play({
960
- position: (fV === 9 && !s.isHTML5 ? s.position : s.position / 1000)
1021
+ position: (fV === 9 && !s.isHTML5 ? s.position : s.position / msecScale)
961
1022
  });
962
1023
  return s;
963
1024
  }
@@ -1185,7 +1246,7 @@ function SoundManager(smURL, smID) {
1185
1246
  isNew = true;
1186
1247
  }
1187
1248
  s.durationEstimate = s.duration;
1188
- time = (s._a.currentTime * 1000 || 0);
1249
+ time = (s._a.currentTime * msecScale || 0);
1189
1250
  if (time !== lastHTML5State.time) {
1190
1251
  lastHTML5State.time = time;
1191
1252
  isNew = true;
@@ -1199,7 +1260,7 @@ function SoundManager(smURL, smID) {
1199
1260
  };
1200
1261
  this._get_html5_duration = function() {
1201
1262
  var instanceOptions = s._iO,
1202
- d = (s._a && s._a.duration ? s._a.duration*1000 : (instanceOptions && instanceOptions.duration ? instanceOptions.duration : null)),
1263
+ d = (s._a && s._a.duration ? s._a.duration*msecScale : (instanceOptions && instanceOptions.duration ? instanceOptions.duration : null)),
1203
1264
  result = (d && !isNaN(d) && d !== Infinity ? d : null);
1204
1265
  return result;
1205
1266
  };
@@ -1523,7 +1584,6 @@ function SoundManager(smURL, smID) {
1523
1584
  sm2.setupOptions[i] = o[i];
1524
1585
  sm2[i] = o[i];
1525
1586
  } else if (bonusOptions[i] === _undefined) {
1526
- complain(str((sm2[i] === _undefined ? 'setupUndef' : 'setupError'), i), 2);
1527
1587
  result = false;
1528
1588
  } else {
1529
1589
  if (sm2[i] instanceof Function) {
@@ -1534,7 +1594,6 @@ function SoundManager(smURL, smID) {
1534
1594
  }
1535
1595
  } else {
1536
1596
  if (bonusOptions[i] === _undefined) {
1537
- complain(str((sm2[i] === _undefined ? 'setupUndef' : 'setupError'), i), 2);
1538
1597
  result = false;
1539
1598
  } else {
1540
1599
  return assign(o[i], i);
@@ -1609,7 +1668,7 @@ function SoundManager(smURL, smID) {
1609
1668
  }
1610
1669
  s._html5_canplay = true;
1611
1670
  s._onbufferchange(0);
1612
- position1K = (s._iO.position !== _undefined && !isNaN(s._iO.position)?s._iO.position/1000:null);
1671
+ position1K = (s._iO.position !== _undefined && !isNaN(s._iO.position)?s._iO.position/msecScale:null);
1613
1672
  if (s.position && this.currentTime !== position1K) {
1614
1673
  try {
1615
1674
  this.currentTime = position1K;
@@ -1658,18 +1717,17 @@ function SoundManager(smURL, smID) {
1658
1717
  isProgress = (e.type === 'progress'),
1659
1718
  ranges = e.target.buffered,
1660
1719
  loaded = (e.loaded||0),
1661
- total = (e.total||1),
1662
- scale = 1000;
1720
+ total = (e.total||1);
1663
1721
  s.buffered = [];
1664
1722
  if (ranges && ranges.length) {
1665
1723
  for (i=0, j=ranges.length; i<j; i++) {
1666
1724
  s.buffered.push({
1667
- 'start': ranges.start(i) * scale,
1668
- 'end': ranges.end(i) * scale
1725
+ 'start': ranges.start(i) * msecScale,
1726
+ 'end': ranges.end(i) * msecScale
1669
1727
  });
1670
1728
  }
1671
- buffered = (ranges.end(0) - ranges.start(0)) * scale;
1672
- loaded = buffered/(e.target.duration*scale);
1729
+ buffered = (ranges.end(0) - ranges.start(0)) * msecScale;
1730
+ loaded = Math.min(1, buffered/(e.target.duration*msecScale));
1673
1731
  }
1674
1732
  if (!isNaN(loaded)) {
1675
1733
  s._onbufferchange(0);
@@ -1698,21 +1756,28 @@ function SoundManager(smURL, smID) {
1698
1756
  };
1699
1757
  html5OK = function(iO) {
1700
1758
  var result;
1701
- if (iO.serverURL || (iO.type && preferFlashCheck(iO.type))) {
1759
+ if (!iO || (!iO.type && !iO.url && !iO.serverURL)) {
1760
+ result = false;
1761
+ } else if (iO.serverURL || (iO.type && preferFlashCheck(iO.type))) {
1702
1762
  result = false;
1703
1763
  } else {
1704
- result = ((iO.type ? html5CanPlay({type:iO.type}) : html5CanPlay({url:iO.url}) || sm2.html5Only));
1764
+ result = ((iO.type ? html5CanPlay({type:iO.type}) : html5CanPlay({url:iO.url}) || sm2.html5Only || iO.url.match(/data\:/i)));
1705
1765
  }
1706
1766
  return result;
1707
1767
  };
1708
- html5Unload = function(oAudio, url) {
1768
+ html5Unload = function(oAudio) {
1769
+ var url;
1709
1770
  if (oAudio) {
1771
+ url = (isSafari && !is_iDevice ? null : (isFirefox ? emptyURL : null));
1710
1772
  oAudio.src = url;
1711
- oAudio._called_load = false;
1773
+ if (oAudio._called_unload !== undefined) {
1774
+ oAudio._called_load = false;
1775
+ }
1712
1776
  }
1713
1777
  if (useGlobalHTML5Audio) {
1714
1778
  lastGlobalHTML5URL = null;
1715
1779
  }
1780
+ return url;
1716
1781
  };
1717
1782
  html5CanPlay = function(o) {
1718
1783
  if (!sm2.useHTML5Audio || !sm2.hasHTML5) {
@@ -1763,6 +1828,8 @@ function SoundManager(smURL, smID) {
1763
1828
  };
1764
1829
  testHTML5 = function() {
1765
1830
  if (!sm2.useHTML5Audio || !sm2.hasHTML5) {
1831
+ sm2.html5.usingFlash = true;
1832
+ needsFlash = true;
1766
1833
  return false;
1767
1834
  }
1768
1835
  var a = (Audio !== _undefined ? (isOpera && opera.version() < 10 ? new Audio(null) : new Audio()) : null),
@@ -1813,6 +1880,8 @@ function SoundManager(smURL, smID) {
1813
1880
  }
1814
1881
  support.canPlayType = (a?cp:null);
1815
1882
  sm2.html5 = mixin(sm2.html5, support);
1883
+ sm2.html5.usingFlash = featureCheck();
1884
+ needsFlash = sm2.html5.usingFlash;
1816
1885
  return true;
1817
1886
  };
1818
1887
  strings = {
@@ -1901,9 +1970,6 @@ function SoundManager(smURL, smID) {
1901
1970
  flash._setPolling(bPolling, bHighPerformance);
1902
1971
  };
1903
1972
  initDebug = function() {
1904
- if (sm2.debugURLParam.test(wl)) {
1905
- sm2.debugMode = true;
1906
- }
1907
1973
  };
1908
1974
  idCheck = this.getSoundById;
1909
1975
  getSWFCSS = function() {
@@ -2020,6 +2086,7 @@ function SoundManager(smURL, smID) {
2020
2086
  try {
2021
2087
  obj = new AX('ShockwaveFlash.ShockwaveFlash');
2022
2088
  } catch(e) {
2089
+ obj = null;
2023
2090
  }
2024
2091
  hasPlugin = (!!obj);
2025
2092
  obj = null;
@@ -2028,9 +2095,8 @@ function SoundManager(smURL, smID) {
2028
2095
  return hasPlugin;
2029
2096
  };
2030
2097
  featureCheck = function() {
2031
- var needsFlash,
2098
+ var flashNeeded,
2032
2099
  item,
2033
- result = true,
2034
2100
  formats = sm2.audioFormats,
2035
2101
  isSpecial = (is_iDevice && !!(ua.match(/os (1|2|3_0|3_1)/i)));
2036
2102
  if (isSpecial) {
@@ -2039,7 +2105,6 @@ function SoundManager(smURL, smID) {
2039
2105
  if (sm2.oMC) {
2040
2106
  sm2.oMC.style.display = 'none';
2041
2107
  }
2042
- result = false;
2043
2108
  } else {
2044
2109
  if (sm2.useHTML5Audio) {
2045
2110
  if (!sm2.html5 || !sm2.html5.canPlayType) {
@@ -2048,18 +2113,25 @@ function SoundManager(smURL, smID) {
2048
2113
  }
2049
2114
  }
2050
2115
  if (sm2.useHTML5Audio && sm2.hasHTML5) {
2116
+ canIgnoreFlash = true;
2051
2117
  for (item in formats) {
2052
2118
  if (formats.hasOwnProperty(item)) {
2053
- if ((formats[item].required && !sm2.html5.canPlayType(formats[item].type)) || (sm2.preferFlash && (sm2.flash[item] || sm2.flash[formats[item].type]))) {
2054
- needsFlash = true;
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
+ }
2055
2126
  }
2056
2127
  }
2057
2128
  }
2058
2129
  }
2059
2130
  if (sm2.ignoreFlash) {
2060
- needsFlash = false;
2131
+ flashNeeded = false;
2132
+ canIgnoreFlash = true;
2061
2133
  }
2062
- sm2.html5Only = (sm2.hasHTML5 && sm2.useHTML5Audio && !needsFlash);
2134
+ sm2.html5Only = (sm2.hasHTML5 && sm2.useHTML5Audio && !flashNeeded);
2063
2135
  return (!sm2.html5Only);
2064
2136
  };
2065
2137
  parseURL = function(url) {
@@ -2146,7 +2218,7 @@ function SoundManager(smURL, smID) {
2146
2218
  };
2147
2219
  this._setSandboxType = function(sandboxType) {
2148
2220
  };
2149
- this._externalInterfaceOK = function(flashDate, swfVersion) {
2221
+ this._externalInterfaceOK = function(swfVersion) {
2150
2222
  if (sm2.swfLoaded) {
2151
2223
  return false;
2152
2224
  }
@@ -2375,7 +2447,17 @@ function SoundManager(smURL, smID) {
2375
2447
  flashBlockHandler();
2376
2448
  }
2377
2449
  } else {
2378
- processOnEvents({type:'ontimeout', ignoreInit: true});
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
+ }
2379
2461
  }
2380
2462
  } else {
2381
2463
  if (sm2.flashLoadTimeout === 0) {
@@ -2504,8 +2586,6 @@ function SoundManager(smURL, smID) {
2504
2586
  });
2505
2587
  }
2506
2588
  testHTML5();
2507
- sm2.html5.usingFlash = featureCheck();
2508
- needsFlash = sm2.html5.usingFlash;
2509
2589
  if (!hasFlash && needsFlash) {
2510
2590
  messages.push(strings.needFlash);
2511
2591
  sm2.setup({