bookreader 1.0.1

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