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