soundmanager2-rails 2.97.20150601 → 2.97.20170601

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,111 +8,117 @@
8
8
  * Code provided under the BSD License:
9
9
  * http://schillmania.com/projects/soundmanager2/license.txt
10
10
  *
11
- * V2.97a.20150601
11
+ * V2.97a.20170601
12
12
  */
13
13
 
14
- /*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio, opera, module, define */
15
- /*jslint regexp: true, sloppy: true, white: true, nomen: true, plusplus: true, todo: true */
14
+ /**
15
+ * About this file
16
16
 
17
- (function(window, _undefined) {
18
- "use strict";
17
+ (function SM2(window, _undefined) {
18
+ 'use strict';
19
19
  if (!window || !window.document) {
20
20
  throw new Error('SoundManager requires a browser with window and document objects.');
21
21
  }
22
22
  var soundManager = null;
23
23
  function SoundManager(smURL, smID) {
24
24
  this.setupOptions = {
25
- 'url': (smURL || null),
26
- 'flashVersion': 8,
27
- 'debugMode': true,
28
- 'debugFlash': false,
29
- 'useConsole': true,
30
- 'consoleOnly': true,
31
- 'waitForWindowLoad': false,
32
- 'bgColor': '#ffffff',
33
- 'useHighPerformance': false,
34
- 'flashPollingInterval': null,
35
- 'html5PollingInterval': null,
36
- 'flashLoadTimeout': 1000,
37
- 'wmode': null,
38
- 'allowScriptAccess': 'always',
39
- 'useFlashBlock': false,
40
- 'useHTML5Audio': true,
41
- 'forceUseGlobalHTML5Audio': false,
42
- 'ignoreMobileRestrictions': false,
43
- 'html5Test': /^(probably|maybe)$/i,
44
- 'preferFlash': false,
45
- 'noSWFCache': false,
46
- 'idPrefix': 'sound'
25
+ url: (smURL || null),
26
+ flashVersion: 8,
27
+ debugMode: true,
28
+ debugFlash: false,
29
+ useConsole: true,
30
+ consoleOnly: true,
31
+ waitForWindowLoad: false,
32
+ bgColor: '#ffffff',
33
+ useHighPerformance: false,
34
+ flashPollingInterval: null,
35
+ html5PollingInterval: null,
36
+ flashLoadTimeout: 1000,
37
+ wmode: null,
38
+ allowScriptAccess: 'always',
39
+ useFlashBlock: false,
40
+ useHTML5Audio: true,
41
+ forceUseGlobalHTML5Audio: false,
42
+ ignoreMobileRestrictions: false,
43
+ html5Test: /^(probably|maybe)$/i,
44
+ preferFlash: false,
45
+ noSWFCache: false,
46
+ idPrefix: 'sound'
47
47
  };
48
48
  this.defaultOptions = {
49
- 'autoLoad': false,
50
- 'autoPlay': false,
51
- 'from': null,
52
- 'loops': 1,
53
- 'onid3': null,
54
- 'onload': null,
55
- 'whileloading': null,
56
- 'onplay': null,
57
- 'onpause': null,
58
- 'onresume': null,
59
- 'whileplaying': null,
60
- 'onposition': null,
61
- 'onstop': null,
62
- 'onfailure': null,
63
- 'onfinish': null,
64
- 'multiShot': true,
65
- 'multiShotEvents': false,
66
- 'position': null,
67
- 'pan': 0,
68
- 'stream': true,
69
- 'to': null,
70
- 'type': null,
71
- 'usePolicyFile': false,
72
- 'volume': 100
49
+ autoLoad: false,
50
+ autoPlay: false,
51
+ from: null,
52
+ loops: 1,
53
+ onid3: null,
54
+ onerror: null,
55
+ onload: null,
56
+ whileloading: null,
57
+ onplay: null,
58
+ onpause: null,
59
+ onresume: null,
60
+ whileplaying: null,
61
+ onposition: null,
62
+ onstop: null,
63
+ onfinish: null,
64
+ multiShot: true,
65
+ multiShotEvents: false,
66
+ position: null,
67
+ pan: 0,
68
+ playbackRate: 1,
69
+ stream: true,
70
+ to: null,
71
+ type: null,
72
+ usePolicyFile: false,
73
+ volume: 100
73
74
  };
74
75
  this.flash9Options = {
75
- 'isMovieStar': null,
76
- 'usePeakData': false,
77
- 'useWaveformData': false,
78
- 'useEQData': false,
79
- 'onbufferchange': null,
80
- 'ondataerror': null
76
+ onfailure: null,
77
+ isMovieStar: null,
78
+ usePeakData: false,
79
+ useWaveformData: false,
80
+ useEQData: false,
81
+ onbufferchange: null,
82
+ ondataerror: null
81
83
  };
82
84
  this.movieStarOptions = {
83
- 'bufferTime': 3,
84
- 'serverURL': null,
85
- 'onconnect': null,
86
- 'duration': null
85
+ bufferTime: 3,
86
+ serverURL: null,
87
+ onconnect: null,
88
+ duration: null
87
89
  };
88
90
  this.audioFormats = {
89
- 'mp3': {
90
- 'type': ['audio/mpeg; codecs="mp3"', 'audio/mpeg', 'audio/mp3', 'audio/MPA', 'audio/mpa-robust'],
91
- 'required': true
91
+ mp3: {
92
+ type: ['audio/mpeg; codecs="mp3"', 'audio/mpeg', 'audio/mp3', 'audio/MPA', 'audio/mpa-robust'],
93
+ required: true
92
94
  },
93
- 'mp4': {
94
- 'related': ['aac','m4a','m4b'],
95
- 'type': ['audio/mp4; codecs="mp4a.40.2"', 'audio/aac', 'audio/x-m4a', 'audio/MP4A-LATM', 'audio/mpeg4-generic'],
96
- 'required': false
95
+ mp4: {
96
+ related: ['aac', 'm4a', 'm4b'],
97
+ type: ['audio/mp4; codecs="mp4a.40.2"', 'audio/aac', 'audio/x-m4a', 'audio/MP4A-LATM', 'audio/mpeg4-generic'],
98
+ required: false
97
99
  },
98
- 'ogg': {
99
- 'type': ['audio/ogg; codecs=vorbis'],
100
- 'required': false
100
+ ogg: {
101
+ type: ['audio/ogg; codecs=vorbis'],
102
+ required: false
101
103
  },
102
- 'opus': {
103
- 'type': ['audio/ogg; codecs=opus', 'audio/opus'],
104
- 'required': false
104
+ opus: {
105
+ type: ['audio/ogg; codecs=opus', 'audio/opus'],
106
+ required: false
105
107
  },
106
- 'wav': {
107
- 'type': ['audio/wav; codecs="1"', 'audio/wav', 'audio/wave', 'audio/x-wav'],
108
- 'required': false
108
+ wav: {
109
+ type: ['audio/wav; codecs="1"', 'audio/wav', 'audio/wave', 'audio/x-wav'],
110
+ required: false
111
+ },
112
+ flac: {
113
+ type: ['audio/flac'],
114
+ required: false
109
115
  }
110
116
  };
111
117
  this.movieID = 'sm2-container';
112
118
  this.id = (smID || 'sm2movie');
113
119
  this.debugID = 'soundmanager-debug';
114
120
  this.debugURLParam = /([#?&])debug=1/i;
115
- this.versionNumber = 'V2.97a.20150601';
121
+ this.versionNumber = 'V2.97a.20170601';
116
122
  this.version = null;
117
123
  this.movieURL = null;
118
124
  this.altURL = null;
@@ -125,33 +131,33 @@ function SoundManager(smURL, smID) {
125
131
  this.didFlashBlock = false;
126
132
  this.filePattern = null;
127
133
  this.filePatterns = {
128
- 'flash8': /\.mp3(\?.*)?$/i,
129
- 'flash9': /\.mp3(\?.*)?$/i
134
+ flash8: /\.mp3(\?.*)?$/i,
135
+ flash9: /\.mp3(\?.*)?$/i
130
136
  };
131
137
  this.features = {
132
- 'buffering': false,
133
- 'peakData': false,
134
- 'waveformData': false,
135
- 'eqData': false,
136
- 'movieStar': false
138
+ buffering: false,
139
+ peakData: false,
140
+ waveformData: false,
141
+ eqData: false,
142
+ movieStar: false
137
143
  };
138
144
  this.sandbox = {
139
145
  };
140
146
  this.html5 = {
141
- 'usingFlash': null
147
+ usingFlash: null
142
148
  };
143
149
  this.flash = {};
144
150
  this.html5Only = false;
145
151
  this.ignoreFlash = false;
146
152
  var SMSound,
147
153
  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, rebootIntoHTML5, setVersionInfo, handleFocus, strings, initMovie, 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 = [],
148
- 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, didSetup, msecScale = 1000,
149
- is_iDevice = ua.match(/(ipad|iphone|ipod)/i), isAndroid = ua.match(/android/i), isIE = ua.match(/msie/i),
154
+ canIgnoreFlash, needsFlash = null, featureCheck, html5OK, html5CanPlay, html5ErrorCodes, html5Ext, html5Unload, domContentLoadedIE, testHTML5, event, slice = Array.prototype.slice, useGlobalHTML5Audio = false, lastGlobalHTML5URL, hasFlash, detectFlash, badSafariFix, html5_events, showSupport, flushMessages, wrapCallback, idCounter = 0, didSetup, msecScale = 1000,
155
+ is_iDevice = ua.match(/(ipad|iphone|ipod)/i), isAndroid = ua.match(/android/i), isIE = ua.match(/msie|trident/i),
150
156
  isWebkit = ua.match(/webkit/i),
151
157
  isSafari = (ua.match(/safari/i) && !ua.match(/chrome/i)),
152
158
  isOpera = (ua.match(/opera/i)),
153
159
  mobileHTML5 = (ua.match(/(mobile|pre\/|xoom)/i) || is_iDevice || isAndroid),
154
- isBadSafari = (!wl.match(/usehtml5audio/i) && !wl.match(/sm2\-ignorebadua/i) && isSafari && !ua.match(/silk/i) && ua.match(/OS X 10_6_([3-7])/i)),
160
+ isBadSafari = (!wl.match(/usehtml5audio/i) && !wl.match(/sm2-ignorebadua/i) && isSafari && !ua.match(/silk/i) && ua.match(/OS\sX\s10_6_([3-7])/i)),
155
161
  hasConsole = (window.console !== _undefined && console.log !== _undefined),
156
162
  isFocused = (doc.hasFocus !== _undefined ? doc.hasFocus() : null),
157
163
  tryInitOnFocus = (isSafari && (doc.hasFocus === _undefined || !doc.hasFocus())),
@@ -160,23 +166,30 @@ function SoundManager(smURL, smID) {
160
166
  emptyURL = 'about:blank',
161
167
  emptyWAV = 'data:audio/wave;base64,/UklGRiYAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQIAAAD//w==',
162
168
  overHTTP = (doc.location ? doc.location.protocol.match(/http/i) : null),
163
- http = (!overHTTP ? 'http:/'+'/' : ''),
164
- netStreamMimeTypes = /^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i,
169
+ http = (!overHTTP ? '//' : ''),
170
+ netStreamMimeTypes = /^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4|m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i,
165
171
  netStreamTypes = ['mpeg4', 'aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', 'm4b', 'mp4v', '3gp', '3g2'],
166
172
  netStreamPattern = new RegExp('\\.(' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i');
167
173
  this.mimePattern = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;
168
174
  this.useAltURL = !overHTTP;
169
175
  swfCSS = {
170
- 'swfBox': 'sm2-object-box',
171
- 'swfDefault': 'movieContainer',
172
- 'swfError': 'swf_error',
173
- 'swfTimedout': 'swf_timedout',
174
- 'swfLoaded': 'swf_loaded',
175
- 'swfUnblocked': 'swf_unblocked',
176
- 'sm2Debug': 'sm2_debug',
177
- 'highPerf': 'high_performance',
178
- 'flashDebug': 'flash_debug'
179
- };
176
+ swfBox: 'sm2-object-box',
177
+ swfDefault: 'movieContainer',
178
+ swfError: 'swf_error',
179
+ swfTimedout: 'swf_timedout',
180
+ swfLoaded: 'swf_loaded',
181
+ swfUnblocked: 'swf_unblocked',
182
+ sm2Debug: 'sm2_debug',
183
+ highPerf: 'high_performance',
184
+ flashDebug: 'flash_debug'
185
+ };
186
+ html5ErrorCodes = [
187
+ null,
188
+ 'MEDIA_ERR_ABORTED',
189
+ 'MEDIA_ERR_NETWORK',
190
+ 'MEDIA_ERR_DECODE',
191
+ 'MEDIA_ERR_SRC_NOT_SUPPORTED'
192
+ ];
180
193
  this.hasHTML5 = (function() {
181
194
  try {
182
195
  return (Audio !== _undefined && (isOpera && opera !== _undefined && opera.version() < 10 ? new Audio(null) : new Audio()).canPlayType !== _undefined);
@@ -195,11 +208,9 @@ function SoundManager(smURL, smID) {
195
208
  messages.push(strings.globalHTML5);
196
209
  useGlobalHTML5Audio = true;
197
210
  }
198
- } else {
199
- if (sm2.setupOptions.forceUseGlobalHTML5Audio) {
200
- messages.push(strings.globalHTML5);
201
- useGlobalHTML5Audio = true;
202
- }
211
+ } else if (sm2.setupOptions.forceUseGlobalHTML5Audio) {
212
+ messages.push(strings.globalHTML5);
213
+ useGlobalHTML5Audio = true;
203
214
  }
204
215
  }
205
216
  if (!didSetup && mobileHTML5) {
@@ -230,8 +241,8 @@ function SoundManager(smURL, smID) {
230
241
  return (needsFlash ? (didInit && !disabled) : (sm2.useHTML5Audio && sm2.hasHTML5));
231
242
  };
232
243
  this.supported = this.ok;
233
- this.getMovie = function(smID) {
234
- return id(smID) || doc[smID] || window[smID];
244
+ this.getMovie = function(movie_id) {
245
+ return id(movie_id) || doc[movie_id] || window[movie_id];
235
246
  };
236
247
  this.createSound = function(oOptions, _url) {
237
248
  var cs, cs_string, options, oSound = null;
@@ -240,8 +251,8 @@ function SoundManager(smURL, smID) {
240
251
  }
241
252
  if (_url !== _undefined) {
242
253
  oOptions = {
243
- 'id': oOptions,
244
- 'url': _url
254
+ id: oOptions,
255
+ url: _url
245
256
  };
246
257
  }
247
258
  options = mixin(oOptions);
@@ -265,7 +276,7 @@ function SoundManager(smURL, smID) {
265
276
  if (sm2.html5Only) {
266
277
  return make();
267
278
  }
268
- if (sm2.html5.usingFlash && options.url && options.url.match(/data\:/i)) {
279
+ if (sm2.html5.usingFlash && options.url && options.url.match(/data:/i)) {
269
280
  return make();
270
281
  }
271
282
  if (fV > 8) {
@@ -296,9 +307,7 @@ function SoundManager(smURL, smID) {
296
307
  return oSound;
297
308
  };
298
309
  this.destroySound = function(sID, _bFromSound) {
299
- if (!idCheck(sID)) {
300
- return false;
301
- }
310
+ if (!idCheck(sID)) return false;
302
311
  var oS = sm2.sounds[sID], i;
303
312
  oS.stop();
304
313
  oS._iO = {};
@@ -317,28 +326,20 @@ function SoundManager(smURL, smID) {
317
326
  return true;
318
327
  };
319
328
  this.load = function(sID, oOptions) {
320
- if (!idCheck(sID)) {
321
- return false;
322
- }
329
+ if (!idCheck(sID)) return false;
323
330
  return sm2.sounds[sID].load(oOptions);
324
331
  };
325
332
  this.unload = function(sID) {
326
- if (!idCheck(sID)) {
327
- return false;
328
- }
333
+ if (!idCheck(sID)) return false;
329
334
  return sm2.sounds[sID].unload();
330
335
  };
331
336
  this.onPosition = function(sID, nPosition, oMethod, oScope) {
332
- if (!idCheck(sID)) {
333
- return false;
334
- }
337
+ if (!idCheck(sID)) return false;
335
338
  return sm2.sounds[sID].onposition(nPosition, oMethod, oScope);
336
339
  };
337
340
  this.onposition = this.onPosition;
338
341
  this.clearOnPosition = function(sID, nPosition, oMethod) {
339
- if (!idCheck(sID)) {
340
- return false;
341
- }
342
+ if (!idCheck(sID)) return false;
342
343
  return sm2.sounds[sID].clearOnPosition(nPosition, oMethod);
343
344
  };
344
345
  this.play = function(sID, oOptions) {
@@ -348,9 +349,7 @@ function SoundManager(smURL, smID) {
348
349
  return false;
349
350
  }
350
351
  if (!idCheck(sID, overloaded)) {
351
- if (!overloaded) {
352
- return false;
353
- }
352
+ if (!overloaded) return false;
354
353
  if (overloaded) {
355
354
  oOptions = {
356
355
  url: oOptions
@@ -371,16 +370,16 @@ function SoundManager(smURL, smID) {
371
370
  return result;
372
371
  };
373
372
  this.start = this.play;
373
+ this.setPlaybackRate = function(sID, rate, allowOverride) {
374
+ if (!idCheck(sID)) return false;
375
+ return sm2.sounds[sID].setPlaybackRate(rate, allowOverride);
376
+ };
374
377
  this.setPosition = function(sID, nMsecOffset) {
375
- if (!idCheck(sID)) {
376
- return false;
377
- }
378
+ if (!idCheck(sID)) return false;
378
379
  return sm2.sounds[sID].setPosition(nMsecOffset);
379
380
  };
380
381
  this.stop = function(sID) {
381
- if (!idCheck(sID)) {
382
- return false;
383
- }
382
+ if (!idCheck(sID)) return false;
384
383
  return sm2.sounds[sID].stop();
385
384
  };
386
385
  this.stopAll = function() {
@@ -392,9 +391,7 @@ function SoundManager(smURL, smID) {
392
391
  }
393
392
  };
394
393
  this.pause = function(sID) {
395
- if (!idCheck(sID)) {
396
- return false;
397
- }
394
+ if (!idCheck(sID)) return false;
398
395
  return sm2.sounds[sID].pause();
399
396
  };
400
397
  this.pauseAll = function() {
@@ -404,27 +401,21 @@ function SoundManager(smURL, smID) {
404
401
  }
405
402
  };
406
403
  this.resume = function(sID) {
407
- if (!idCheck(sID)) {
408
- return false;
409
- }
404
+ if (!idCheck(sID)) return false;
410
405
  return sm2.sounds[sID].resume();
411
406
  };
412
407
  this.resumeAll = function() {
413
408
  var i;
414
- for (i = sm2.soundIDs.length- 1 ; i >= 0; i--) {
409
+ for (i = sm2.soundIDs.length - 1; i >= 0; i--) {
415
410
  sm2.sounds[sm2.soundIDs[i]].resume();
416
411
  }
417
412
  };
418
413
  this.togglePause = function(sID) {
419
- if (!idCheck(sID)) {
420
- return false;
421
- }
414
+ if (!idCheck(sID)) return false;
422
415
  return sm2.sounds[sID].togglePause();
423
416
  };
424
417
  this.setPan = function(sID, nPan) {
425
- if (!idCheck(sID)) {
426
- return false;
427
- }
418
+ if (!idCheck(sID)) return false;
428
419
  return sm2.sounds[sID].setPan(nPan);
429
420
  };
430
421
  this.setVolume = function(sID, nVol) {
@@ -433,11 +424,9 @@ function SoundManager(smURL, smID) {
433
424
  for (i = 0, j = sm2.soundIDs.length; i < j; i++) {
434
425
  sm2.sounds[sm2.soundIDs[i]].setVolume(sID);
435
426
  }
436
- return;
437
- }
438
- if (!idCheck(sID)) {
439
427
  return false;
440
428
  }
429
+ if (!idCheck(sID)) return false;
441
430
  return sm2.sounds[sID].setVolume(nVol);
442
431
  };
443
432
  this.mute = function(sID) {
@@ -451,9 +440,7 @@ function SoundManager(smURL, smID) {
451
440
  }
452
441
  sm2.muted = true;
453
442
  } else {
454
- if (!idCheck(sID)) {
455
- return false;
456
- }
443
+ if (!idCheck(sID)) return false;
457
444
  return sm2.sounds[sID].mute();
458
445
  }
459
446
  return true;
@@ -472,9 +459,7 @@ function SoundManager(smURL, smID) {
472
459
  }
473
460
  sm2.muted = false;
474
461
  } else {
475
- if (!idCheck(sID)) {
476
- return false;
477
- }
462
+ if (!idCheck(sID)) return false;
478
463
  return sm2.sounds[sID].unmute();
479
464
  }
480
465
  return true;
@@ -483,9 +468,7 @@ function SoundManager(smURL, smID) {
483
468
  sm2.unmute();
484
469
  };
485
470
  this.toggleMute = function(sID) {
486
- if (!idCheck(sID)) {
487
- return false;
488
- }
471
+ if (!idCheck(sID)) return false;
489
472
  return sm2.sounds[sID].toggleMute();
490
473
  };
491
474
  this.getMemoryUse = function() {
@@ -500,13 +483,12 @@ function SoundManager(smURL, smID) {
500
483
  if (bNoDisable === _undefined) {
501
484
  bNoDisable = false;
502
485
  }
503
- if (disabled) {
504
- return false;
505
- }
486
+ if (disabled) return false;
506
487
  disabled = true;
507
488
  for (i = sm2.soundIDs.length - 1; i >= 0; i--) {
508
489
  disableObject(sm2.sounds[sm2.soundIDs[i]]);
509
490
  }
491
+ disableObject(sm2);
510
492
  initComplete(bNoDisable);
511
493
  event.remove(window, 'load', initUserOnload);
512
494
  return true;
@@ -536,17 +518,11 @@ function SoundManager(smURL, smID) {
536
518
  return result;
537
519
  };
538
520
  this.canPlayLink = function(oLink) {
539
- if (oLink.type !== _undefined && oLink.type) {
540
- if (sm2.canPlayMIME(oLink.type)) {
541
- return true;
542
- }
543
- }
521
+ if (oLink.type !== _undefined && oLink.type && sm2.canPlayMIME(oLink.type)) return true;
544
522
  return sm2.canPlayURL(oLink.href);
545
523
  };
546
524
  this.getSoundById = function(sID, _suppressDebug) {
547
- if (!sID) {
548
- return null;
549
- }
525
+ if (!sID) return null;
550
526
  var result = sm2.sounds[sID];
551
527
  return result;
552
528
  };
@@ -573,7 +549,7 @@ function SoundManager(smURL, smID) {
573
549
  oScope = window;
574
550
  }
575
551
  addOnEvent(sType, oMethod, oScope);
576
- processOnEvents({type:sType});
552
+ processOnEvents({ type: sType });
577
553
  result = true;
578
554
  } else {
579
555
  throw str('needFunction', sType);
@@ -588,7 +564,7 @@ function SoundManager(smURL, smID) {
588
564
  };
589
565
  this.reboot = function(resetEvents, excludeInit) {
590
566
  var i, j, k;
591
- for (i = sm2.soundIDs.length- 1 ; i >= 0; i--) {
567
+ for (i = sm2.soundIDs.length - 1; i >= 0; i--) {
592
568
  sm2.sounds[sm2.soundIDs[i]].destruct();
593
569
  }
594
570
  if (flash) {
@@ -618,7 +594,7 @@ function SoundManager(smURL, smID) {
618
594
  on_queue = [];
619
595
  }
620
596
  sm2.html5 = {
621
- 'usingFlash': null
597
+ usingFlash: null
622
598
  };
623
599
  sm2.flash = {};
624
600
  sm2.html5Only = false;
@@ -640,9 +616,7 @@ function SoundManager(smURL, smID) {
640
616
  windowLoaded = true;
641
617
  domContentLoaded();
642
618
  setTimeout(function() {
643
- if (initPending) {
644
- return false;
645
- }
619
+ if (initPending) return false;
646
620
  createMovie();
647
621
  initMovie();
648
622
  initPending = true;
@@ -669,17 +643,17 @@ function SoundManager(smURL, smID) {
669
643
  this.volume = this.options.volume;
670
644
  this.isHTML5 = false;
671
645
  this._a = null;
672
- urlOmitted = (this.url ? false : true);
646
+ urlOmitted = (!this.url);
673
647
  this.id3 = {};
674
648
  this._debug = function() {
675
649
  };
676
- this.load = function(oOptions) {
650
+ this.load = function(options) {
677
651
  var oSound = null, instanceOptions;
678
- if (oOptions !== _undefined) {
679
- s._iO = mixin(oOptions, s.options);
652
+ if (options !== _undefined) {
653
+ s._iO = mixin(options, s.options);
680
654
  } else {
681
- oOptions = s.options;
682
- s._iO = oOptions;
655
+ options = s.options;
656
+ s._iO = options;
683
657
  if (lastURL && lastURL !== s.url) {
684
658
  s._iO.url = s.url;
685
659
  s.url = null;
@@ -723,7 +697,7 @@ function SoundManager(smURL, smID) {
723
697
  if (sm2.html5Only) {
724
698
  return s;
725
699
  }
726
- if (s._iO.url && s._iO.url.match(/data\:/i)) {
700
+ if (s._iO.url && s._iO.url.match(/data:/i)) {
727
701
  return s;
728
702
  }
729
703
  try {
@@ -787,20 +761,19 @@ function SoundManager(smURL, smID) {
787
761
  sm2.destroySound(s.id, true);
788
762
  }
789
763
  };
790
- this.play = function(oOptions, _updatePlayState) {
764
+ this.play = function(options, _updatePlayState) {
791
765
  var fN, allowMulti, a, onready,
792
766
  audioClone, onended, oncanplay,
793
- startOK = true,
794
- exit = null;
767
+ startOK = true;
795
768
  _updatePlayState = (_updatePlayState === _undefined ? true : _updatePlayState);
796
- if (!oOptions) {
797
- oOptions = {};
769
+ if (!options) {
770
+ options = {};
798
771
  }
799
772
  if (s.url) {
800
773
  s._iO.url = s.url;
801
774
  }
802
775
  s._iO = mixin(s._iO, s.options);
803
- s._iO = mixin(oOptions, s._iO);
776
+ s._iO = mixin(options, s._iO);
804
777
  s._iO.url = parseURL(s._iO.url);
805
778
  s.instanceOptions = s._iO;
806
779
  if (!s.isHTML5 && s._iO.serverURL && !s.connected) {
@@ -819,14 +792,10 @@ function SoundManager(smURL, smID) {
819
792
  if (s.isHTML5) {
820
793
  s.setPosition(s._iO.position);
821
794
  }
822
- exit = s;
823
- } else {
795
+ return s;
824
796
  }
825
797
  }
826
- if (exit !== null) {
827
- return exit;
828
- }
829
- if (oOptions.url && oOptions.url !== s.url) {
798
+ if (options.url && options.url !== s.url) {
830
799
  if (!s.readyState && !s.isHTML5 && fV === 8 && urlOmitted) {
831
800
  urlOmitted = false;
832
801
  } else {
@@ -841,43 +810,35 @@ function SoundManager(smURL, smID) {
841
810
  } else if (s.isHTML5) {
842
811
  s.load(s._iO);
843
812
  } else {
844
- exit = s;
813
+ return s;
845
814
  }
846
815
  s.instanceOptions = s._iO;
847
816
  } else if (s.readyState === 2) {
848
- exit = s;
817
+ return s;
849
818
  } else {
850
819
  }
851
820
  } else {
852
821
  }
853
- if (exit !== null) {
854
- return exit;
855
- }
856
822
  if (!s.isHTML5 && fV === 9 && s.position > 0 && s.position === s.duration) {
857
- oOptions.position = 0;
823
+ options.position = 0;
858
824
  }
859
825
  if (s.paused && s.position >= 0 && (!s._iO.serverURL || s.position > 0)) {
860
826
  s.resume();
861
827
  } else {
862
- s._iO = mixin(oOptions, s._iO);
828
+ s._iO = mixin(options, s._iO);
863
829
  if (((!s.isHTML5 && s._iO.position !== null && s._iO.position > 0) || (s._iO.from !== null && s._iO.from > 0) || s._iO.to !== null) && s.instanceCount === 0 && s.playState === 0 && !s._iO.serverURL) {
864
830
  onready = function() {
865
- s._iO = mixin(oOptions, s._iO);
831
+ s._iO = mixin(options, s._iO);
866
832
  s.play(s._iO);
867
833
  };
868
834
  if (s.isHTML5 && !s._html5_canplay) {
869
835
  s.load({
870
836
  _oncanplay: onready
871
837
  });
872
- exit = false;
873
838
  } else if (!s.isHTML5 && !s.loaded && (!s.readyState || s.readyState !== 2)) {
874
839
  s.load({
875
840
  onload: onready
876
841
  });
877
- exit = false;
878
- }
879
- if (exit !== null) {
880
- return exit;
881
842
  }
882
843
  s._iO = applyFromTo();
883
844
  }
@@ -899,6 +860,9 @@ function SoundManager(smURL, smID) {
899
860
  }
900
861
  s.setVolume(s._iO.volume, true);
901
862
  s.setPan(s._iO.pan, true);
863
+ if (s._iO.playbackRate !== 1) {
864
+ s.setPlaybackRate(s._iO.playbackRate);
865
+ }
902
866
  if (!s.isHTML5) {
903
867
  startOK = flash._start(s.id, s._iO.loops || 1, (fV === 9 ? s.position : s.position / msecScale), s._iO.multiShot || false);
904
868
  if (fV === 9 && !startOK) {
@@ -906,8 +870,7 @@ function SoundManager(smURL, smID) {
906
870
  s._iO.onplayerror.apply(s);
907
871
  }
908
872
  }
909
- } else {
910
- if (s.instanceCount < 2) {
873
+ } else if (s.instanceCount < 2) {
911
874
  start_html5_timer();
912
875
  a = s._setup_html5();
913
876
  s.setPosition(s._iO.position);
@@ -923,14 +886,14 @@ function SoundManager(smURL, smID) {
923
886
  oncanplay = function() {
924
887
  event.remove(audioClone, 'canplay', oncanplay);
925
888
  try {
926
- audioClone.currentTime = s._iO.position/msecScale;
889
+ audioClone.currentTime = s._iO.position / msecScale;
927
890
  } catch(err) {
928
891
  }
929
892
  audioClone.play();
930
893
  };
931
894
  event.add(audioClone, 'ended', onended);
932
895
  if (s._iO.volume !== _undefined) {
933
- audioClone.volume = Math.max(0, Math.min(1, s._iO.volume/100));
896
+ audioClone.volume = Math.max(0, Math.min(1, s._iO.volume / 100));
934
897
  }
935
898
  if (s.muted) {
936
899
  audioClone.muted = true;
@@ -941,7 +904,6 @@ function SoundManager(smURL, smID) {
941
904
  audioClone.play();
942
905
  }
943
906
  }
944
- }
945
907
  }
946
908
  return s;
947
909
  };
@@ -965,8 +927,7 @@ function SoundManager(smURL, smID) {
965
927
  if (instanceOptions.serverURL) {
966
928
  s.unload();
967
929
  }
968
- } else {
969
- if (s._a) {
930
+ } else if (s._a) {
970
931
  originalPosition = s.position;
971
932
  s.setPosition(0);
972
933
  s.position = originalPosition;
@@ -975,7 +936,6 @@ function SoundManager(smURL, smID) {
975
936
  s._onTimer();
976
937
  stop_html5_timer();
977
938
  }
978
- }
979
939
  s.instanceCount = 0;
980
940
  s._iO = {};
981
941
  if (instanceOptions.onstop) {
@@ -998,6 +958,17 @@ function SoundManager(smURL, smID) {
998
958
  this.getAutoPlay = function() {
999
959
  return s._iO.autoPlay;
1000
960
  };
961
+ this.setPlaybackRate = function(playbackRate) {
962
+ var normalizedRate = Math.max(0.5, Math.min(4, playbackRate));
963
+ if (s.isHTML5) {
964
+ try {
965
+ s._iO.playbackRate = normalizedRate;
966
+ s._a.playbackRate = normalizedRate;
967
+ } catch(e) {
968
+ }
969
+ }
970
+ return s;
971
+ };
1001
972
  this.setPosition = function(nMsecOffset) {
1002
973
  if (nMsecOffset === _undefined) {
1003
974
  nMsecOffset = 0;
@@ -1005,7 +976,7 @@ function SoundManager(smURL, smID) {
1005
976
  var position, position1K,
1006
977
  offset = (s.isHTML5 ? Math.max(nMsecOffset, 0) : Math.min(s.duration || s._iO.duration, Math.max(nMsecOffset, 0)));
1007
978
  s.position = offset;
1008
- position1K = s.position/msecScale;
979
+ position1K = s.position / msecScale;
1009
980
  s._resetOnPosition(s.position);
1010
981
  s._iO.position = offset;
1011
982
  if (!s.isHTML5) {
@@ -1015,7 +986,7 @@ function SoundManager(smURL, smID) {
1015
986
  }
1016
987
  } else if (s._a) {
1017
988
  if (s._html5_canplay) {
1018
- if (s._a.currentTime !== position1K) {
989
+ if (s._a.currentTime.toFixed(3) !== position1K.toFixed(3)) {
1019
990
  try {
1020
991
  s._a.currentTime = position1K;
1021
992
  if (s.playState === 0 || s.paused) {
@@ -1034,9 +1005,7 @@ function SoundManager(smURL, smID) {
1034
1005
  return s;
1035
1006
  };
1036
1007
  this.pause = function(_bCallFlash) {
1037
- if (s.paused || (s.playState === 0 && s.readyState !== 1)) {
1038
- return s;
1039
- }
1008
+ if (s.paused || (s.playState === 0 && s.readyState !== 1)) return s;
1040
1009
  s.paused = true;
1041
1010
  if (!s.isHTML5) {
1042
1011
  if (_bCallFlash || _bCallFlash === _undefined) {
@@ -1053,9 +1022,7 @@ function SoundManager(smURL, smID) {
1053
1022
  };
1054
1023
  this.resume = function() {
1055
1024
  var instanceOptions = s._iO;
1056
- if (!s.paused) {
1057
- return s;
1058
- }
1025
+ if (!s.paused) return s;
1059
1026
  s.paused = false;
1060
1027
  s.playState = 1;
1061
1028
  if (!s.isHTML5) {
@@ -1120,7 +1087,7 @@ function SoundManager(smURL, smID) {
1120
1087
  s.muted = true;
1121
1088
  s._a.muted = true;
1122
1089
  }
1123
- s._a.volume = Math.max(0, Math.min(1, nVol/100));
1090
+ s._a.volume = Math.max(0, Math.min(1, nVol / 100));
1124
1091
  }
1125
1092
  s._iO.volume = nVol;
1126
1093
  if (!_bInstanceOnly) {
@@ -1165,9 +1132,9 @@ function SoundManager(smURL, smID) {
1165
1132
  var i;
1166
1133
  nPosition = parseInt(nPosition, 10);
1167
1134
  if (isNaN(nPosition)) {
1168
- return false;
1135
+ return;
1169
1136
  }
1170
- for (i=0; i < onPositionItems.length; i++) {
1137
+ for (i = 0; i < onPositionItems.length; i++) {
1171
1138
  if (nPosition === onPositionItems[i].position) {
1172
1139
  if (!oMethod || (oMethod === onPositionItems[i].method)) {
1173
1140
  if (onPositionItems[i].fired) {
@@ -1180,25 +1147,21 @@ function SoundManager(smURL, smID) {
1180
1147
  };
1181
1148
  this._processOnPosition = function() {
1182
1149
  var i, item, j = onPositionItems.length;
1183
- if (!j || !s.playState || onPositionFired >= j) {
1184
- return false;
1185
- }
1150
+ if (!j || !s.playState || onPositionFired >= j) return false;
1186
1151
  for (i = j - 1; i >= 0; i--) {
1187
1152
  item = onPositionItems[i];
1188
1153
  if (!item.fired && s.position >= item.position) {
1189
1154
  item.fired = true;
1190
1155
  onPositionFired++;
1191
1156
  item.method.apply(item.scope, [item.position]);
1192
- j = onPositionItems.length;
1157
+ j = onPositionItems.length;
1193
1158
  }
1194
1159
  }
1195
1160
  return true;
1196
1161
  };
1197
1162
  this._resetOnPosition = function(nPosition) {
1198
1163
  var i, item, j = onPositionItems.length;
1199
- if (!j) {
1200
- return false;
1201
- }
1164
+ if (!j) return false;
1202
1165
  for (i = j - 1; i >= 0; i--) {
1203
1166
  item = onPositionItems[i];
1204
1167
  if (item.fired && nPosition <= item.position) {
@@ -1320,8 +1283,8 @@ function SoundManager(smURL, smID) {
1320
1283
  s._whileplaying(time, x, x, x, x);
1321
1284
  }
1322
1285
  }
1323
- return isNew;
1324
1286
  }
1287
+ return isNew;
1325
1288
  };
1326
1289
  this._get_html5_duration = function() {
1327
1290
  var instanceOptions = s._iO,
@@ -1332,8 +1295,8 @@ function SoundManager(smURL, smID) {
1332
1295
  this._apply_loop = function(a, nLoops) {
1333
1296
  a.loop = (nLoops > 1 ? 'loop' : '');
1334
1297
  };
1335
- this._setup_html5 = function(oOptions) {
1336
- var instanceOptions = mixin(s._iO, oOptions),
1298
+ this._setup_html5 = function(options) {
1299
+ var instanceOptions = mixin(s._iO, options),
1337
1300
  a = useGlobalHTML5Audio ? globalHTML5Audio : s._a,
1338
1301
  dURL = decodeURI(instanceOptions.url),
1339
1302
  sameURL;
@@ -1392,9 +1355,7 @@ function SoundManager(smURL, smID) {
1392
1355
  return a;
1393
1356
  };
1394
1357
  add_html5_events = function() {
1395
- if (s._a._added_events) {
1396
- return false;
1397
- }
1358
+ if (s._a._added_events) return false;
1398
1359
  var f;
1399
1360
  function add(oEvt, oFn, bCapture) {
1400
1361
  return s._a ? s._a.addEventListener(oEvt, oFn, bCapture || false) : null;
@@ -1425,6 +1386,9 @@ function SoundManager(smURL, smID) {
1425
1386
  s.loaded = loadOK;
1426
1387
  s.readyState = (loadOK ? 3 : 2);
1427
1388
  s._onbufferchange(0);
1389
+ if (!loadOK && !s.isHTML5) {
1390
+ s._onerror();
1391
+ }
1428
1392
  if (s._iO.onload) {
1429
1393
  wrapCallback(s, function() {
1430
1394
  s._iO.onload.apply(s, [loadOK]);
@@ -1432,13 +1396,16 @@ function SoundManager(smURL, smID) {
1432
1396
  }
1433
1397
  return true;
1434
1398
  };
1435
- this._onbufferchange = function(nIsBuffering) {
1436
- if (s.playState === 0) {
1437
- return false;
1438
- }
1439
- if ((nIsBuffering && s.isBuffering) || (!nIsBuffering && !s.isBuffering)) {
1440
- return false;
1399
+ this._onerror = function(errorCode, description) {
1400
+ if (s._iO.onerror) {
1401
+ wrapCallback(s, function() {
1402
+ s._iO.onerror.apply(s, [errorCode, description]);
1403
+ });
1441
1404
  }
1405
+ };
1406
+ this._onbufferchange = function(nIsBuffering) {
1407
+ if (s.playState === 0) return false;
1408
+ if ((nIsBuffering && s.isBuffering) || (!nIsBuffering && !s.isBuffering)) return false;
1442
1409
  s.isBuffering = (nIsBuffering === 1);
1443
1410
  if (s._iO.onbufferchange) {
1444
1411
  s._iO.onbufferchange.apply(s, [nIsBuffering]);
@@ -1507,8 +1474,8 @@ function SoundManager(smURL, smID) {
1507
1474
  }
1508
1475
  if (!s.isHTML5) {
1509
1476
  s.buffered = [{
1510
- 'start': 0,
1511
- 'end': s.duration
1477
+ start: 0,
1478
+ end: s.duration
1512
1479
  }];
1513
1480
  }
1514
1481
  if ((s.readyState !== 3 || s.isHTML5) && instanceOptions.whileloading) {
@@ -1518,9 +1485,7 @@ function SoundManager(smURL, smID) {
1518
1485
  this._whileplaying = function(nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) {
1519
1486
  var instanceOptions = s._iO,
1520
1487
  eqLeft;
1521
- if (isNaN(nPosition) || nPosition === null) {
1522
- return false;
1523
- }
1488
+ if (isNaN(nPosition) || nPosition === null) return false;
1524
1489
  s.position = Math.max(0, nPosition);
1525
1490
  s._processOnPosition();
1526
1491
  if (!s.isHTML5 && fV > 8) {
@@ -1636,11 +1601,11 @@ function SoundManager(smURL, smID) {
1636
1601
  }
1637
1602
  };
1638
1603
  extraOptions = {
1639
- 'onready': 1,
1640
- 'ontimeout': 1,
1641
- 'defaultOptions': 1,
1642
- 'flash9Options': 1,
1643
- 'movieStarOptions': 1
1604
+ onready: 1,
1605
+ ontimeout: 1,
1606
+ defaultOptions: 1,
1607
+ flash9Options: 1,
1608
+ movieStarOptions: 1
1644
1609
  };
1645
1610
  assign = function(o, oParent) {
1646
1611
  var i,
@@ -1658,19 +1623,15 @@ function SoundManager(smURL, smID) {
1658
1623
  sm2[i] = o[i];
1659
1624
  } else if (bonusOptions[i] === _undefined) {
1660
1625
  result = false;
1626
+ } else if (sm2[i] instanceof Function) {
1627
+ sm2[i].apply(sm2, (o[i] instanceof Array ? o[i] : [o[i]]));
1661
1628
  } else {
1662
- if (sm2[i] instanceof Function) {
1663
- sm2[i].apply(sm2, (o[i] instanceof Array ? o[i] : [o[i]]));
1664
- } else {
1665
- sm2[i] = o[i];
1666
- }
1629
+ sm2[i] = o[i];
1667
1630
  }
1631
+ } else if (bonusOptions[i] === _undefined) {
1632
+ result = false;
1668
1633
  } else {
1669
- if (bonusOptions[i] === _undefined) {
1670
- result = false;
1671
- } else {
1672
- return assign(o[i], i);
1673
- }
1634
+ return assign(o[i], i);
1674
1635
  }
1675
1636
  }
1676
1637
  }
@@ -1714,8 +1675,8 @@ function SoundManager(smURL, smID) {
1714
1675
  apply(getArgs(arguments), 'remove');
1715
1676
  }
1716
1677
  return {
1717
- 'add': add,
1718
- 'remove': remove
1678
+ add: add,
1679
+ remove: remove
1719
1680
  };
1720
1681
  }());
1721
1682
  function html5_event(oFn) {
@@ -1737,11 +1698,11 @@ function SoundManager(smURL, smID) {
1737
1698
  var s = this._s,
1738
1699
  position1K;
1739
1700
  if (s._html5_canplay) {
1740
- return true;
1701
+ return;
1741
1702
  }
1742
1703
  s._html5_canplay = true;
1743
1704
  s._onbufferchange(0);
1744
- position1K = (s._iO.position !== _undefined && !isNaN(s._iO.position) ? s._iO.position/msecScale : null);
1705
+ position1K = (s._iO.position !== _undefined && !isNaN(s._iO.position) ? s._iO.position / msecScale : null);
1745
1706
  if (this.currentTime !== position1K) {
1746
1707
  try {
1747
1708
  this.currentTime = position1K;
@@ -1773,7 +1734,9 @@ function SoundManager(smURL, smID) {
1773
1734
  s._onfinish();
1774
1735
  }),
1775
1736
  error: html5_event(function() {
1737
+ var description = (html5ErrorCodes[this.error.code] || null);
1776
1738
  this._s._onload(false);
1739
+ this._s._onerror(this.error.code, description);
1777
1740
  }),
1778
1741
  loadeddata: html5_event(function() {
1779
1742
  var s = this._s;
@@ -1803,8 +1766,8 @@ function SoundManager(smURL, smID) {
1803
1766
  if (ranges && ranges.length) {
1804
1767
  for (i = 0, j = ranges.length; i < j; i++) {
1805
1768
  s.buffered.push({
1806
- 'start': ranges.start(i) * msecScale,
1807
- 'end': ranges.end(i) * msecScale
1769
+ start: ranges.start(i) * msecScale,
1770
+ end: ranges.end(i) * msecScale
1808
1771
  });
1809
1772
  }
1810
1773
  buffered = (ranges.end(0) - ranges.start(0)) * msecScale;
@@ -1841,7 +1804,7 @@ function SoundManager(smURL, smID) {
1841
1804
  } else if (iO.serverURL || (iO.type && preferFlashCheck(iO.type))) {
1842
1805
  result = false;
1843
1806
  } else {
1844
- result = ((iO.type ? html5CanPlay({type:iO.type}) : html5CanPlay({url:iO.url}) || sm2.html5Only || iO.url.match(/data\:/i)));
1807
+ result = ((iO.type ? html5CanPlay({ type: iO.type }) : html5CanPlay({ url: iO.url }) || sm2.html5Only || iO.url.match(/data:/i)));
1845
1808
  }
1846
1809
  return result;
1847
1810
  };
@@ -1860,9 +1823,7 @@ function SoundManager(smURL, smID) {
1860
1823
  return url;
1861
1824
  };
1862
1825
  html5CanPlay = function(o) {
1863
- if (!sm2.useHTML5Audio || !sm2.hasHTML5) {
1864
- return false;
1865
- }
1826
+ if (!sm2.useHTML5Audio || !sm2.hasHTML5) return false;
1866
1827
  var url = (o.url || null),
1867
1828
  mime = (o.type || null),
1868
1829
  aF = sm2.audioFormats,
@@ -1870,9 +1831,7 @@ function SoundManager(smURL, smID) {
1870
1831
  offset,
1871
1832
  fileExt,
1872
1833
  item;
1873
- if (mime && sm2.html5[mime] !== _undefined) {
1874
- return (sm2.html5[mime] && !preferFlashCheck(mime));
1875
- }
1834
+ if (mime && sm2.html5[mime] !== _undefined) return (sm2.html5[mime] && !preferFlashCheck(mime));
1876
1835
  if (!html5Ext) {
1877
1836
  html5Ext = [];
1878
1837
  for (item in aF) {
@@ -1883,7 +1842,7 @@ function SoundManager(smURL, smID) {
1883
1842
  }
1884
1843
  }
1885
1844
  }
1886
- html5Ext = new RegExp('\\.('+html5Ext.join('|')+')(\\?.*)?$','i');
1845
+ html5Ext = new RegExp('\\.(' + html5Ext.join('|') + ')(\\?.*)?$', 'i');
1887
1846
  }
1888
1847
  fileExt = (url ? url.toLowerCase().match(html5Ext) : null);
1889
1848
  if (!fileExt || !fileExt.length) {
@@ -1891,7 +1850,7 @@ function SoundManager(smURL, smID) {
1891
1850
  result = false;
1892
1851
  } else {
1893
1852
  offset = mime.indexOf(';');
1894
- fileExt = (offset !== -1 ? mime.substr(0,offset) : mime).substr(6);
1853
+ fileExt = (offset !== -1 ? mime.substr(0, offset) : mime).substr(6);
1895
1854
  }
1896
1855
  } else {
1897
1856
  fileExt = fileExt[1];
@@ -1900,7 +1859,7 @@ function SoundManager(smURL, smID) {
1900
1859
  result = (sm2.html5[fileExt] && !preferFlashCheck(fileExt));
1901
1860
  } else {
1902
1861
  mime = 'audio/' + fileExt;
1903
- result = sm2.html5.canPlayType({type:mime});
1862
+ result = sm2.html5.canPlayType({ type: mime });
1904
1863
  sm2.html5[fileExt] = result;
1905
1864
  result = (result && sm2.html5[mime] && !preferFlashCheck(mime));
1906
1865
  }
@@ -1918,9 +1877,7 @@ function SoundManager(smURL, smID) {
1918
1877
  var canPlay, j,
1919
1878
  result = false,
1920
1879
  isOK = false;
1921
- if (!a || typeof a.canPlayType !== 'function') {
1922
- return result;
1923
- }
1880
+ if (!a || typeof a.canPlayType !== 'function') return result;
1924
1881
  if (m instanceof Array) {
1925
1882
  for (i = 0, j = m.length; i < j; i++) {
1926
1883
  if (sm2.html5[m[i]] || a.canPlayType(m[i]).match(sm2.html5Test)) {
@@ -2002,19 +1959,17 @@ function SoundManager(smURL, smID) {
2002
1959
  sm2.disable(bNoDisable);
2003
1960
  }
2004
1961
  };
2005
- normalizeMovieURL = function(smURL) {
1962
+ normalizeMovieURL = function(movieURL) {
2006
1963
  var urlParams = null, url;
2007
- if (smURL) {
2008
- if (smURL.match(/\.swf(\?.*)?$/i)) {
2009
- urlParams = smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?') + 4);
2010
- if (urlParams) {
2011
- return smURL;
2012
- }
2013
- } else if (smURL.lastIndexOf('/') !== smURL.length - 1) {
2014
- smURL += '/';
1964
+ if (movieURL) {
1965
+ if (movieURL.match(/\.swf(\?.*)?$/i)) {
1966
+ urlParams = movieURL.substr(movieURL.toLowerCase().lastIndexOf('.swf?') + 4);
1967
+ if (urlParams) return movieURL;
1968
+ } else if (movieURL.lastIndexOf('/') !== movieURL.length - 1) {
1969
+ movieURL += '/';
2015
1970
  }
2016
1971
  }
2017
- url = (smURL && smURL.lastIndexOf('/') !== - 1 ? smURL.substr(0, smURL.lastIndexOf('/') + 1) : './') + sm2.movieURL;
1972
+ url = (movieURL && movieURL.lastIndexOf('/') !== -1 ? movieURL.substr(0, movieURL.lastIndexOf('/') + 1) : './') + sm2.movieURL;
2018
1973
  if (sm2.noSWFCache) {
2019
1974
  url += ('?ts=' + new Date().getTime());
2020
1975
  }
@@ -2045,7 +2000,7 @@ function SoundManager(smURL, smID) {
2045
2000
  };
2046
2001
  setPolling = function(bPolling, bHighPerformance) {
2047
2002
  if (!flash) {
2048
- return false;
2003
+ return;
2049
2004
  }
2050
2005
  flash._setPolling(bPolling, bHighPerformance);
2051
2006
  };
@@ -2070,10 +2025,10 @@ function SoundManager(smURL, smID) {
2070
2025
  p = sm2.getMoviePercent(),
2071
2026
  css = swfCSS,
2072
2027
  error = {
2073
- type:'FLASHBLOCK'
2028
+ type: 'FLASHBLOCK'
2074
2029
  };
2075
2030
  if (sm2.html5Only) {
2076
- return false;
2031
+ return;
2077
2032
  }
2078
2033
  if (!sm2.ok()) {
2079
2034
  if (needsFlash) {
@@ -2097,9 +2052,9 @@ function SoundManager(smURL, smID) {
2097
2052
  on_queue[sType] = [];
2098
2053
  }
2099
2054
  on_queue[sType].push({
2100
- 'method': oMethod,
2101
- 'scope': (oScope || null),
2102
- 'fired': false
2055
+ method: oMethod,
2056
+ scope: (oScope || null),
2057
+ fired: false
2103
2058
  });
2104
2059
  };
2105
2060
  processOnEvents = function(oOptions) {
@@ -2108,12 +2063,8 @@ function SoundManager(smURL, smID) {
2108
2063
  type: (sm2.ok() ? 'onready' : 'ontimeout')
2109
2064
  };
2110
2065
  }
2111
- if (!didInit && oOptions && !oOptions.ignoreInit) {
2112
- return false;
2113
- }
2114
- if (oOptions.type === 'ontimeout' && (sm2.ok() || (disabled && !oOptions.ignoreInit))) {
2115
- return false;
2116
- }
2066
+ if (!didInit && oOptions && !oOptions.ignoreInit) return false;
2067
+ if (oOptions.type === 'ontimeout' && (sm2.ok() || (disabled && !oOptions.ignoreInit))) return false;
2117
2068
  var status = {
2118
2069
  success: (oOptions && oOptions.ignoreInit ? sm2.ok() : !disabled)
2119
2070
  },
@@ -2158,10 +2109,14 @@ function SoundManager(smURL, smID) {
2158
2109
  }, 1);
2159
2110
  };
2160
2111
  detectFlash = function() {
2161
- if (hasFlash !== _undefined) {
2162
- return hasFlash;
2112
+ if (hasFlash !== _undefined) return hasFlash;
2113
+ var hasPlugin = false, n = navigator, obj, type, types, AX = window.ActiveXObject;
2114
+ var nP;
2115
+ try {
2116
+ nP = n.plugins;
2117
+ } catch(e) {
2118
+ nP = undefined;
2163
2119
  }
2164
- var hasPlugin = false, n = navigator, nP = n.plugins, obj, type, types, AX = window.ActiveXObject;
2165
2120
  if (nP && nP.length) {
2166
2121
  type = 'application/x-shockwave-flash';
2167
2122
  types = n.mimeTypes;
@@ -2180,7 +2135,7 @@ function SoundManager(smURL, smID) {
2180
2135
  hasFlash = hasPlugin;
2181
2136
  return hasPlugin;
2182
2137
  };
2183
- featureCheck = function() {
2138
+ featureCheck = function() {
2184
2139
  var flashNeeded,
2185
2140
  item,
2186
2141
  formats = sm2.audioFormats,
@@ -2191,13 +2146,11 @@ featureCheck = function() {
2191
2146
  if (sm2.oMC) {
2192
2147
  sm2.oMC.style.display = 'none';
2193
2148
  }
2194
- } else {
2195
- if (sm2.useHTML5Audio) {
2149
+ } else if (sm2.useHTML5Audio) {
2196
2150
  if (!sm2.html5 || !sm2.html5.canPlayType) {
2197
2151
  sm2.hasHTML5 = false;
2198
2152
  }
2199
2153
  }
2200
- }
2201
2154
  if (sm2.useHTML5Audio && sm2.hasHTML5) {
2202
2155
  canIgnoreFlash = true;
2203
2156
  for (item in formats) {
@@ -2267,7 +2220,7 @@ featureCheck = function() {
2267
2220
  if (h5IntervalTimer !== null && !h5TimerCount) {
2268
2221
  clearInterval(h5IntervalTimer);
2269
2222
  h5IntervalTimer = null;
2270
- return false;
2223
+ return;
2271
2224
  }
2272
2225
  for (i = sm2.soundIDs.length - 1; i >= 0; i--) {
2273
2226
  if (sm2.sounds[sm2.soundIDs[i]].isHTML5 && sm2.sounds[sm2.soundIDs[i]]._hasTimer) {
@@ -2288,7 +2241,7 @@ featureCheck = function() {
2288
2241
  };
2289
2242
  badSafariFix = function() {
2290
2243
  if (!isBadSafari || !detectFlash()) {
2291
- return false;
2244
+ return;
2292
2245
  }
2293
2246
  var aF = sm2.audioFormats, i, item;
2294
2247
  for (item in aF) {
@@ -2308,7 +2261,7 @@ featureCheck = function() {
2308
2261
  };
2309
2262
  this._externalInterfaceOK = function(swfVersion) {
2310
2263
  if (sm2.swfLoaded) {
2311
- return false;
2264
+ return;
2312
2265
  }
2313
2266
  var e;
2314
2267
  sm2.swfLoaded = true;
@@ -2318,10 +2271,8 @@ featureCheck = function() {
2318
2271
  }
2319
2272
  setTimeout(init, isIE ? 100 : 1);
2320
2273
  };
2321
- createMovie = function(smID, smURL) {
2322
- if (didAppend && appendSuccess) {
2323
- return false;
2324
- }
2274
+ createMovie = function(movieID, movieURL) {
2275
+ if (didAppend && appendSuccess) return false;
2325
2276
  function initMsg() {
2326
2277
  }
2327
2278
  if (sm2.html5Only) {
@@ -2333,7 +2284,7 @@ featureCheck = function() {
2333
2284
  appendSuccess = true;
2334
2285
  return false;
2335
2286
  }
2336
- var remoteURL = (smURL || sm2.url),
2287
+ var remoteURL = (movieURL || sm2.url),
2337
2288
  localURL = (sm2.altURL || remoteURL),
2338
2289
  swfTitle = 'JS/Flash audio component (SoundManager 2)',
2339
2290
  oTarget = getDocument(),
@@ -2342,30 +2293,30 @@ featureCheck = function() {
2342
2293
  html = doc.getElementsByTagName('html')[0],
2343
2294
  oEmbed, oMovie, tmp, movieHTML, oEl, s, x, sClass;
2344
2295
  isRTL = (html && html.dir && html.dir.match(/rtl/i));
2345
- smID = (smID === _undefined ? sm2.id : smID);
2296
+ movieID = (movieID === _undefined ? sm2.id : movieID);
2346
2297
  function param(name, value) {
2347
2298
  return '<param name="' + name + '" value="' + value + '" />';
2348
2299
  }
2349
2300
  setVersionInfo();
2350
2301
  sm2.url = normalizeMovieURL(overHTTP ? remoteURL : localURL);
2351
- smURL = sm2.url;
2302
+ movieURL = sm2.url;
2352
2303
  sm2.wmode = (!sm2.wmode && sm2.useHighPerformance ? 'transparent' : sm2.wmode);
2353
2304
  if (sm2.wmode !== null && (ua.match(/msie 8/i) || (!isIE && !sm2.useHighPerformance)) && navigator.platform.match(/win32|win64/i)) {
2354
2305
  messages.push(strings.spcWmode);
2355
2306
  sm2.wmode = null;
2356
2307
  }
2357
2308
  oEmbed = {
2358
- 'name': smID,
2359
- 'id': smID,
2360
- 'src': smURL,
2361
- 'quality': 'high',
2362
- 'allowScriptAccess': sm2.allowScriptAccess,
2363
- 'bgcolor': sm2.bgColor,
2364
- 'pluginspage': http + 'www.macromedia.com/go/getflashplayer',
2365
- 'title': swfTitle,
2366
- 'type': 'application/x-shockwave-flash',
2367
- 'wmode': sm2.wmode,
2368
- 'hasPriority': 'true'
2309
+ name: movieID,
2310
+ id: movieID,
2311
+ src: movieURL,
2312
+ quality: 'high',
2313
+ allowScriptAccess: sm2.allowScriptAccess,
2314
+ bgcolor: sm2.bgColor,
2315
+ pluginspage: http + 'www.macromedia.com/go/getflashplayer',
2316
+ title: swfTitle,
2317
+ type: 'application/x-shockwave-flash',
2318
+ wmode: sm2.wmode,
2319
+ hasPriority: 'true'
2369
2320
  };
2370
2321
  if (sm2.debugFlash) {
2371
2322
  oEmbed.FlashVars = 'debug=1';
@@ -2376,11 +2327,11 @@ featureCheck = function() {
2376
2327
  if (isIE) {
2377
2328
  oMovie = doc.createElement('div');
2378
2329
  movieHTML = [
2379
- '<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">',
2380
- param('movie', smURL),
2330
+ '<object id="' + movieID + '" data="' + movieURL + '" 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">',
2331
+ param('movie', movieURL),
2381
2332
  param('AllowScriptAccess', sm2.allowScriptAccess),
2382
2333
  param('quality', oEmbed.quality),
2383
- (sm2.wmode? param('wmode', sm2.wmode): ''),
2334
+ (sm2.wmode ? param('wmode', sm2.wmode) : ''),
2384
2335
  param('bgcolor', sm2.bgColor),
2385
2336
  param('hasPriority', 'true'),
2386
2337
  (sm2.debugFlash ? param('FlashVars', oEmbed.FlashVars) : ''),
@@ -2407,20 +2358,20 @@ featureCheck = function() {
2407
2358
  if (!sm2.useFlashBlock) {
2408
2359
  if (sm2.useHighPerformance) {
2409
2360
  s = {
2410
- 'position': 'fixed',
2411
- 'width': '8px',
2412
- 'height': '8px',
2413
- 'bottom': '0px',
2414
- 'left': '0px',
2415
- 'overflow': 'hidden'
2361
+ position: 'fixed',
2362
+ width: '8px',
2363
+ height: '8px',
2364
+ bottom: '0px',
2365
+ left: '0px',
2366
+ overflow: 'hidden'
2416
2367
  };
2417
2368
  } else {
2418
2369
  s = {
2419
- 'position': 'absolute',
2420
- 'width': '6px',
2421
- 'height': '6px',
2422
- 'top': '-9999px',
2423
- 'left': '-9999px'
2370
+ position: 'absolute',
2371
+ width: '6px',
2372
+ height: '6px',
2373
+ top: '-9999px',
2374
+ left: '-9999px'
2424
2375
  };
2425
2376
  if (isRTL) {
2426
2377
  s.left = Math.abs(parseInt(s.left, 10)) + 'px';
@@ -2472,9 +2423,7 @@ featureCheck = function() {
2472
2423
  createMovie();
2473
2424
  return false;
2474
2425
  }
2475
- if (flash) {
2476
- return false;
2477
- }
2426
+ if (flash) return false;
2478
2427
  if (!sm2.url) {
2479
2428
  return false;
2480
2429
  }
@@ -2514,15 +2463,15 @@ featureCheck = function() {
2514
2463
  var p,
2515
2464
  loadIncomplete = false;
2516
2465
  if (!sm2.url) {
2517
- return false;
2466
+ return;
2518
2467
  }
2519
2468
  if (waitingForEI) {
2520
- return false;
2469
+ return;
2521
2470
  }
2522
2471
  waitingForEI = true;
2523
2472
  event.remove(window, 'load', delayWaitForEI);
2524
2473
  if (hasFlash && tryInitOnFocus && !isFocused) {
2525
- return false;
2474
+ return;
2526
2475
  }
2527
2476
  if (!didInit) {
2528
2477
  p = sm2.getMoviePercent();
@@ -2535,7 +2484,7 @@ featureCheck = function() {
2535
2484
  if (loadIncomplete) {
2536
2485
  waitingForEI = false;
2537
2486
  window.setTimeout(delayWaitForEI, 1);
2538
- return false;
2487
+ return;
2539
2488
  }
2540
2489
  if (!didInit && okToDisable) {
2541
2490
  if (p === null) {
@@ -2543,28 +2492,22 @@ featureCheck = function() {
2543
2492
  if (sm2.useFlashBlock) {
2544
2493
  flashBlockHandler();
2545
2494
  }
2495
+ } else if (!sm2.useFlashBlock && canIgnoreFlash) {
2496
+ rebootIntoHTML5();
2546
2497
  } else {
2547
- if (!sm2.useFlashBlock && canIgnoreFlash) {
2548
- rebootIntoHTML5();
2549
- } else {
2550
- processOnEvents({
2551
- type: 'ontimeout',
2552
- ignoreInit: true,
2553
- error: {
2554
- type: 'INIT_FLASHBLOCK'
2555
- }
2556
- });
2557
- }
2498
+ processOnEvents({
2499
+ type: 'ontimeout',
2500
+ ignoreInit: true,
2501
+ error: {
2502
+ type: 'INIT_FLASHBLOCK'
2503
+ }
2504
+ });
2558
2505
  }
2506
+ } else if (sm2.flashLoadTimeout === 0) {
2507
+ } else if (!sm2.useFlashBlock && canIgnoreFlash) {
2508
+ rebootIntoHTML5();
2559
2509
  } else {
2560
- if (sm2.flashLoadTimeout === 0) {
2561
- } else {
2562
- if (!sm2.useFlashBlock && canIgnoreFlash) {
2563
- rebootIntoHTML5();
2564
- } else {
2565
- failSafely(true);
2566
- }
2567
- }
2510
+ failSafely(true);
2568
2511
  }
2569
2512
  }
2570
2513
  }, sm2.flashLoadTimeout);
@@ -2589,9 +2532,7 @@ featureCheck = function() {
2589
2532
  showSupport = function() {
2590
2533
  };
2591
2534
  initComplete = function(bNoDisable) {
2592
- if (didInit) {
2593
- return false;
2594
- }
2535
+ if (didInit) return false;
2595
2536
  if (sm2.html5Only) {
2596
2537
  didInit = true;
2597
2538
  initUserOnload();
@@ -2681,23 +2622,21 @@ featureCheck = function() {
2681
2622
  return true;
2682
2623
  };
2683
2624
  domContentLoaded = function() {
2684
- if (didDCLoaded) {
2685
- return false;
2686
- }
2625
+ if (didDCLoaded) return false;
2687
2626
  didDCLoaded = true;
2688
2627
  setProperties();
2689
2628
  initDebug();
2690
2629
  if (!hasFlash && sm2.hasHTML5) {
2691
2630
  sm2.setup({
2692
- 'useHTML5Audio': true,
2693
- 'preferFlash': false
2631
+ useHTML5Audio: true,
2632
+ preferFlash: false
2694
2633
  });
2695
2634
  }
2696
2635
  testHTML5();
2697
2636
  if (!hasFlash && needsFlash) {
2698
2637
  messages.push(strings.needFlash);
2699
2638
  sm2.setup({
2700
- 'flashLoadTimeout': 1
2639
+ flashLoadTimeout: 1
2701
2640
  });
2702
2641
  }
2703
2642
  if (doc.removeEventListener) {
@@ -2754,7 +2693,7 @@ if (typeof module === 'object' && module && typeof module.exports === 'object')
2754
2693
  return {
2755
2694
  constructor: SoundManager,
2756
2695
  getInstance: getInstance
2757
- }
2696
+ };
2758
2697
  });
2759
2698
  }
2760
2699
  // standard browser case