diff --git a/Gemfile b/Gemfile index 51ddc1db..8fd03a16 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ gem 'rails', '3.2.17' # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'devise' -gem 'redis' +gem 'redis', '2.2.2' gem 'pg' gem 'cancan' gem 'formula' diff --git a/Gemfile.lock b/Gemfile.lock index e4bbb146..b4efab8d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -117,7 +117,7 @@ GEM rake (10.3.2) rdoc (3.12.2) json (~> 1.4) - redis (3.0.7) + redis (2.2.2) sass (3.3.7) sass-rails (3.2.6) railties (~> 3.2.0) @@ -160,6 +160,6 @@ DEPENDENCIES pg rails (= 3.2.17) rails3-jquery-autocomplete - redis + redis (= 2.2.2) sass-rails uglifier (>= 1.0.3) diff --git a/Gemfile~ b/Gemfile~ deleted file mode 100644 index 9e2acc35..00000000 --- a/Gemfile~ +++ /dev/null @@ -1,47 +0,0 @@ -source 'https://rubygems.org' - -gem 'rails', '3.2.17' - -# Bundle edge Rails instead: -# gem 'rails', :git => 'git://github.com/rails/rails.git' - -gem 'devise' -gem 'redis' -gem 'pg' -gem 'cancan' -gem 'formula' -gem 'formtastic' -gem 'json' -gem 'rails3-jquery-autocomplete' -gem 'best_in_place' -gem 'therubyracer' #optional -#gem 'rb-readline' - -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails' - gem 'coffee-rails', '~> 3.2.1' - - # See https://github.com/sstephenson/execjs#readme for more supported runtimes - # gem 'therubyracer' - - gem 'uglifier', '>= 1.0.3' -end - -gem 'jquery-rails', '2.1.2' - -# To use ActiveModel has_secure_password -# gem 'bcrypt-ruby', '~> 3.0.0' - -# To use Jbuilder templates for JSON - gem 'jbuilder', '0.8.2' - -# Use unicorn as the web server -# gem 'unicorn' - -# Deploy with Capistrano -# gem 'capistrano' - -# To use debugger -# gem 'ruby-debug19', :require => 'ruby-debug' diff --git a/app/assets/images/synapsevisualize.png b/app/assets/images/synapsevisualize.png new file mode 100644 index 00000000..a3f85f59 Binary files /dev/null and b/app/assets/images/synapsevisualize.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/README.rdoc b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/README.rdoc new file mode 100755 index 00000000..60f1529d --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/README.rdoc @@ -0,0 +1,71 @@ +== SoundManager 2: JavaScript Sound for the Web + +By wrapping and extending HTML5 and Flash Audio APIs, SoundManager 2 brings reliable cross-platform audio to JavaScript. + +== HTML5 Audio() Support + + * 100% Flash-free MP3 + MP4/AAC where supported + * Compatible with Apple iPad 3.2, iPhone/iOS 4 and newer + * Fallback to Flash for MP3/MP4 support, as needed + * SM2 API is transparent; HTML5/flash switching handled internally + * HTML5 API support approximates Flash 8 API features + * Some other formats (WAV/OGG) supported via HTML5, depending on browser + * See "useHTML5Audio" property for implementation details + +== Basic API Features (Flash 8) + + * Load, stop, play, pause, mute, seek, pan and volume control of sounds from Javascript + * Events: onload, whileloading, whileplaying, onfinish and more + * ID3V1 and ID3V2 tag support for MP3s (title, artist, genre etc.) + +== Shiny Flash 9 Features + + * RTMP / Flash Media Server streaming support (new, experimental) + * MPEG-4 (AAC, HE-AAC, H.264) audio support + * "MultiShot" play (layered/chorusing effects) + * Waveform/frequency spectrum data + * Peak (L/R channel volume) data + * Audio buffering state/event handling + +== General Tech Stuff + + * Full API Documentation with examples and notes + * console.log()-style debug output and troubleshooting tools + * Community-based discussion/support + +== As Heard On The Internets + +A few nifty sites that have implemented SM2 for driving audio: + + * SoundCloud / The Cloud Player + * last.fm + * Opera (media player component) + * 8tracks + * Discogs + * The Hype Machine + * nyan.cat + * turntable.fm + * AudioGalaxy + +== Project home, documentation, live demos etc.: + +http://www.schillmania.com/projects/soundmanager2/ + +== Compiling JS builds (-nodebug, -jsmin) and Flash components, AS2/AS3 to SWF + +An Ant build file defines the tasks for compiling JS and SWF components, useful if you make changes to the SM2 source and want to recompile. +Google's Closure Compiler is used for the JS. AS2 compilation is done by MTASC, and AS3 is handled by Adobe's Open Source Flex SDK (mxmlc) compiler. +Refer to the build.xml file for compiler downloads and path definitions. + +== Versioning / Development Notes + +Releases are versioned by date, e.g., V2.97a.20110424 and are tagged as such.* +The latest official release is always on trunk/master. +Post-release development builds may be available on the appropriate +DEV branch, eg., V2.97a.20110801+DEV + +== Forks and Pull Requests + +Firstly, thank you for wanting to contribute! Bug fixes and tweaks are welcomed, particularly if they follow the general coding style of the project. +If making a pull request, use the project's current +DEV development branch as the merge target instead of "master", if possible (please and thank-you.) + +* SoundManager 2 has been at "version" 2.97 for a long time, because 2.97 was arguably the best llama-ass-whipping version of WinAmp. (WinAmp 3 was not as good, and WinAmp 5 was "the best of 2 and 3 combined.") This MP3 player was my favourite Windows app during the 90's, and is missed as there's nothing quite like it on OS X where I spend most of my time these days. diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360 button - large.psd b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360 button - large.psd new file mode 100755 index 00000000..930b41e0 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360 button - large.psd differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360 button.psd b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360 button.psd new file mode 100755 index 00000000..afd04980 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360 button.psd differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-pause-light.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-pause-light.gif new file mode 100755 index 00000000..a7efb1da Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-pause-light.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-pause-light.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-pause-light.png new file mode 100755 index 00000000..21860abb Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-pause-light.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-pause.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-pause.gif new file mode 100755 index 00000000..5317ded4 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-pause.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-pause.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-pause.png new file mode 100755 index 00000000..b22bf93f Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-pause.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-play-light.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-play-light.gif new file mode 100755 index 00000000..22be94f8 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-play-light.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-play-light.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-play-light.png new file mode 100755 index 00000000..fc30c5f4 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-play-light.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-play.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-play.gif new file mode 100755 index 00000000..d150c0d6 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-play.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-play.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-play.png new file mode 100755 index 00000000..8fd7c4c6 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-play.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-pause-light.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-pause-light.gif new file mode 100755 index 00000000..68bf149f Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-pause-light.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-pause-light.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-pause-light.png new file mode 100755 index 00000000..a4a0a5ed Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-pause-light.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-pause.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-pause.gif new file mode 100755 index 00000000..4bd23332 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-pause.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-pause.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-pause.png new file mode 100755 index 00000000..3627f67a Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-pause.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-play-light.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-play-light.gif new file mode 100755 index 00000000..7ce69321 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-play-light.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-play-light.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-play-light.png new file mode 100755 index 00000000..599b0c67 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-play-light.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-play.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-play.gif new file mode 100755 index 00000000..4837776a Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-play.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-play.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-play.png new file mode 100755 index 00000000..a36478d8 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360-button-vis-play.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360player-visualization.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360player-visualization.css new file mode 100755 index 00000000..6bef9969 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360player-visualization.css @@ -0,0 +1,156 @@ +/* larger canvas, spectrum + EQ visualization and other items */ + +.ui360-vis, +.ui360-vis .sm2-360ui, +.sm2-inline-list .ui360-vis { + /* size of the container for the circle, etc. */ + width:256px; + height:256px; +} + +.ui360-vis { + position:relative; + /* a little extra spacing */ + padding-top:1px; + padding-bottom:1px; + margin-bottom:-18px; /* approximate "line height" we want */ + padding-left:248px; + margin-left:0px; + background-position:22.6% 50%; /* (~109px) initial play button position */ +} + +.sm2-inline-list .ui360-vis { + cursor:pointer +} + +.ui360-vis a { + font:14px "helvetica neue",helvetica,monaco,lucida,terminal,monospace; + white-space:nowrap; + text-indent:0px; /* undo inline style */ + top:46%; /* ehh. */ +} + +.sm2-inline-list .ui360-vis a { + line-height:256px; + top:auto; +} + +.ui360-vis .sm2-360ui { + margin-left:-256px; +} + +.ui360-vis .sm2-timing { + font:bold 24px "helvetica neue",helvetica,monaco,lucida,terminal,monospace; + color:#333; + text-align:center; + line-height:256px; + text-indent:0px; +} + +.sm2-inline-list .ui360-vis, +.sm2-inline-list .ui360-vis .sm2-360ui { + margin-left:0px; +} + +.sm2-inline-list .ui360-vis { + margin:8px 13px 7px 0px; + padding-left:0px; + background-position:50% 50%; /* initial play button position */ +} + +.sm2-inline-list .ui360-vis .sm2-360ui { + border:1px solid #eee; + /* offset the border */ + margin-left:-1px; + margin-top:-1px; +} + +.sm2-inline-list .ui360-vis a { + position:absolute; + display:inline; + left:0px; + bottom:0px; + top:1px; + width:100%; /* 2px padding in box */ + height:99%; /* dumb vertical hack */ + *height:256px; /* IE is dumb. */ + overflow:hidden; + font-size:small; + font-weight:300; + color:#333; + margin:0px; + padding:0px; + line-height:488px; /* bottom vertical alignment for text */ + *line-height:480px; /* IE again */ + text-align:center; + border-radius:0px; +} + +.sm2-inline-list .ui360 a:hover { + background-color:transparent; /* reset */ +} + +.sm2-inline-list .ui360-vis:hover .sm2-360ui, +.sm2-inline-list .ui360-vis a.sm2_link:hover, +.sm2-inline-list .ui360-vis a.sm2_link:active, +.sm2-inline-list .ui360-vis a.sm2_link:focus { + background-color:transparent; +} + +.sm2-inline-list .ui360-vis:hover a.sm2_link { + background-color:#fafafa; + *background-color:transparent; /* eh, screw IE. */ +} + +/* Use a bigger loading image for this layout */ + +.ui360-vis .sm2-360btn, +.ui360-vis .sm2-360ui.sm2_paused .sm2-360btn, +.ui360-vis .sm2-360ui.sm2_playing .sm2-360btn { + width:48px; + height:48px; + margin-left:-24px; + margin-top:-24px; + border-radius: none; +} + +.ui360-vis, +.ui360-vis .sm2-360ui.sm2_paused .sm2-360btn, +.ui360-vis .sm2-360btn-default { + background:transparent url(360-button-vis-play.png) no-repeat 50% 50%; + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAABuVBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADv7++lpaXr6+uAgIDk5OQzMzPt7e1tbW3n5+dgYGDW1tZNTU10dHQ5OTnw8PCvr6/e3t6JiYlAQEDb29vo6OgrKyuqqqrq6uq4uLjf399AQEDGxsbq6uqAgIDY2Nje3t61tbXp6enU1NTu7u7r6+vl5eXt7e2fn5/n5+fDw8Ph4eHv7+/t7e3CwsLW1tbu7u7b29vw8PDm5uYgICDp6enY2Nji4uLo6Ojm5uakpKTS0tLPz8/h4eHw8PDs7Ozj4+Pa2trg4ODx8fHT09Pk5OTPz8/S0tLBwcGmpqawsLCOjo7h4eHn5+fo6OgAAADY2NjNzc3n5+cAAADd3d3Gxsbu7u7t7e0AAADX19fl5eXi4uLf39/Hx8fn5+fs7Ozg4ODR0dHX19e4uLjv7+/z8/P09PTy8vL19fXv7+/n5+fx8fH29vbs7Ozq6urm5ubo6Ojw8PDu7u7p6enr6+sAAAB/f3/Z2dn39/fh4eGOjo4ODg7t7e3l5eWWlpba2tqjo6NVVVXk5OTe3t65ubnMzMzExMTf39/GxsampqZiYmJNcTiZAAAAbXRSTlMAAQIEAwcFCAb5EdAImAXpB6oIUAoLCfsgZQ0EVrsGEr4ZYQgbsgpUYxikNd/aatQQli+R7rlUUdas6+8I+VaFruoOOV/S8Nq5sWL8UqmKUFsuHyTcrtsJm0z7C49V3NMKkdKXuk7S7oVeVSv7tAAEVwAAAu5JREFUeF6llmVz3DwURmNLsr1pmJmZmZmxzMwsybS8gXJfhl9cKXbHEK+TmZ4P/nDnOXN1NbalHD8CQ7QRGDmhnIQhBDYQnkhheRECSVIQQrLMHookAciUkHhBw1zVwuLShcJIpPDC0uJC1VxDQTaFx1srSvM3DUxU1TRVlWBjM7+0opUrQaupLSnrLK7ELIepwaCYmbiyuLOspJY38eeLykdGxzDhYQfKCmOjI+VFPkMQYF7NZD0l2DgFJrR+siYPegxBzBvqeoQxpgGw8qOuoTz3HGw9udUPCaFZIORhdS5blZOHjXWDBIdABusanb0S4MpqEw4XcNPqCrQFQQTN+XwPQ8CY5jcDUbB3KLdlg6hnQDZacqEgWA3a2rF6Jri9zWohwI6dXXK2QHZ3OqBw0qC7B6vnAPd0sxZMkHr7VNPD34YZgNrXK3EBSgPU9HJ4eIQDDDogQS4ow4QJxy4+MmKs4oYJZFhhggjQuMoKHoHzn3bsQx1HQOTClOkXLP6lviZTtjCjmn7B5g/izqszliBHTB+HDhl3PSJbwnxSS3n45HDkVLXkvCWg5Uws7eHgJ98/uKqxzLI9w3o6oXuwhd+OPNVEet0WtnU9/sWNJfz1u6cY1/VtLghQuRgk/PmBmT7hogJPXo3L8YQed3Nw8PWfuB89Eb8scUGUrl33DfH/N93BGeH6NUnkArh1O5FOuNETp2GR27cAE/iaJu6mz8HdCQnan+i96XQmdgaZ9PQ9+xMVoPJgNhrNhBKNzj5Q+E/AavH4SSz6OZRo7Mlj3oDDp7jyPJoKJfr8CpvAOUrQi6eppJaVZOrpCwTdP1cgr93UjKxoN9dka2KX8ealZtBADO3lG2+e7xRAd7Y0igOg2tYdBKD/CBIBenf/lYGJD2y8uv8OgaBDDkry3v57SlQXhL7f35OlwJOXGUBBl571JykmzCIE02T/s0tIASyf/R6Arr59fcM62G+8fnsVhdwFwq4Ov345Of/15wd0RYY81HHUTQAAAABJRU5ErkJggg==); + *background-image:url(360-button-vis-play.png); + _background:transparent url(360-button-vis-play.gif) no-repeat 50% 50%; + cursor:pointer; +} + +.ui360-vis:hover .sm2-360btn, +.ui360-vis .sm2-360btn-default:hover, +.ui360-vis .sm2-360ui.sm2_paused .sm2-360btn:hover { + background:transparent url(360-button-vis-play-light.png) no-repeat 50% 50%; + _background:transparent url(360-button-vis-play.gif) no-repeat 50% 50%; + cursor:pointer; +} + + +.ui360-vis .sm2-360ui.sm2_playing .sm2-360btn:hover, +.ui360-vis .sm2-360btn-playing:hover { + background:transparent url(360-button-vis-pause-light.png) no-repeat 50% 50%; + _background:transparent url(360-button-vis-pause-light.gif) no-repeat 50% 50%; + cursor:pointer; +} + +.ui360-vis { + /* non-JS / before-loaded state */ + background-position: 21% 50%; + _background:transparent url(360-button-vis-play.gif) no-repeat 21% 50%; /* IE 6-only: special crap GIF */ +} + +.ui360-vis .sm2-360btn-default { + /* real button, post-loaded state */ + _background:transparent url(360-button-vis-play.gif) no-repeat 50% 50%; /* IE 6-only: special crap GIF */ +} + +.ui360-vis .sm2-360ui.sm2_dragging .sm2-360btn { + visibility: hidden; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360player.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360player.css new file mode 100755 index 00000000..b74df11c --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/360player.css @@ -0,0 +1,271 @@ +/* General warning: Beta-ish. Code could be a bit cleaner. */ + +.ui360, /* entire UI */ +.sm2-360ui { /* canvas container */ + position:relative; +} + +.ui360, +.sm2-360ui { + min-width:50px; /* should always be at least this. */ + min-height:50px; +} + +.sm2-360ui { + width:50px; + height:50px; +} + +.ui360, +.ui360 * { + vertical-align:middle; +} + +.sm2-360ui { + position:relative; + display:inline-block; /* firefox 3 et al */ + float:left; /* IE 6+7, firefox 2 needs this, inline-block would work with fx3 and others */ + *display:inline; +/* + clear:left; +*/ +} + +.sm2-360ui.sm2_playing, +.sm2-360ui.sm2_paused { + /* bump on top when active */ + z-index:10; +} + +.ui360 a { /* .sm2_link class added to playable links by SM2 */ + float:left; + display:inline; + position:relative; + color:#000; + text-decoration:none; + left:3px; /* slight spacing on left UI */ + top:18px; /* vertical align */ + text-indent:50px; /* make room for UI at left */ +} + +.ui360 a.sm2_link { /* SM2 has now started */ + text-indent:0px; /* UI now in place. */ +} + +.ui360 a, +.ui360 a:hover, +.ui360 a:focus { + padding:2px; + margin-left:-2px; + margin-top:-2px; +} + +.ui360 a:hover, +.ui360 a:focus { + background:#eee; + border-radius:3px; + outline:none; +} + +.ui360 .sm2-canvas { + position:absolute; + left:0px; + top:0px; +} + +.ui360 .sm2-timing { + position:absolute; + display:block; + left:0px; + top:0px; + width:100%; + height:100%; + margin:0px; + font:11px "helvetica neue",helvetica,monaco,lucida,terminal,monospace; + color:#666; + text-align:center; + line-height:50px; +} + +.ui360 .sm2-timing.alignTweak { + text-indent:1px; /* devious center-alignment tweak for Safari (might break things for others.) */ +} + +.ui360 .sm2-cover { + position:absolute; + left:0px; + top:0px; + width:100%; + height:100%; + z-index:2; + display:none; + background-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==); /* old-skool bug: IE 9 won't catch mouse events otherwise. /smash */ +} + +.ui360 .sm2-360btn { + position:absolute; + display:block; + top:50%; + left:50%; +/* + width:22px; + height:22px; + margin-left:-11px; + margin-top:-11px; +*/ + /* by default, cover whole space. make smaller when playing. */ + width:50px; + height:50px; + margin-left:-25px; + margin-top:-25px; + border-radius: 25px; + cursor:pointer; + z-index:3; +} + +.ui360 .sm2-360data { + display:inline-block; + font-family:helvetica; +} + +.sm2-inline-block .ui360 .sm2-360btn, +.ui360 .sm2-360ui.sm2_playing .sm2-360btn, +.ui360 .sm2-360ui.sm2_paused .sm2-360btn { + /* smaller clickable button, in center */ + width:22px; + height:22px; + margin-left:-11px; + margin-top:-11px; +} + +.ui360 .sm2-360ui.sm2_playing .sm2-cover, +.ui360 .sm2-360ui.sm2_paused .sm2-cover { + display:block; +} + +/* this could be optimized a fair bit. */ + +.ui360, +.ui360 .sm2-360btn-default, +.ui360 .sm2-360ui.sm2_paused .sm2-360btn { + background:transparent url(360-button-play.png) no-reoeat; + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAABoUlEQVR42sWVu2oCQRhGU/s8gpVYJeQJNkZSbiH4QNuLlQZS21sJayGYaOEFVFDxNiremj9zig2uzk5YQpKFg8PMd75ZZle9E5Ff4e+Ll8tlQuNoPI2vUcCYOdbIxCmm9F5T0YgNMmS/LebSwWdNa7VayXq9ls1mI9vtVna7nQBj5lgjQxYHN7KY3QkiUbDf7+V4PMrpdArBHGtkyOJc3/n1mVaUUl+F5/PZSrABDi4dpmKH3QkixQEHlw5TsccZmsRCoSD1et1ajkuHqdg/HA5GKZPJCOTzeanVasYMLh2mYsXDIGAoDuG6rlSr1WCdBxrcsTIWazgrQiHS6bSRYJ3XDzeq2O/3+9Ltdm9IpVIhstmslEqlUAY36ii8ZrMpjUbjhmQyKeA4jhSLRWMGN+rhOZ1Oh8ANuVxOyuUy40hwo163RK/XeyPQbrdjgYNr/ILAYDB41Gf1wZnFAQfX+iM0HA5fxuPx+2g0Ej22QoYsDq61mGsymTxMp9NX/Sk2yJDFsRZfXpzXbDZ7WiwW3nw+9zUKGDPHGpkL5V//mn7OJyJZApyzeUS5AAAAAElFTkSuQmCC); + *background-image: url(360-button-play.png); + background-repeat: no-repeat; +} + +.ui360 { + /* + "fake" button shown before SM2 has started, non-JS/non-SM2 case etc. + background image will be removed via JS, in threeSixyPlayer.init() + */ + background-position: 14px 50%; + _background:transparent url(360-button-play.gif) no-repeat 14px 50%; /* IE 6-only: special crap GIF */ +} + +.ui360 .sm2-360btn-default, +.ui360 .sm2-360ui.sm2_paused .sm2-360btn { + background-position:50% 50%; + _background:transparent url(360-button-play.gif) no-repeat 50% 50%; /* IE 6-only: special crap GIF */ +} + +.ui360 .sm2-360btn-default, +.ui360 .sm2-360ui.sm2_paused .sm2-360btn { + cursor:pointer; +} + +.ui360 .sm2-360btn-default:hover, +.ui360 .sm2-360ui.sm2_paused .sm2-360btn:hover { + background:transparent url(360-button-play-light.png) no-repeat 50% 50%; + _background:transparent url(360-button-play.gif) no-repeat 50% 50%; + cursor:pointer; +} + +.ui360 .sm2-360ui.sm2_playing .sm2-360btn:hover, +.ui360 .sm2-360btn-playing:hover { + background:transparent url(360-button-pause-light.png) no-repeat 50% 50%; + _background:transparent url(360-button-pause-light.gif) no-repeat 50% 50%; + cursor:pointer; +} + +.ui360 .sm2-360ui.sm2_playing .sm2-timing { + visibility:visible; +} + +.ui360 .sm2-360ui.sm2_buffering .sm2-timing { + visibility:hidden; +} + +.ui360 .sm2-360ui .sm2-timing, +.ui360 .sm2-360ui .sm2-360btn:hover + .sm2-timing, +.ui360 .sm2-360ui.sm2_paused .sm2-timing { + visibility:hidden; +} + +.ui360 .sm2-360ui.sm2_dragging .sm2-timing, +.ui360 .sm2-360ui.sm2_dragging .sm2-360btn:hover + .sm2-timing { + /* paused + dragging */ + visibility:visible; +} + +.ui360 .sm2-360ui.sm2_playing .sm2-360btn, +.ui360 .sm2-360ui.sm2_dragging .sm2-360btn, +.ui360 .sm2-360ui.sm2_dragging .sm2-360btn:hover, +.ui360 .sm2-360ui.sm2_dragging .sm2-360btn-playing:hover { + /* don't let pause button show on hover when dragging (or paused and dragging) */ + background:transparent; + cursor:auto; +} + +.ui360 .sm2-360ui.sm2_buffering .sm2-360btn, +.ui360 .sm2-360ui.sm2_buffering .sm2-360btn:hover { + background:transparent url(icon_loading_spinner.gif) no-repeat 50% 50%; + opacity:0.5; + visibility:visible; +} + +/* inline list style */ + +.sm2-inline-list .ui360, +.sm2-inline-block .ui360 { + position:relative; + display:inline-block; + float:left; + _display:inline; + margin-bottom:-15px; +} + +.sm2-inline-list .ui360 { + /* inline player: minor tweak, tighten spacing */ + margin-right:-2px; +} + +.sm2-inline-block .ui360 { + margin-right:8px; +} + +.sm2-inline-list .ui360 a { + display:none; +} + +/* annotations */ + +ul.ui360playlist { + list-style-type:none; +} + +ul.ui360playlist, +ul.ui360playlist li { + margin:0px; + padding:0px; +} + +div.ui360 div.metadata { + display:none; +} + +div.ui360 a span.metadata, +div.ui360 a span.metadata * { + /* name of track, note etc. */ + vertical-align:baseline; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/canvas-visualization-basic.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/canvas-visualization-basic.html new file mode 100755 index 00000000..352856b4 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/canvas-visualization-basic.html @@ -0,0 +1,132 @@ + + + +360° MP3 player UI demo (SoundManager 2): Javascript + Canvas Visualization, basic example + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

360° Player Demo - Visualization Example, Basic Template

+ +

Canvas-based UI with visualization options. Note: No EQ/spectrum support for IE < 9 (too slow.) Data not implemented in HTML5.

+ +
+ +
+ +
+ + + +

Inline list

+ +
+ + + + + + +
+ +

Block list

+ +
+ + +
+ +
+ +

+ SoundManager 2 project page (not an MP3 link) +

+ + + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/canvas-visualization.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/canvas-visualization.html new file mode 100755 index 00000000..1f3d6e2c --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/canvas-visualization.html @@ -0,0 +1,359 @@ + + + +360° MP3 player UI demo (SoundManager 2): Javascript + Canvas Visualization + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

SoundManager 2 / 360° Player Demo: JS + Canvas Visualization

+ +

Canvas-based UI with visualization options. Note: Spectrum/EQ visualizations disabled for IE < 9 (too slow.) Data is not implemented under HTML5.

+

You can also show FPS or customize the UI, or see the hi-fi version. Check the basic template for a minimal code example; also see the default 360° UI.

+ + + + + + + +
+ +
+ +

Inline list

+ +
+ + + + + + + +
+ +

Artist thank-yous: "Graffiti Sex" courtesy of The Fugitives. "Blue Belle Lament" courtesy of Adrian Glynn. "I Tried" and "People Asking" courtesy of SonReal.

+ +

Block list

+ +
+ + + + +
+ +

56K Modem sound (Creative Commons license) via dialup.mp3, from freesound.org user Jlew.

+ + +

Variant: Annotations/meta-data

+ + + + +
+ +

+ SoundManager 2 project page (not an MP3 link) +

+ + + +
+ + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/demo-slider-controls.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/demo-slider-controls.css new file mode 100755 index 00000000..27281c0b --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/demo-slider-controls.css @@ -0,0 +1,179 @@ +#cp-container { position:relative;float:left;display:inline; margin-left:1em;padding: 6px; background-color: #f6f6f6; border:1px solid #eee; width: 320px; height:180px;z-index:2; } + +.yui-picker-controls li, +.yui-picker-controls input { + font-size:1em; + font-family:"helvetica neue",helvetica,arial,verdana; +} + +#controls { + position:relative; + margin-top:1.5em; + font-size:0.85em; +} + +#options { + float:left; + display:inline; + margin-bottom:0.5em; + margin-top:-1.2em; +} + +#controls .checkbox { + float:left; + display:inline; + width:21.2em; + margin-right:2.5em; +} + +#controls .checkbox div { + /* tab */ + width:auto; + padding:0.4em; + border:1px solid #ddd; + border-bottom:none; + background:#eee; +} + +#controls .checkbox div, +#controls .checkbox input { + font-family:arial,tahoma,verdana,"sans serif"; + font-size:1em; + vertical-align:middle; +} + +#controls dl { + width:21em; +} + +#controls dl.col { + position:relative; + float:left; + display:inline; + margin:0px; + margin-right:1em; + padding:0.75em; +/* + height:12.4em; +*/ + height:auto; + border:1px solid #ddd; + background:#f6f6f6; +} + +#controls .disabled { + color:#ccc; +} + +#controls .disabled dt, +#controls .disabled dd { + color:#999; + opacity:0.5; +} + +#controls dl dd p { + margin:0px; + padding:0px; +} + +#controls dt, +#controls dd { + margin:0px; + padding:0px; +} + +#controls dt { + border-bottom:none; +} + +#controls dt { + float:left; + display:inline; + background:transparent; + padding-right:0.7em; + margin-right:0.7em; + border-right:1px solid #ccc; + font-size:1.1em; + color:#333; + font-family:"helvetica neue",helvetica,verdana,arial,"sans serif"; +} + +#controls dd { + margin:0px; + padding:0px; + font-size:0.9em; + vertical-align:middle; + color:#666; +} + +#controls .title { + float:left; + display:inline; + margin-right:0.6em; + color:#333; +} + +/* those slider bits you might be wondering about */ + +#controls .control { + position:relative; + border-left:0px; + width:214px; + height:20px; +} + +#controls .control .bar { + position:absolute; + left:0px; + top:0px; + width:214px; + height:20px; + background:transparent url(../_image/slider-bar.gif) no-repeat 0px 9px; + cursor:pointer; + cursor:hand; +} + +#controls .control .slider { + position:absolute; + left:0px; + top:0px; + width:20px; + height:20px; + background:transparent url(../_image/slider.png) no-repeat 0px 0px; + *background:none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='../_image/slider.png'); + cursor:pointer; + cursor:hand; +} + +#controls .control .slider:hover { + background:transparent url(../_image/slider-1.png) no-repeat 0px 0px; + *background:none; +} + +#controls .control .slider.hover { + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='../_image/slider-1.png'); +} + +#controls .disabled .control .slider { + background:transparent url(../_image/slider-disabled.png) no-repeat 0px 0px; + *background:none; + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='../_image/slider-disabled.png'); +} + +#controls .disabled .control .slider:hover { + background:transparent url(../_image/slider-disabled-1.png) no-repeat 0px 0px; + *background:none; +} + +#controls .disabled .control .slider.hover { + filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod=crop,src='../_image/slider-disabled-1.png'); +} + +#controls input[type=text] { + width:5em; +} + +#options div { + margin-bottom:0.25em; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/demo-slider-controls.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/demo-slider-controls.js new file mode 100755 index 00000000..379cd33d --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/demo-slider-controls.js @@ -0,0 +1,750 @@ +/* + Ancient fireworks slider control code (2005) + Kinda/sorta refactored for SM2 360 demo + http://schillmania.com/projects/fireworks/ + -------------------------------------------- + Not required for your use! +*/ + +function Animator2() { + var self = this; + this.tweens = []; + this.tweens['default'] = [1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]; + this.tweens['blast'] = [12,12,11,10,10,9,8,7,6,5,4,3,2,1]; + this.tweens['fade'] = [10,10,10,10,10,10,10,10,10,10]; + this.queue = []; + this.queue.IDs = []; + this.active = false; + this.timer = null; + + this.createTween = function(start,end,type) { + // return array of tween coordinate data (start->end) + type = type||'default'; + var tween = [start]; + var tmp = start; + var diff = end-start; + var x = self.tweens[type].length; + for (var i=0; i= 0.4 && pos <= 0.6) { + pos = 0.5; + } + pos = parseInt(pos*100); + // writeDebug('getPanX('+x+'): '+pos+'%'); + return pos; + } + + this.isEmpty = function(o) { + // needs further hacking + return (typeof(o)=='undefined'||(o==null&&o!=0)||(o==''&&o!=0)||o=='null'); + } + + this.init = function() { +// self.oFW = document.getElementById('fw'); +// self.oFP = document.getElementById('fp'); +// if (typeof(enableDebugMode)!='undefined' && (self.DEBUG||window.location.toString().toLowerCase().indexOf('debug')>=0)) enableDebugMode(); + self.getWindowCoords(); + self.animator = new Animator2(); + } + + this.destructor = function() { +/* + for (var i=self.fireworks.length; i--;) { + self.fireworks[i] = null; + } + self.fireworks = null; + if (soundManager) { + soundManager.destructor(); + soundManager = null; + } +*/ + } + + if (this.isSafari || this.isOpera) this.getWindowCoords = this.getWindowCoordsAlt; + +} + + +function Controller(o) { + var self = this; + this.o = o; + this.controls = []; + this.cb = []; + this.options = []; + this.functionExample = document.getElementById('function-example'); + this.fbIE = null; + + this.randomize = function() { + for (var i=1; i,\n\ + autoPlay: "+threeSixtyPlayer.config.autoPlay+",\n\ + allowMultiple: "+threeSixtyPlayer.config.allowMultiple+",\n\ + loadRingColor: '"+threeSixtyPlayer.config.loadRingColor+"',\n\ + playRingColor: '"+threeSixtyPlayer.config.playRingColor+"',\n\ + backgroundRingColor: '"+threeSixtyPlayer.config.backgroundRingColor+"',\n\ + circleDiameter: "+threeSixtyPlayer.config.circleDiameter+",\n\ + circleRadius: "+threeSixtyPlayer.config.circleRadius+",\n\ + animDuration: "+threeSixtyPlayer.config.animDuration+",\n\ + animTransition: Animator.tx.bouncy,\n\ + showHMSTime: "+threeSixtyPlayer.config.showHMSTime+",\n\ +\n\ + useWaveformData: "+threeSixtyPlayer.config.useWaveformData+",\n\ + waveformDataColor: '"+threeSixtyPlayer.config.waveformDataColor+"',\n\ + waveformDataDownsample: "+threeSixtyPlayer.config.waveformDataDownsample+",\n\ + waveformDataOutside: "+threeSixtyPlayer.config.waveformDataOutside+",\n\ + waveformDataConstrain: false,\n\ + waveformDataLineRatio: "+threeSixtyPlayer.config.waveformDataLineRatio+",\n\ +\n\ + useEQData: "+threeSixtyPlayer.config.useEQData+",\n\ + eqDataColor: '"+threeSixtyPlayer.config.eqDataColor+"',\n\ + eqDataDownsample: "+threeSixtyPlayer.config.eqDataDownsample+",\n\ + eqDataOutside: "+threeSixtyPlayer.config.eqDataOutside+",\n\ + eqDataLineRatio: "+threeSixtyPlayer.config.eqDataLineRatio+",\n\ +\n\ + usePeakData: "+threeSixtyPlayer.config.usePeakData+",\n\ + peakDataColor: '"+threeSixtyPlayer.config.peakDataColor+"',\n\ + peakDataOutside: "+threeSixtyPlayer.config.peakDataOutside+",\n\ + peakDataLineRatio: "+threeSixtyPlayer.config.peakDataLineRatio+",\n\ +\n\ + useAmplifier: "+threeSixtyPlayer.config.useAmplifier+"\n\ +\n\ +}"; +document.getElementById('config-code').style.display = 'block'; // weird Fx fix + } + + this.createCustomFirework = function() { + } + + this.destructor = function() { + for (var i=self.controls.length; i--;) { + self.controls[i].destructor(); + } + for (i=self.cb.length; i--;) { + self.cb.onclick = null; + self.cb[i] = null; + } + for (i=self.options.length; i--;) { + self.options[i] = null; + } + if (navigator.userAgent.match(/msie/i)) { + self.fbIE.onmouseover = null; + self.fbIE.onmouseout = null; + self.fbIE = null; + } + self.cb = null; + self.options = null; + self.controls = null; + self.functionExample = null; + self.o = null; + } + + var items = parseInt(this.o.length/3); + for (var i=0; iself.xMax) { + x = self.xMax; + } else if (x=self.tween.length-1) { + self.active = false; + self.frame = 0; + if (self._oncomplete) self._oncomplete(); +// self.doUpdate(); + return false; + } + self.doUpdate(); + return true; + } + + this.doUpdate = function(t) { + // if (!self.timer) self.timer = setTimeout(self.update,t||20); + self.update(); + } + + this.update = function() { + self.timer = null; + self.value = 1+parseInt(self.x/self.xMax*(self.scale-1)); + if (self.value<1) self.value = 1; + // if (self.oV.innerHTML != self.value) self.oV.innerHTML = self.value; + // self.oV.innerHTML = self.value; + } + + this.setValue = function(x) { + self.slide(self.x,Math.min(self.xMax,x)); + } + + this.randomize = function() { + self.slide(self.x,parseInt(Math.random()*self.xMax)); + } + + this.destructor = function() { + self.o.onmouseover = null; + self.o.onmouseout = null; + self.o.onmousedown = null; + self.o = null; + self.oV = null; + self.oB.onclick = null; + self.oB = null; + } + + if (soundManager.isIE) { + // IE is lame, no :hover + this.o.onmouseover = this.over; + this.o.onmouseout = this.out; + } + + this.o.onmousedown = this.down; + this.oB.onclick = this.barClick; + self.update(); + +} + +var gOID = 0; + +function demoInit() { + controller = new Controller(document.getElementById('controls').getElementsByTagName('dd')); +} + +function demoDestuctor() { + controller.destructor(); + controller = null; +} + +var controller = null; + +var mc = new MainController(); +// create null objects if APIs not present + +function createCP(oInput,oHandler) { + var Event = YAHOO.util.Event; + + cpHandler = oHandler; + if (picker != null) { + // picker.showcontrols(true); + var c = oInput.value.substr(1); + picker.setValue(hex2decArray([c.substr(0,2),c.substr(2,2),c.substr(4,2)]),true); // be silent + return false; + } + + Event.onDOMReady(function() { + picker = new YAHOO.widget.ColorPicker("cp-container", { + showhsvcontrols: true, + showhexcontrols: true, + images: { + PICKER_THUMB: "../_image/picker_thumb.png", + HUE_THUMB: "../_image/hue_thumb.png" + } + }); + +// picker.showcontrols(false); + //a listener for logging RGB color changes; + //this will only be visible if logger is enabled: + var onRgbChange = function(o) { + /*o is an object + { newValue: (array of R, G, B values), + prevValue: (array of R, G, B values), + type: "rgbChange" + } + */ + cpHandler(o.newValue); + controller.updateExampleCode(); + } + + //subscribe to the rgbChange event; + picker.on("rgbChange", onRgbChange); + + //use setValue to reset the value to white: + Event.on("reset", "click", function(e) { + picker.setValue([255, 255, 255], false); //false here means that rgbChange + //wil fire; true would silence it + }); + + //use the "get" method to get the current value + //of one of the Color Picker's properties; in + //this case, we'll get the hex value and write it + //to the log: + Event.on("gethex", "click", function(e) { + console.log("Current hex value: " + picker.get("hex")); + }); + + }); +} + +var picker = null; + +cpHandler = function() { +} + + + // hex -> dec / dec -> hex + // http://www.southwest.com.au/~jfuller/binary/converter.htm + + function dec2hex(cval) { + if (cval > 255) cval = 255; + var hexascii = "0123456789ABCDEF"; + var cval0 = Math.floor(cval/16); + var cval1 = cval-(cval0*16); + var c1 = hexascii.charAt(cval0); + var c2 = hexascii.charAt(cval1); + return (c1+c2); + } + + function hex2dec(cval) { + cval = cval.toUpperCase(); + var tval = 0; + var hexascii = "0123456789ABCDEF"; + var mychar, ch; + for (var c=0; c + + +360° MP3 player UI demo (SoundManager 2) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

SoundManager 2 / 360° Player: JavaScript + Canvas UI

+ +

Canvas-based UI. Load progress, seek, play/pause etc. Also see 360° UI visualization demo.

+ +
+ +
+ +
+ + + + +
+ +

Alternate style: inline

+ + + +
+ +
+ +
+ + +

How This Works

+ +

The script looks for a container element matching div.ui360, and then the first link inside of it.

+ +
+ +
<div class="ui360">
+ <a href="/path/to/an.mp3">play "an.mp3"</a>
+</div>
+ +
+ +

When the 360 player script loads, it adds a UI template to the block, prepending it in front of the MP3 link:

+ +
<div class="ui360">
+ <-- dynamically-inserted block -->
+ <div class="ui">
+  <canvas class="sm2-canvas"></canvas>
+  <span class="sm2-360btn"></span> 
+  <div class="sm2-timing"></div>
+  <div class="sm2-cover"></div>
+ </div>
+ <-- /UI -->
+ <a href="/path/to/an.mp3">
+</div>
+ +

Customizing the UI

+ +

The player's default 50x50-pixel canvas is defined both within JavaScript and CSS. For an example with different values, see this larger version.

+ +
threeSixtyPlayer.config = {
+  playNext: false, // stop after one sound, or play through list until end
+  autoPlay: false, // start playing the first sound right away
+  allowMultiple: true, // let many sounds play at once (false = one at a time)
+  loadRingColor: '#ccc', // amount of sound which has loaded
+  playRingColor: '#000', // amount of sound which has played
+  backgroundRingColor: '#eee', // "default" color shown underneath everything else
+  animDuration: 500,
+  animTransition: Animator.tx.bouncy // http://www.berniecode.com/writing/animator.html
+}
+ +

The CSS for the canvas UI block is a bit ugly, but JavaScript reads the width of the .sm2-360ui element in the DOM as set by CSS and uses that to later draw and update the canvas element while playing.

+ +
.ui360,
+.sm2-360ui {
+  /* size of the container for the circle, etc. */
+  width:50px;
+  height:50px;
+}
+
+ +

Third-party Components

+ +

This demo includes use of Bernie's Better Animation Class (Apache licensed) for some animation effects.

+

Also, some loader/spinner icons from ajaxload.info are used for showing loading/buffering states.

+ +
+ +

+ SoundManager 2 project page (not an MP3 link) +

+ + +
+ + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/script/360player.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/script/360player.js new file mode 100755 index 00000000..c869d1a1 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/script/360player.js @@ -0,0 +1,1410 @@ +/** + * + * SoundManager 2 Demo: 360-degree / "donut player" + * ------------------------------------------------ + * http://schillmania.com/projects/soundmanager2/ + * + * An inline player with a circular UI. + * Based on the original SM2 inline player. + * Inspired by Apple's preview feature in the + * iTunes music store (iPhone), among others. + * + * Requires SoundManager 2 Javascript API. + * Also uses Bernie's Better Animation Class (BSD): + * http://www.berniecode.com/writing/animator.html + * +*/ + +/*jslint white: false, onevar: true, undef: true, nomen: false, eqeqeq: true, plusplus: false, bitwise: true, regexp: false, newcap: true, immed: true */ +/*global document, window, soundManager, navigator */ + +var threeSixtyPlayer, // instance + ThreeSixtyPlayer; // constructor + +(function(window) { + +function ThreeSixtyPlayer() { + + var self = this, + pl = this, + sm = soundManager, // soundManager instance + uA = navigator.userAgent, + isIE = (uA.match(/msie/i)), + isOpera = (uA.match(/opera/i)), + isSafari = (uA.match(/safari/i)), + isChrome = (uA.match(/chrome/i)), + isFirefox = (uA.match(/firefox/i)), + isTouchDevice = (uA.match(/ipad|iphone/i)), + hasRealCanvas = (typeof window.G_vmlCanvasManager === 'undefined' && typeof document.createElement('canvas').getContext('2d') !== 'undefined'), + // I dunno what Opera doesn't like about this. I'm probably doing it wrong. + fullCircle = (isOpera||isChrome?359.9:360); + + // CSS class for ignoring MP3 links + this.excludeClass = 'threesixty-exclude'; + this.links = []; + this.sounds = []; + this.soundsByURL = []; + this.indexByURL = []; + this.lastSound = null; + this.lastTouchedSound = null; + this.soundCount = 0; + this.oUITemplate = null; + this.oUIImageMap = null; + this.vuMeter = null; + this.callbackCount = 0; + this.peakDataHistory = []; + + // 360player configuration options + this.config = { + + playNext: false, // stop after one sound, or play through list until end + autoPlay: false, // start playing the first sound right away + allowMultiple: false, // let many sounds play at once (false = only one sound playing at a time) + loadRingColor: '#ccc', // how much has loaded + playRingColor: '#000', // how much has played + backgroundRingColor: '#eee', // color shown underneath load + play ("not yet loaded" color) + + // optional segment/annotation (metadata) stuff.. + segmentRingColor: 'rgba(255,255,255,0.33)', // metadata/annotation (segment) colors + segmentRingColorAlt: 'rgba(0,0,0,0.1)', + loadRingColorMetadata: '#ddd', // "annotations" load color + playRingColorMetadata: 'rgba(128,192,256,0.9)', // how much has played when metadata is present + + circleDiameter: null, // set dynamically according to values from CSS + circleRadius: null, + animDuration: 500, + animTransition: window.Animator.tx.bouncy, // http://www.berniecode.com/writing/animator.html + showHMSTime: false, // hours:minutes:seconds vs. seconds-only + scaleFont: true, // also set the font size (if possible) while animating the circle + + // optional: spectrum or EQ graph in canvas (not supported in IE <9, too slow via ExCanvas) + useWaveformData: false, + waveformDataColor: '#0099ff', + waveformDataDownsample: 3, // use only one in X (of a set of 256 values) - 1 means all 256 + waveformDataOutside: false, + waveformDataConstrain: false, // if true, +ve values only - keep within inside circle + waveformDataLineRatio: 0.64, + + // "spectrum frequency" option + useEQData: false, + eqDataColor: '#339933', + eqDataDownsample: 4, // use only one in X (of 256 values) + eqDataOutside: true, + eqDataLineRatio: 0.54, + + // enable "amplifier" (canvas pulses like a speaker) effect + usePeakData: true, + peakDataColor: '#ff33ff', + peakDataOutside: true, + peakDataLineRatio: 0.5, + + useAmplifier: true, // "pulse" like a speaker + + fontSizeMax: null, // set according to CSS + + scaleArcWidth: 1, // thickness factor of playback progress ring + + useFavIcon: false // Experimental (also requires usePeakData: true).. Try to draw a "VU Meter" in the favicon area, if browser supports it (Firefox + Opera as of 2009) + + }; + + this.css = { + + // CSS class names appended to link during various states + sDefault: 'sm2_link', // default state + sBuffering: 'sm2_buffering', + sPlaying: 'sm2_playing', + sPaused: 'sm2_paused' + + }; + + this.addEventHandler = (typeof window.addEventListener !== 'undefined' ? function(o, evtName, evtHandler) { + return o.addEventListener(evtName,evtHandler,false); + } : function(o, evtName, evtHandler) { + o.attachEvent('on'+evtName,evtHandler); + }); + + this.removeEventHandler = (typeof window.removeEventListener !== 'undefined' ? function(o, evtName, evtHandler) { + return o.removeEventListener(evtName,evtHandler,false); + } : function(o, evtName, evtHandler) { + return o.detachEvent('on'+evtName,evtHandler); + }); + + this.hasClass = function(o,cStr) { + return typeof(o.className)!=='undefined'?o.className.match(new RegExp('(\\s|^)'+cStr+'(\\s|$)')):false; + }; + + this.addClass = function(o,cStr) { + + if (!o || !cStr || self.hasClass(o,cStr)) { + return false; + } + o.className = (o.className?o.className+' ':'')+cStr; + + }; + + this.removeClass = function(o,cStr) { + + if (!o || !cStr || !self.hasClass(o,cStr)) { + return false; + } + o.className = o.className.replace(new RegExp('( '+cStr+')|('+cStr+')','g'),''); + + }; + + this.getElementsByClassName = function(className,tagNames,oParent) { + + var doc = (oParent||document), + matches = [], i,j, nodes = []; + if (typeof tagNames !== 'undefined' && typeof tagNames !== 'string') { + for (i=tagNames.length; i--;) { + if (!nodes || !nodes[tagNames[i]]) { + nodes[tagNames[i]] = doc.getElementsByTagName(tagNames[i]); + } + } + } else if (tagNames) { + nodes = doc.getElementsByTagName(tagNames); + } else { + nodes = doc.all||doc.getElementsByTagName('*'); + } + if (typeof(tagNames)!=='string') { + for (i=tagNames.length; i--;) { + for (j=nodes[tagNames[i]].length; j--;) { + if (self.hasClass(nodes[tagNames[i]][j],className)) { + matches.push(nodes[tagNames[i]][j]); + } + } + } + } else { + for (i=0; i 1) { + // only catch left-clicks + return true; + } + + var o = self.getTheDamnLink(e), + canvasElements, sURL, soundURL, thisSound, oContainer, has_vis, diameter; + + if (o.nodeName.toLowerCase() !== 'a') { + o = self.isChildOfNode(o,'a'); + if (!o) { + return true; + } + } + + if (!self.isChildOfClass(o,'ui360')) { + // not a link we're interested in + return true; + } + + sURL = o.getAttribute('href'); + + if (!o.href || !sm.canPlayLink(o) || self.hasClass(o,self.excludeClass)) { + return true; // pass-thru for non-MP3/non-links + } + + sm._writeDebug('handleClick()'); + soundURL = (o.href); + thisSound = self.getSoundByURL(soundURL); + + if (thisSound) { + + // already exists + if (thisSound === self.lastSound) { + // and was playing (or paused) + thisSound.togglePause(); + } else { + // different sound + thisSound.togglePause(); // start playing current + sm._writeDebug('sound different than last sound: '+self.lastSound.id); + if (!self.config.allowMultiple && self.lastSound) { + self.stopSound(self.lastSound); + } + } + + } else { + + // append some dom shiz, make noise + + oContainer = o.parentNode; + has_vis = (self.getElementsByClassName('ui360-vis','div',oContainer.parentNode).length); + + // create sound + thisSound = sm.createSound({ + id:'ui360Sound'+(self.soundCount++), + url:soundURL, + onplay:self.events.play, + onstop:self.events.stop, + onpause:self.events.pause, + onresume:self.events.resume, + onfinish:self.events.finish, + onbufferchange:self.events.bufferchange, + type:(o.type||null), + whileloading:self.events.whileloading, + whileplaying:self.events.whileplaying, + useWaveformData:(has_vis && self.config.useWaveformData), + useEQData:(has_vis && self.config.useEQData), + usePeakData:(has_vis && self.config.usePeakData) + }); + + // tack on some custom data + + diameter = parseInt(self.getElementsByClassName('sm2-360ui','div',oContainer)[0].offsetWidth, 10); + + // see note re: IE <9 and excanvas when Modernizr is included, making weird things happen with . + canvasElements = self.getElementsByClassName('sm2-canvas','canvas',oContainer), + + thisSound._360data = { + oUI360: self.getParentByClassName(o,'ui360'), // the (whole) entire container + oLink: o, // DOM node for reference within SM2 object event handlers + className: self.css.sPlaying, + oUIBox: self.getElementsByClassName('sm2-360ui','div',oContainer)[0], + oCanvas: canvasElements[canvasElements.length-1], + oButton: self.getElementsByClassName('sm2-360btn','span',oContainer)[0], + oTiming: self.getElementsByClassName('sm2-timing','div',oContainer)[0], + oCover: self.getElementsByClassName('sm2-cover','div',oContainer)[0], + circleDiameter: diameter, + circleRadius: diameter/2, + lastTime: null, + didFinish: null, + pauseCount:0, + radius:0, + fontSize: 1, + fontSizeMax: self.config.fontSizeMax, + scaleFont: (has_vis && self.config.scaleFont), + showHMSTime: has_vis, + amplifier: (has_vis && self.config.usePeakData?0.9:1), // TODO: x1 if not being used, else use dynamic "how much to amplify by" value + radiusMax: diameter*0.175, // circle radius + width:0, + widthMax: diameter*0.4, // width of the outer ring + lastValues: { + bytesLoaded: 0, + bytesTotal: 0, + position: 0, + durationEstimate: 0 + }, // used to track "last good known" values before sound finish/reset for anim + animating: false, + oAnim: new window.Animator({ + duration: self.config.animDuration, + transition:self.config.animTransition, + onComplete: function() { + // var thisSound = this; + // thisSound._360data.didFinish = false; // reset full circle + } + }), + oAnimProgress: function(nProgress) { + var thisSound = this; + thisSound._360data.radius = parseInt(thisSound._360data.radiusMax*thisSound._360data.amplifier*nProgress, 10); + thisSound._360data.width = parseInt(thisSound._360data.widthMax*thisSound._360data.amplifier*nProgress, 10); + if (thisSound._360data.scaleFont && thisSound._360data.fontSizeMax !== null) { + thisSound._360data.oTiming.style.fontSize = parseInt(Math.max(1,thisSound._360data.fontSizeMax*nProgress), 10)+'px'; + thisSound._360data.oTiming.style.opacity = nProgress; + } + if (thisSound.paused || thisSound.playState === 0 || thisSound._360data.lastValues.bytesLoaded === 0 || thisSound._360data.lastValues.position === 0) { + self.updatePlaying.apply(thisSound); + } + }, + fps: 0 + }; + + // "Metadata" (annotations) + if (typeof self.Metadata !== 'undefined' && self.getElementsByClassName('metadata','div',thisSound._360data.oUI360).length) { + thisSound._360data.metadata = new self.Metadata(thisSound,self); + } + + // minimize ze font + if (thisSound._360data.scaleFont && thisSound._360data.fontSizeMax !== null) { + thisSound._360data.oTiming.style.fontSize = '1px'; + } + + // set up ze animation + thisSound._360data.oAnim.addSubject(thisSound._360data.oAnimProgress,thisSound); + + // animate the radius out nice + self.refreshCoords(thisSound); + + self.updatePlaying.apply(thisSound); + + self.soundsByURL[soundURL] = thisSound; + self.sounds.push(thisSound); + if (!self.config.allowMultiple && self.lastSound) { + self.stopSound(self.lastSound); + } + thisSound.play(); + + } + + self.lastSound = thisSound; // reference for next call + + if (typeof e !== 'undefined' && typeof e.preventDefault !== 'undefined') { + e.preventDefault(); + } else if (typeof window.event !== 'undefined') { + window.event.returnValue = false; + } + return false; + + }; + + this.fanOut = function(oSound) { + + var thisSound = oSound; + if (thisSound._360data.animating === 1) { + return false; + } + thisSound._360data.animating = 0; + soundManager._writeDebug('fanOut: '+thisSound.id+': '+thisSound._360data.oLink.href); + thisSound._360data.oAnim.seekTo(1); // play to end + window.setTimeout(function() { + // oncomplete hack + thisSound._360data.animating = 0; + },self.config.animDuration+20); + + }; + + this.fanIn = function(oSound) { + + var thisSound = oSound; + if (thisSound._360data.animating === -1) { + return false; + } + thisSound._360data.animating = -1; + soundManager._writeDebug('fanIn: '+thisSound.id+': '+thisSound._360data.oLink.href); + // massive hack + thisSound._360data.oAnim.seekTo(0); // play to end + window.setTimeout(function() { + // reset full 360 fill after animation has completed (oncomplete hack) + thisSound._360data.didFinish = false; + thisSound._360data.animating = 0; + self.resetLastValues(thisSound); + }, self.config.animDuration+20); + + }; + + this.resetLastValues = function(oSound) { + oSound._360data.lastValues.position = 0; + }; + + this.refreshCoords = function(thisSound) { + + thisSound._360data.canvasXY = self.findXY(thisSound._360data.oCanvas); + thisSound._360data.canvasMid = [thisSound._360data.circleRadius,thisSound._360data.circleRadius]; + thisSound._360data.canvasMidXY = [thisSound._360data.canvasXY[0]+thisSound._360data.canvasMid[0], thisSound._360data.canvasXY[1]+thisSound._360data.canvasMid[1]]; + + }; + + this.stopSound = function(oSound) { + + soundManager._writeDebug('stopSound: '+oSound.id); + soundManager.stop(oSound.id); + if (!isTouchDevice) { // iOS 4.2+ security blocks onfinish() -> playNext() if we set a .src in-between(?) + soundManager.unload(oSound.id); + } + + }; + + this.buttonClick = function(e) { + + var o = e?(e.target?e.target:e.srcElement):window.event.srcElement; + self.handleClick({target:self.getParentByClassName(o,'sm2-360ui').nextSibling}); // link next to the nodes we inserted + return false; + + }; + + this.buttonMouseDown = function(e) { + + // user might decide to drag from here + // watch for mouse move + if (!isTouchDevice) { + document.onmousemove = function(e) { + // should be boundary-checked, really (eg. move 3px first?) + self.mouseDown(e); + }; + } else { + self.addEventHandler(document,'touchmove',self.mouseDown); + } + self.stopEvent(e); + return false; + + }; + + this.mouseDown = function(e) { + + if (!isTouchDevice && e.button > 1) { + return true; // ignore non-left-click + } + + if (!self.lastSound) { + self.stopEvent(e); + return false; + } + + var evt = e?e:window.event, + target, thisSound, oData; + + if (isTouchDevice && evt.touches) { + evt = evt.touches[0]; + } + target = (evt.target||evt.srcElement); + + thisSound = self.getSoundByURL(self.getElementsByClassName('sm2_link','a',self.getParentByClassName(target,'ui360'))[0].href); // self.lastSound; // TODO: In multiple sound case, figure out which sound is involved etc. + // just in case, update coordinates (maybe the element moved since last time.) + self.lastTouchedSound = thisSound; + self.refreshCoords(thisSound); + oData = thisSound._360data; + self.addClass(oData.oUIBox,'sm2_dragging'); + oData.pauseCount = (self.lastTouchedSound.paused?1:0); + // self.lastSound.pause(); + self.mmh(e?e:window.event); + + if (isTouchDevice) { + self.removeEventHandler(document,'touchmove',self.mouseDown); + self.addEventHandler(document,'touchmove',self.mmh); + self.addEventHandler(document,'touchend',self.mouseUp); + } else { + // incredibly old-skool. TODO: Modernize. + document.onmousemove = self.mmh; + document.onmouseup = self.mouseUp; + } + + self.stopEvent(e); + return false; + + }; + + this.mouseUp = function(e) { + + var oData = self.lastTouchedSound._360data; + self.removeClass(oData.oUIBox,'sm2_dragging'); + if (oData.pauseCount === 0) { + self.lastTouchedSound.resume(); + } + if (!isTouchDevice) { + document.onmousemove = null; + document.onmouseup = null; + } else { + self.removeEventHandler(document,'touchmove',self.mmh); + self.removeEventHandler(document,'touchend',self.mouseUP); + } + + }; + + this.mmh = function(e) { + + if (typeof e === 'undefined') { + e = window.event; + } + var oSound = self.lastTouchedSound, + coords = self.getMouseXY(e), + x = coords[0], + y = coords[1], + deltaX = x-oSound._360data.canvasMidXY[0], + deltaY = y-oSound._360data.canvasMidXY[1], + angle = Math.floor(fullCircle-(self.rad2deg(Math.atan2(deltaX,deltaY))+180)); + + oSound.setPosition(oSound.durationEstimate*(angle/fullCircle)); + self.stopEvent(e); + return false; + + }; + + // assignMouseDown(); + + this.drawSolidArc = function(oCanvas, color, radius, width, radians, startAngle, noClear) { + + // thank you, http://www.snipersystems.co.nz/community/polarclock/tutorial.html + + var x = radius, + y = radius, + canvas = oCanvas, + ctx, innerRadius, doesntLikeZero, endPoint; + + if (canvas.getContext) { + // use getContext to use the canvas for drawing + ctx = canvas.getContext('2d'); + } + + // re-assign canvas as the actual context + oCanvas = ctx; + + if (!noClear) { + self.clearCanvas(canvas); + } + // ctx.restore(); + + if (color) { + ctx.fillStyle = color; + } + + oCanvas.beginPath(); + + if (isNaN(radians)) { + radians = 0; + } + + innerRadius = radius-width; + doesntLikeZero = (isOpera || isSafari); // safari 4 doesn't actually seem to mind. + + if (!doesntLikeZero || (doesntLikeZero && radius > 0)) { + oCanvas.arc(0, 0, radius, startAngle, radians, false); + endPoint = self.getArcEndpointCoords(innerRadius, radians); + oCanvas.lineTo(endPoint.x, endPoint.y); + oCanvas.arc(0, 0, innerRadius, radians, startAngle, true); + oCanvas.closePath(); + oCanvas.fill(); + } + + }; + + this.getArcEndpointCoords = function(radius, radians) { + + return { + x: radius * Math.cos(radians), + y: radius * Math.sin(radians) + }; + + }; + + this.deg2rad = function(nDeg) { + return (nDeg * Math.PI/180); + }; + + this.rad2deg = function(nRad) { + return (nRad * 180/Math.PI); + }; + + this.getTime = function(nMSec,bAsString) { + + // convert milliseconds to mm:ss, return as object literal or string + var nSec = Math.floor(nMSec/1000), + min = Math.floor(nSec/60), + sec = nSec-(min*60); + // if (min === 0 && sec === 0) return null; // return 0:00 as null + return (bAsString?(min+':'+(sec<10?'0'+sec:sec)):{'min':min,'sec':sec}); + + }; + + this.clearCanvas = function(oCanvas) { + + var canvas = oCanvas, + ctx = null, + width, height; + + if (canvas.getContext) { + // use getContext to use the canvas for drawing + ctx = canvas.getContext('2d'); + } + + if (ctx) { + width = canvas.offsetWidth; + height = canvas.offsetHeight; + ctx.clearRect(-(width/2), -(height/2), width, height); + } + + }; + + this.updatePlaying = function() { + + var timeNow = (this._360data.showHMSTime?self.getTime(this.position,true):parseInt(this.position/1000, 10)); + var ringScaleFactor = self.config.scaleArcWidth; + + if (this.bytesLoaded) { + this._360data.lastValues.bytesLoaded = this.bytesLoaded; + this._360data.lastValues.bytesTotal = this.bytesTotal; + } + + if (this.position) { + this._360data.lastValues.position = this.position; + } + + if (this.durationEstimate) { + this._360data.lastValues.durationEstimate = this.durationEstimate; + } + + // background ring + self.drawSolidArc(this._360data.oCanvas,self.config.backgroundRingColor,this._360data.width,this._360data.radius * ringScaleFactor,self.deg2rad(fullCircle),false); + + // loaded ring + self.drawSolidArc(this._360data.oCanvas,(this._360data.metadata?self.config.loadRingColorMetadata:self.config.loadRingColor),this._360data.width,this._360data.radius * ringScaleFactor,self.deg2rad(fullCircle*(this._360data.lastValues.bytesLoaded/this._360data.lastValues.bytesTotal)),0,true); + + // don't draw if 0 (full black circle in Opera) + if (this._360data.lastValues.position !== 0) { + self.drawSolidArc(this._360data.oCanvas,(this._360data.metadata?self.config.playRingColorMetadata:self.config.playRingColor),this._360data.width,this._360data.radius * ringScaleFactor,self.deg2rad((this._360data.didFinish===1?fullCircle:fullCircle*(this._360data.lastValues.position/this._360data.lastValues.durationEstimate))),0,true); + } + + // metadata goes here + if (this._360data.metadata) { + this._360data.metadata.events.whileplaying(); + } + + if (timeNow !== this._360data.lastTime) { + this._360data.lastTime = timeNow; + this._360data.oTiming.innerHTML = timeNow; + } + + // draw spectrum, if applicable + if ((this.instanceOptions.useWaveformData || this.instanceOptions.useEQData) && hasRealCanvas) { // IE <9 can render maybe 3 or 4 FPS when including the wave/EQ, so don't bother. + self.updateWaveform(this); + } + + if (self.config.useFavIcon && self.vuMeter) { + self.vuMeter.updateVU(this); + } + + }; + + this.updateWaveform = function(oSound) { + + if ((!self.config.useWaveformData && !self.config.useEQData) || (!sm.features.waveformData && !sm.features.eqData)) { + // feature not enabled.. + return false; + } + + if (!oSound.waveformData.left.length && !oSound.eqData.length && !oSound.peakData.left) { + // no data (or errored out/paused/unavailable?) + return false; + } + + /* use for testing the data */ + /* + for (i=0; i<256; i++) { + oSound.eqData[i] = 1-(i/256); + } + */ + + var oCanvas = oSound._360data.oCanvas.getContext('2d'), + offX = 0, + offY = parseInt(oSound._360data.circleDiameter/2, 10), + scale = offY/2, // Y axis (+/- this distance from 0) + // lineWidth = Math.floor(oSound._360data.circleDiameter-(oSound._360data.circleDiameter*0.175)/(oSound._360data.circleDiameter/255)); // width for each line + lineWidth = 1, + lineHeight = 1, + thisY = 0, + offset = offY, + i, j, direction, downSample, dataLength, sampleCount, startAngle, endAngle, waveData, innerRadius, perItemAngle, yDiff, eqSamples, playedAngle, iAvg, nPeak; + + if (self.config.useWaveformData) { + // raw waveform + downSample = self.config.waveformDataDownsample; // only sample X in 256 (greater number = less sample points) + downSample = Math.max(1,downSample); // make sure it's at least 1 + dataLength = 256; + sampleCount = (dataLength/downSample); + startAngle = 0; + endAngle = 0; + waveData = null; + innerRadius = (self.config.waveformDataOutside?1:(self.config.waveformDataConstrain?0.5:0.565)); + scale = (self.config.waveformDataOutside?0.7:0.75); + perItemAngle = self.deg2rad((360/sampleCount)*self.config.waveformDataLineRatio); // 0.85 = clean pixel lines at 150? // self.deg2rad(360*(Math.max(1,downSample-1))/sampleCount); + for (i=0; i16500 Hz), most stuff won't actually use it. + sampleCount = (eqSamples/downSample); + innerRadius = (self.config.eqDataOutside?1:0.565); + direction = (self.config.eqDataOutside?-1:1); + scale = (self.config.eqDataOutside?0.5:0.75); + startAngle = 0; + endAngle = 0; + perItemAngle = self.deg2rad((360/sampleCount)*self.config.eqDataLineRatio); // self.deg2rad(360/(sampleCount+1)); + playedAngle = self.deg2rad((oSound._360data.didFinish===1?360:360*(oSound._360data.lastValues.position/oSound._360data.lastValues.durationEstimate))); + j=0; + iAvg = 0; + for (i=0; iplayedAngle?self.config.eqDataColor:self.config.playRingColor),oSound._360data.width*innerRadius,oSound._360data.radius*scale*(oSound.eqData.left[i]*direction),endAngle,startAngle,true); + } + } + + if (self.config.usePeakData) { + if (!oSound._360data.animating) { + nPeak = (oSound.peakData.left||oSound.peakData.right); + // GIANT HACK: use EQ spectrum data for bass frequencies + eqSamples = 3; + for (i=0; i', + ' ', // note use of imageMap, edit or remove if you use a different-size image. + '
', // + Ever-so-slight Safari horizontal alignment tweak + '
' + ]; + + }; + + this.uiTest = function(sClass) { + + // fake a 360 UI so we can get some numbers from CSS, etc. + + var oTemplate = document.createElement('div'), + oFakeUI, oFakeUIBox, oTemp, fakeDiameter, uiHTML, circleDiameter, circleRadius, fontSizeMax, oTiming; + + oTemplate.className = 'sm2-360ui'; + + oFakeUI = document.createElement('div'); + oFakeUI.className = 'ui360'+(sClass?' '+sClass:''); // ui360 ui360-vis + + oFakeUIBox = oFakeUI.appendChild(oTemplate.cloneNode(true)); + + oFakeUI.style.position = 'absolute'; + oFakeUI.style.left = '-9999px'; + + oTemp = document.body.appendChild(oFakeUI); + + fakeDiameter = oFakeUIBox.offsetWidth; + + uiHTML = self.getUIHTML(fakeDiameter); + + oFakeUIBox.innerHTML = uiHTML[1]+uiHTML[2]+uiHTML[3]; + + circleDiameter = parseInt(oFakeUIBox.offsetWidth, 10); + circleRadius = parseInt(circleDiameter/2, 10); + + oTiming = self.getElementsByClassName('sm2-timing','div',oTemp)[0]; + fontSizeMax = parseInt(self.getStyle(oTiming,'font-size'), 10); + if (isNaN(fontSizeMax)) { + // getStyle() etc. didn't work. + fontSizeMax = null; + } + + // soundManager._writeDebug('diameter, font size: '+circleDiameter+','+fontSizeMax); + + oFakeUI.parentNode.removeChild(oFakeUI); + + uiHTML = oFakeUI = oFakeUIBox = oTemp = null; + + return { + circleDiameter: circleDiameter, + circleRadius: circleRadius, + fontSizeMax: fontSizeMax + }; + + }; + + this.init = function() { + + sm._writeDebug('threeSixtyPlayer.init()'); + + var oItems = self.getElementsByClassName('ui360','div'), + i, j, oLinks = [], is_vis = false, foundItems = 0, canvasElements, oCanvas, oCanvasCTX, oCover, diameter, radius, uiData, uiDataVis, oUI, oBtn, o, o2, oID; + + for (i=0,j=oItems.length; i. + * When this is the case, the first doesn't have getContext('2d') and such - so, use the second. + */ + canvasElements = oCanvas.parentNode.getElementsByTagName('canvas'); + if (canvasElements.length > 1) { + oCanvas = canvasElements[canvasElements.length-1]; + } + } else { + // add a handler for the button + oCanvas = oLinks[i].parentNode.getElementsByTagName('canvas')[0]; + } + oCover = self.getElementsByClassName('sm2-cover','div',oLinks[i].parentNode)[0]; + oBtn = oLinks[i].parentNode.getElementsByTagName('span')[0]; + self.addEventHandler(oBtn,'click',self.buttonClick); + if (!isTouchDevice) { + self.addEventHandler(oCover,'mousedown',self.mouseDown); + } else { + self.addEventHandler(oCover,'touchstart',self.mouseDown); + } + oCanvasCTX = oCanvas.getContext('2d'); + oCanvasCTX.translate(radius, radius); + oCanvasCTX.rotate(self.deg2rad(-90)); // compensate for arc starting at EAST // http://stackoverflow.com/questions/319267/tutorial-for-html-canvass-arc-function + } + } + if (foundItems>0) { + self.addEventHandler(document,'click',self.handleClick); + if (self.config.autoPlay) { + self.handleClick({target:self.links[0],preventDefault:function(){}}); + } + } + sm._writeDebug('threeSixtyPlayer.init(): Found '+foundItems+' relevant items.'); + + if (self.config.useFavIcon && typeof this.VUMeter !== 'undefined') { + this.vuMeter = new this.VUMeter(this); + } + + }; + +} + +// Optional: VU Meter component + +ThreeSixtyPlayer.prototype.VUMeter = function(oParent) { + + var self = oParent, + me = this, + _head = document.getElementsByTagName('head')[0], + isOpera = (navigator.userAgent.match(/opera/i)), + isFirefox = (navigator.userAgent.match(/firefox/i)); + + this.vuMeterData = []; + this.vuDataCanvas = null; + + this.setPageIcon = function(sDataURL) { + + if (!self.config.useFavIcon || !self.config.usePeakData || !sDataURL) { + return false; + } + + var link = document.getElementById('sm2-favicon'); + if (link) { + _head.removeChild(link); + link = null; + } + if (!link) { + link = document.createElement('link'); + link.id = 'sm2-favicon'; + link.rel = 'shortcut icon'; + link.type = 'image/png'; + link.href = sDataURL; + document.getElementsByTagName('head')[0].appendChild(link); + } + + }; + + this.resetPageIcon = function() { + + if (!self.config.useFavIcon) { + return false; + } + var link = document.getElementById('favicon'); + if (link) { + link.href = '/favicon.ico'; + } + + }; + + this.updateVU = function(oSound) { + + if (soundManager.flashVersion >= 9 && self.config.useFavIcon && self.config.usePeakData) { + me.setPageIcon(me.vuMeterData[parseInt(16*oSound.peakData.left, 10)][parseInt(16*oSound.peakData.right, 10)]); + } + + }; + + this.createVUData = function() { + + var i=0, j=0, + canvas = me.vuDataCanvas.getContext('2d'), + vuGrad = canvas.createLinearGradient(0, 16, 0, 0), + bgGrad = canvas.createLinearGradient(0, 16, 0, 0), + outline = 'rgba(0,0,0,0.2)'; + + vuGrad.addColorStop(0,'rgb(0,192,0)'); + vuGrad.addColorStop(0.30,'rgb(0,255,0)'); + vuGrad.addColorStop(0.625,'rgb(255,255,0)'); + vuGrad.addColorStop(0.85,'rgb(255,0,0)'); + bgGrad.addColorStop(0,outline); + bgGrad.addColorStop(1,'rgba(0,0,0,0.5)'); + for (i=0; i<16; i++) { + me.vuMeterData[i] = []; + } + for (i=0; i<16; i++) { + for (j=0; j<16; j++) { + // reset/erase canvas + me.vuDataCanvas.setAttribute('width',16); + me.vuDataCanvas.setAttribute('height',16); + // draw new stuffs + canvas.fillStyle = bgGrad; + canvas.fillRect(0,0,7,15); + canvas.fillRect(8,0,7,15); + /* + // shadow + canvas.fillStyle = 'rgba(0,0,0,0.1)'; + canvas.fillRect(1,15-i,7,17-(17-i)); + canvas.fillRect(9,15-j,7,17-(17-j)); + */ + canvas.fillStyle = vuGrad; + canvas.fillRect(0,15-i,7,16-(16-i)); + canvas.fillRect(8,15-j,7,16-(16-j)); + // and now, clear out some bits. + canvas.clearRect(0,3,16,1); + canvas.clearRect(0,7,16,1); + canvas.clearRect(0,11,16,1); + me.vuMeterData[i][j] = me.vuDataCanvas.toDataURL('image/png'); + // for debugging VU images + /* + var o = document.createElement('img'); + o.style.marginRight = '5px'; + o.src = vuMeterData[i][j]; + document.documentElement.appendChild(o); + */ + } + } + + }; + + this.testCanvas = function() { + + // canvas + toDataURL(); + var c = document.createElement('canvas'), + ctx = null, ok; + if (!c || typeof c.getContext === 'undefined') { + return null; + } + ctx = c.getContext('2d'); + if (!ctx || typeof c.toDataURL !== 'function') { + return null; + } + // just in case.. + try { + ok = c.toDataURL('image/png'); + } catch(e) { + // no canvas or no toDataURL() + return null; + } + // assume we're all good. + return c; + + }; + + this.init = function() { + + if (self.config.useFavIcon) { + me.vuDataCanvas = me.testCanvas(); + if (me.vuDataCanvas && (isFirefox || isOpera)) { + // these browsers support dynamically-updating the favicon + me.createVUData(); + } else { + // browser doesn't support doing this + self.config.useFavIcon = false; + } + } + + }; + + this.init(); + +}; + +// completely optional: Metadata/annotations/segments code + +ThreeSixtyPlayer.prototype.Metadata = function(oSound, oParent) { + + soundManager._wD('Metadata()'); + + var me = this, + oBox = oSound._360data.oUI360, + o = oBox.getElementsByTagName('ul')[0], + oItems = o.getElementsByTagName('li'), + isFirefox = (navigator.userAgent.match(/firefox/i)), + isAlt = false, i, oDuration; + + this.lastWPExec = 0; + this.refreshInterval = 250; + this.totalTime = 0; + + this.events = { + + whileplaying: function() { + + var width = oSound._360data.width, + radius = oSound._360data.radius, + fullDuration = (oSound.durationEstimate||(me.totalTime*1000)), + isAlt = null, i, j, d; + + for (i=0,j=me.data.length; ime.refreshInterval) { + me.refresh(); + me.lastWPExec = d; + } + + } + + }; + + this.refresh = function() { + + // Display info as appropriate + var i, j, index = null, + now = oSound.position, + metadata = oSound._360data.metadata.data; + + for (i=0, j=metadata.length; i= metadata[i].startTimeMS && now <= metadata[i].endTimeMS) { + index = i; + break; + } + } + if (index !== metadata.currentItem && index < metadata.length) { + // update + oSound._360data.oLink.innerHTML = metadata.mainTitle+' '; + // self.setPageTitle(metadata[index].title+' | '+metadata.mainTitle); + metadata.currentItem = index; + } + + }; + + this.strToTime = function(sTime) { + var segments = sTime.split(':'), + seconds = 0, i; + for (i=segments.length; i--;) { + seconds += parseInt(segments[i], 10)*Math.pow(60,segments.length-1-i); // hours, minutes + } + return seconds; + }; + + this.data = []; + this.data.givenDuration = null; + this.data.currentItem = null; + this.data.mainTitle = oSound._360data.oLink.innerHTML; + + for (i=0; i= Math.abs(this.state - this.target)) { + this.state = this.target; + } else { + this.state += movement; + } + + try { + this.propagate(); + } finally { + this.options.onStep.call(this); + if (this.target == this.state) { + window.clearInterval(this.intervalId); + this.intervalId = null; + this.options.onComplete.call(this); + } + } + }, + // shortcuts + play: function() {this.seekFromTo(0, 1)}, + reverse: function() {this.seekFromTo(1, 0)}, + // return a string describing this Animator, for debugging + inspect: function() { + var str = "# 20) return; + } + }, + getStyle: function(state) { + state = this.from + ((this.to - this.from) * state); + if (this.property == 'filter') return "alpha(opacity=" + Math.round(state*100) + ")"; + if (this.property == 'opacity') return state; + return Math.round(state) + this.units; + }, + inspect: function() { + return "\t" + this.property + "(" + this.from + this.units + " to " + this.to + this.units + ")\n"; + } +} + +// animates a colour based style property between two hex values +function ColorStyleSubject(els, property, from, to) { + this.els = Animator.makeArray(els); + this.property = Animator.camelize(property); + this.to = this.expandColor(to); + this.from = this.expandColor(from); + this.origFrom = from; + this.origTo = to; +} + +ColorStyleSubject.prototype = { + // parse "#FFFF00" to [256, 256, 0] + expandColor: function(color) { + var hexColor, red, green, blue; + hexColor = ColorStyleSubject.parseColor(color); + if (hexColor) { + red = parseInt(hexColor.slice(1, 3), 16); + green = parseInt(hexColor.slice(3, 5), 16); + blue = parseInt(hexColor.slice(5, 7), 16); + return [red,green,blue] + } + if (window.DEBUG) { + alert("Invalid colour: '" + color + "'"); + } + }, + getValueForState: function(color, state) { + return Math.round(this.from[color] + ((this.to[color] - this.from[color]) * state)); + }, + setState: function(state) { + var color = '#' + + ColorStyleSubject.toColorPart(this.getValueForState(0, state)) + + ColorStyleSubject.toColorPart(this.getValueForState(1, state)) + + ColorStyleSubject.toColorPart(this.getValueForState(2, state)); + for (var i=0; i 255) number = 255; + var digits = number.toString(16); + if (number < 16) return '0' + digits; + return digits; +} +ColorStyleSubject.parseColor.rgbRe = /^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i; +ColorStyleSubject.parseColor.hexRe = /^\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/; + +// Animates discrete styles, i.e. ones that do not scale but have discrete values +// that can't be interpolated +function DiscreteStyleSubject(els, property, from, to, threshold) { + this.els = Animator.makeArray(els); + this.property = Animator.camelize(property); + this.from = from; + this.to = to; + this.threshold = threshold || 0.5; +} + +DiscreteStyleSubject.prototype = { + setState: function(state) { + var j=0; + for (var i=0; i section ? 1 : 0); + } + if (this.options.rememberance) { + document.location.hash = this.rememberanceTexts[section]; + } + } +} diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/script/excanvas.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/script/excanvas.js new file mode 100755 index 00000000..d7488739 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/360-player/script/excanvas.js @@ -0,0 +1,17 @@ +// Excanvas (Explorer Canvas) R43 +// http://excanvas.sourceforge.net/ +// Copyright 2006 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +if(!document.createElement("canvas").getContext){(function(){var u=Math;var v=u.round;var r=u.sin;var C=u.cos;var l=u.abs;var B=u.sqrt;var a=10;var n=a/2;function g(){return this.context_||(this.context_=new p(this))}var t=Array.prototype.slice;function D(j,m,E){var i=t.call(arguments,2);return function(){return j.apply(m,i.concat(t.call(arguments)))}}var h={init:function(i){if(/MSIE/.test(navigator.userAgent)&&!window.opera){var j=i||document;j.createElement("canvas");j.attachEvent("onreadystatechange",D(this.init_,this,j))}},init_:function(F){if(!F.namespaces.g_vml_){F.namespaces.add("g_vml_","urn:schemas-microsoft-com:vml","#default#VML")}if(!F.namespaces.g_o_){F.namespaces.add("g_o_","urn:schemas-microsoft-com:office:office","#default#VML")}if(!F.styleSheets.ex_canvas_){var E=F.createStyleSheet();E.owningElement.id="ex_canvas_";E.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}g_vml_\\:*{behavior:url(#default#VML)}g_o_\\:*{behavior:url(#default#VML)}"}var m=F.getElementsByTagName("canvas");for(var j=0;j','","");this.element_.insertAdjacentHTML("BeforeEnd",Y.join(""))};k.stroke=function(ae){var J=[];var K=false;var ap=c(ae?this.fillStyle:this.strokeStyle);var aa=ap.color;var ak=ap.alpha*this.globalAlpha;var F=10;var M=10;J.push("V.x){V.x=ai.x}if(ao.y==null||ai.yV.y){V.y=ai.y}}}J.push(' ">');if(!ae){var U=this.lineScale_*this.lineWidth;if(U<1){ak*=U}J.push("')}else{if(typeof this.fillStyle=="object"){var N=this.fillStyle;var S=0;var ah={x:0,y:0};var ab=0;var Q=1;if(N.type_=="gradient"){var P=N.x0_/this.arcScaleX_;var m=N.y0_/this.arcScaleY_;var O=N.x1_/this.arcScaleX_;var aq=N.y1_/this.arcScaleY_;var am=this.getCoords_(P,m);var al=this.getCoords_(O,aq);var I=al.x-am.x;var G=al.y-am.y;S=Math.atan2(I,G)*180/Math.PI;if(S<0){S+=360}if(S<0.000001){S=0}}else{var am=this.getCoords_(N.x0_,N.y0_);var j=V.x-ao.x;var E=V.y-ao.y;ah={x:(am.x-ao.x)/j,y:(am.y-ao.y)/E};j/=this.arcScaleX_*a;E/=this.arcScaleY_*a;var ag=u.max(j,E);ab=2*N.r0_/ag;Q=2*N.r1_/ag-ab}var Z=N.colors_;Z.sort(function(H,i){return H.offset-i.offset});var T=Z.length;var Y=Z[0].color;var X=Z[T-1].color;var ad=Z[0].alpha*this.globalAlpha;var ac=Z[T-1].alpha*this.globalAlpha;var af=[];for(var aj=0;aj')}else{J.push('')}}J.push("");this.element_.insertAdjacentHTML("beforeEnd",J.join(""))};k.fill=function(){this.stroke(true)};k.closePath=function(){this.currentPath_.push({type:"close"})};k.getCoords_=function(E,j){var i=this.m_;return{x:a*(E*i[0][0]+j*i[1][0]+i[2][0])-n,y:a*(E*i[0][1]+j*i[1][1]+i[2][1])-n}};k.save=function(){var i={};w(this,i);this.aStack_.push(i);this.mStack_.push(this.m_);this.m_=d(q(),this.m_)};k.restore=function(){w(this.aStack_.pop(),this);this.m_=this.mStack_.pop()};k.translate=function(m,j){var i=[[1,0,0],[0,1,0],[m,j,1]];this.m_=d(i,this.m_)};k.rotate=function(j){var E=C(j);var m=r(j);var i=[[E,m,0],[-m,E,0],[0,0,1]];this.m_=d(i,this.m_)};k.scale=function(G,F){this.arcScaleX_*=G;this.arcScaleY_*=F;var j=[[G,0,0],[0,F,0],[0,0,1]];var i=this.m_=d(j,this.m_);var E=i[0][0]*i[1][1]-i[0][1]*i[1][0];this.lineScale_=B(l(E))};k.clip=function(){};k.arcTo=function(){};k.createPattern=function(){return new f};function z(i){this.type_=i;this.x0_=0;this.y0_=0;this.r0_=0;this.x1_=0;this.y1_=0;this.r1_=0;this.colors_=[]}z.prototype.addColorStop=function(j,i){i=c(i);this.colors_.push({offset:j,color:i.color,alpha:i.alpha})};function f(){}G_vmlCanvasManager=h;CanvasRenderingContext2D=p;CanvasGradient=z;CanvasPattern=f})()}; \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/360ui-screenshot1.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/360ui-screenshot1.png new file mode 100755 index 00000000..b7b3b5dd Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/360ui-screenshot1.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/360ui-screenshot2.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/360ui-screenshot2.png new file mode 100755 index 00000000..28cc0879 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/360ui-screenshot2.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/360ui-screenshot3.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/360ui-screenshot3.png new file mode 100755 index 00000000..fd57d068 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/360ui-screenshot3.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/360ui-screenshot4.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/360ui-screenshot4.png new file mode 100755 index 00000000..5cb03a0c Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/360ui-screenshot4.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/armor-alley-screenshot.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/armor-alley-screenshot.png new file mode 100755 index 00000000..f190275c Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/armor-alley-screenshot.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/cassette-tape-ui-screenshot.jpg b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/cassette-tape-ui-screenshot.jpg new file mode 100755 index 00000000..6d5a5d98 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/cassette-tape-ui-screenshot.jpg differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/cassette-tape-ui-screenshot.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/cassette-tape-ui-screenshot.png new file mode 100755 index 00000000..7bffca2b Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/cassette-tape-ui-screenshot.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/christmas-lights.jpg b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/christmas-lights.jpg new file mode 100755 index 00000000..f07cd01e Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/christmas-lights.jpg differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/christmas-lights.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/christmas-lights.png new file mode 100755 index 00000000..5600eee6 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/christmas-lights.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/chunk-webfont.svg b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/chunk-webfont.svg new file mode 100755 index 00000000..9b4ae056 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/chunk-webfont.svg @@ -0,0 +1,127 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Generated in 2010 by FontLab Studio Copyright info pending + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/chunk-webfont.ttf b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/chunk-webfont.ttf new file mode 100755 index 00000000..5ba183ce Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/chunk-webfont.ttf differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/chunk-webfont.woff b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/chunk-webfont.woff new file mode 100755 index 00000000..116bf471 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/chunk-webfont.woff differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/dejavusansmono-webfont.eot b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/dejavusansmono-webfont.eot new file mode 100755 index 00000000..97fd210d Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/dejavusansmono-webfont.eot differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/dejavusansmono-webfont.woff b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/dejavusansmono-webfont.woff new file mode 100755 index 00000000..cd75c788 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/dejavusansmono-webfont.woff differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/fitter-happier-waveform.jpg b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/fitter-happier-waveform.jpg new file mode 100755 index 00000000..20497b7e Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/fitter-happier-waveform.jpg differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/fitter-happier-waveform.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/fitter-happier-waveform.png new file mode 100755 index 00000000..67689d7d Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/fitter-happier-waveform.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/flash9-dark.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/flash9-dark.png new file mode 100755 index 00000000..02e356b5 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/flash9-dark.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/flash9.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/flash9.png new file mode 100755 index 00000000..ad08d03e Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/flash9.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/getsatisfaction-icon.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/getsatisfaction-icon.gif new file mode 100755 index 00000000..f3762c74 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/getsatisfaction-icon.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/glyphish-dot-com-icons-and-android-sprite.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/glyphish-dot-com-icons-and-android-sprite.png new file mode 100755 index 00000000..c4d7b764 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/glyphish-dot-com-icons-and-android-sprite.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/hue_thumb.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/hue_thumb.png new file mode 100755 index 00000000..0492e8a0 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/hue_thumb.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/logo-sprite.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/logo-sprite.png new file mode 100755 index 00000000..f08a6705 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/logo-sprite.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/mpc-screenshot.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/mpc-screenshot.png new file mode 100755 index 00000000..b714b260 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/mpc-screenshot.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/muxtape-logo.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/muxtape-logo.png new file mode 100755 index 00000000..edc5d35f Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/muxtape-logo.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/new-bw.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/new-bw.png new file mode 100755 index 00000000..8c60abbc Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/new-bw.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/new-dark.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/new-dark.png new file mode 100755 index 00000000..8d20f603 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/new-dark.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/new.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/new.png new file mode 100755 index 00000000..c7618bae Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/new.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/noise-dark.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/noise-dark.png new file mode 100755 index 00000000..38818ad5 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/noise-dark.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/noise.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/noise.png new file mode 100755 index 00000000..4b66015e Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/noise.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/picker_thumb.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/picker_thumb.png new file mode 100755 index 00000000..de21a6f2 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/picker_thumb.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/slider-1.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/slider-1.png new file mode 100755 index 00000000..b4d01c6f Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/slider-1.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/slider-bar.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/slider-bar.gif new file mode 100755 index 00000000..8e25d0e8 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/slider-bar.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/slider.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/slider.png new file mode 100755 index 00000000..320f987e Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/slider.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/soundmanager2-speaker.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/soundmanager2-speaker.png new file mode 100755 index 00000000..c3ab1117 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/soundmanager2-speaker.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/speaker.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/speaker.png new file mode 100755 index 00000000..94dbbe9c Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/speaker.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/survivor-screenshot.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/survivor-screenshot.png new file mode 100755 index 00000000..0bd8eacf Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/survivor-screenshot.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/tiny_grid.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/tiny_grid.png new file mode 100755 index 00000000..679051dc Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/tiny_grid.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/wedge.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/wedge.png new file mode 100755 index 00000000..ad1c4884 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/wedge.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/wheelsofsteel-full-ui.jpg b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/wheelsofsteel-full-ui.jpg new file mode 100755 index 00000000..d758823d Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/wheelsofsteel-full-ui.jpg differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/wheelsofsteel-full-ui.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/wheelsofsteel-full-ui.png new file mode 100755 index 00000000..568e9850 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/wheelsofsteel-full-ui.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/wheelsofsteel-single-deck-256.jpg b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/wheelsofsteel-single-deck-256.jpg new file mode 100755 index 00000000..2d8aeaf7 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_image/wheelsofsteel-single-deck-256.jpg differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/1hz-10khz-sweep.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/1hz-10khz-sweep.mp3 new file mode 100755 index 00000000..226ac1e9 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/1hz-10khz-sweep.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/440hz.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/440hz.mp3 new file mode 100755 index 00000000..e2dd5e05 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/440hz.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/880hz.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/880hz.mp3 new file mode 100755 index 00000000..756e8d93 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/880hz.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/background0.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/background0.mp3 new file mode 100755 index 00000000..3816dd76 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/background0.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/background1.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/background1.mp3 new file mode 100755 index 00000000..9e9c6380 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/background1.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/background2.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/background2.mp3 new file mode 100755 index 00000000..ec251cf2 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/background2.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/bass.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/bass.mp3 new file mode 100755 index 00000000..adc281f9 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/bass.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/button-0.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/button-0.mp3 new file mode 100755 index 00000000..243c3e5d Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/button-0.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/button-1.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/button-1.mp3 new file mode 100755 index 00000000..a2833fdb Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/button-1.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/click-high.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/click-high.mp3 new file mode 100755 index 00000000..afb09d74 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/click-high.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/click-low.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/click-low.mp3 new file mode 100755 index 00000000..9cbe8fe2 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/click-low.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/coins.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/coins.mp3 new file mode 100755 index 00000000..f0c2401d Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/coins.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/fancy-beer-bottle-pop.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/fancy-beer-bottle-pop.mp3 new file mode 100755 index 00000000..44988742 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/fancy-beer-bottle-pop.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/going_outside.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/going_outside.mp3 new file mode 100755 index 00000000..75558317 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/going_outside.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/mak.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/mak.mp3 new file mode 100755 index 00000000..9bc9af3a Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/mak.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/mouseover.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/mouseover.mp3 new file mode 100755 index 00000000..9e9a4f41 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/mouseover.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/mouseover2.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/mouseover2.mp3 new file mode 100755 index 00000000..9273f99f Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/mouseover2.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/mouseover3.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/mouseover3.mp3 new file mode 100755 index 00000000..93d04be6 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/mouseover3.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/office_lobby.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/office_lobby.mp3 new file mode 100755 index 00000000..8432fa7a Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/office_lobby.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/rain.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/rain.mp3 new file mode 100755 index 00000000..86050cbd Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/rain.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/select.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/select.mp3 new file mode 100755 index 00000000..9f9c7112 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/select.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/sine, square, sawtooth, rando.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/sine, square, sawtooth, rando.mp3 new file mode 100755 index 00000000..a649164e Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/sine, square, sawtooth, rando.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/walking.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/walking.mp3 new file mode 100755 index 00000000..45f660ea Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/_mp3/walking.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-1/css/animation.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-1/css/animation.css new file mode 100755 index 00000000..1c3f93be --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-1/css/animation.css @@ -0,0 +1,74 @@ +body { + font-size:75%; +} + +h1, h2, h3 { + font:normal 3em "Helvetica Neue",helvetica,georgia,"times new roman","Arial Rounded MT Bold",verdana,tahoma,arial,"sans serif"; + font-weight:normal; + margin-bottom:0px; +} + +h1, h2 { + letter-spacing:-1px; /* zomg web x.0! ;) */ +} + +h1, h2, h3 { + padding-bottom:1px; + margin-bottom:0.25em; +} + +h1 { + margin-top:0px; + margin-bottom:0px; + background-color:#666; + color:#ccc; + margin-left:-5px; + padding-left:5px; + padding-right:5px; + padding-bottom:5px; +} + +h1, +h1 a { + color:#fff; + text-decoration:none; +} + +h1 a:hover { + text-decoration:underline; +} + +h2 { + font-size:2em; + margin-top:1em; + background-color:#aaa; + color:#fff; + padding:5px; + margin-left:-5px; + min-width:23em; +} + +h3 { + font-size:1.65em; + margin-top:0.5em; + margin-bottom:0.25em; + color:#333; + min-width:28em; +} + +h3 a { + font-size:small; +} + +h4 { + color:#444; +} +p { + font:normal 1em/2em verdana,tahoma,arial,"sans serif"; +} + +.balls img { + position:absolute; + width:12px; + height:12px; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-1/image/ball.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-1/image/ball.gif new file mode 100755 index 00000000..65bb5399 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-1/image/ball.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-1/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-1/index.html new file mode 100755 index 00000000..9997f53d --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-1/index.html @@ -0,0 +1,46 @@ + + + + + + + + + + +
+ +

Interval-based animation (with sound)

+ +

+ Click + drag for fun. +

+ +

Speeding Up ExternalInterface: Keep .swf in view

+ +

SoundManager 2 now incorporates a "high performance" mode, which has been shown to noticeably improve timing and frequency of flash callbacks. This is important for timing, reducing delay between a JS call and the sound being played, etc.

+ +

To reduce audio delay and timing issues from slow JS/Flash communication, SM2 will try to ensure that the flash movie is visible on screen at all times. If hidden or otherwise off-screen, Flash will be given lower priority and thus JS/flash "lag" (ie., delay) will be introduced when trying to play audio "in sync."

+ +

Generally, positioning the flash movie using position:fixed and bottom/left or bottom/right 0px is the less-intrusive option.

+ +

+ Throw from mouse +

+

+ + +

+ + +

Sound source: "Acclivity", freesound.org

+ +
+ +
+ +
+ + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-1/script/animation.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-1/script/animation.js new file mode 100755 index 00000000..2228c86c --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-1/script/animation.js @@ -0,0 +1,190 @@ +var balls = []; +var canvasX = 0; +var canvasY = 0; +var timer = null; +var m_lastX = 0; +var m_lastY = 0; +var M_SPACE = 24; +var B_VMIN = 5; +var B_VMAX = 5; +var B_WIDTH = 13; +var B_HEIGHT = 13; +var useMouse = null; +var ballSound = null; +var ballPopSound = null; + +function rnd(n) { + return Math.random()*n; +} + +function rndI(n) { + return parseInt(rnd(n)); +} + +function createBall(oParent) { + oParent.appendChild(balls[0].cloneNode(true)); + initBall(balls[balls.length-1],balls.length); +} + +function createBallAtMouse(e) { + e = e?e:event; + createBall(document.getElementById('ball-container')); + with (balls[balls.length-1]) { + _x = e.clientX; + _y = e.clientY; + if (useMouse.checked != false) { + _vX = (m_lastX-e.clientX)*-0.7; + _vY = (m_lastY-e.clientY)*-0.7; + } else { + _vX = 0; + _vY = 0; + } + } + moveBall(balls[balls.length-1]); +} + +function initBall(oBall,i) { + oBall._id = 'ball'+i; + oBall._active = true; + oBall._x = rnd(canvasX); + oBall._y = rnd(canvasY); + oBall._vX = B_VMIN+rnd(B_VMAX)*(Math.random()>0.5?1:-1); + oBall._vY = B_VMIN+rnd(B_VMAX); + oBall.style.display = 'block'; +} + +function moveBall(oBall) { + oBall._x += oBall._vX; + oBall._y += (oBall._vY++); // gravity! + var bounce = false; + if ((oBall._vX>0 && oBall._x+oBall._vX+B_WIDTH>canvasX) || (oBall._vX<0 && oBall._x+oBall._vX<0)) { + oBall._vX *= -1; + bounce = true; + } + if ((oBall._vY>0 && oBall._y+oBall._vY+B_HEIGHT>canvasY) || (oBall._vY<0 && oBall._y+oBall._vY<0)) { + // bounce on Y axis - with resistance on both axes + if (oBall._vY>0) oBall._y = canvasY-B_HEIGHT; // bounce exactly from bottom + oBall._vY *= -(oBall._vY>1?0.6:1); + bounce = true; + if (Math.abs(oBall._vX)>0.5) { + oBall._vX *= 0.85; + } else { + oBall._vX = 0; + } + if (Math.abs(oBall._vY)<=3 && Math.abs(oBall._vX==0)) { + oBall._active = false; + bounce = false; + ballPopSound.play(); + oBall.style.display = 'none'; + } + } + oBall.style.left = oBall._x+'px'; + oBall.style.top = oBall._y+'px'; + if (bounce) ballSound.play({pan:getPan(oBall._x,canvasX)}); +} + +function getPan(x,canvasX) { + var pos = x/canvasX; + var pan = null; + if (pos<=0.4) { + pan = Math.floor(-100+(pos/0.4*100)); + } else if (pos>0.4 && pos<=0.5) { + pan = 0; + } else { + pan = Math.floor(pos*100); + } + return pan; +} + +function animateStuff() { + for (var i=balls.length; i--;) { + if (balls[i]._active) moveBall(balls[i]); + } +} + +function startAnimation() { + if (!timer) timer = setInterval(animateStuff,20); + document.getElementById('b-start').disabled = true; + document.getElementById('b-stop').disabled = false; +} + +function stopAnimation() { + if (!timer) return false; + clearInterval(timer); + timer = null; + document.getElementById('b-start').disabled = false; + document.getElementById('b-stop').disabled = true; +} + +function mouseDown(e) { + e = e?e:event; + m_lastX = e.clientX; + m_lastY = e.clientY; + document.onmousemove = mouseMove; + document.onmouseup = mouseUp; + return false; +} + +function mouseMove(e) { + e = e?e:event; + if (Math.abs(e.clientX-m_lastX)>M_SPACE || Math.abs(e.clientY-m_lastY)>M_SPACE) { + createBallAtMouse(e); + m_lastX = e.clientX; + m_lastY = e.clientY; + } + return false; +} + +function mouseUp() { + document.onmousemove = null; + document.onmouseup = null; +} + +function init() { + ballSound = soundManager.createSound({ + id: 'ballSound', + url: '../animation/audio/fingerplop.mp3', + volume: 50, + multiShot: true, + autoLoad: true + }); + ballPopSound = soundManager.createSound({ + id: 'ballPopSound', + url: '../animation/audio/fingerplop2.mp3', + volume: 50, + multiShot: true, + autoLoad: true + }); + balls = document.getElementById('ball-container').getElementsByTagName('img'); + for (var i=balls.length; i--;) { + initBall(balls[i],i); + } + useMouse = document.getElementById('useMouse'); + useMouse.checked = true; + getWindowCoords(); + startAnimation(); + document.onmousedown = mouseDown; +} + +// I know this is kinda broken in Opera. +getWindowCoords = (navigator.userAgent.toLowerCase().indexOf('opera')>0||navigator.appVersion.toLowerCase().indexOf('safari')!=-1)?function() { + canvasX = window.innerWidth; + canvasY = window.innerHeight; +}:function() { + canvasX = document.documentElement.clientWidth||document.body.clientWidth||document.body.scrollWidth; + canvasY = document.documentElement.clientHeight||document.body.clientHeight||document.body.scrollHeight; +} + +window.onresize = getWindowCoords; + +soundManager.setup({ + preferFlash: true, + flashVersion: 9, + url: '../../swf/', + useHighPerformance: true, + debugMode: false, // disable debug mode + onready: function() { + // soundManager is ready to use (create sounds and so on) + init(); + } +}); diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/bg-land.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/bg-land.png new file mode 100755 index 00000000..bf4e9961 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/bg-land.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/bg-sky.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/bg-sky.png new file mode 100755 index 00000000..24b1989c Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/bg-sky.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-10.cur b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-10.cur new file mode 100755 index 00000000..1f78e9e1 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-10.cur differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-11.cur b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-11.cur new file mode 100755 index 00000000..c559d34a Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-11.cur differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-3.cur b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-3.cur new file mode 100755 index 00000000..5864f787 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-3.cur differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-4.cur b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-4.cur new file mode 100755 index 00000000..668fba63 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-4.cur differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-5.cur b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-5.cur new file mode 100755 index 00000000..54de2c9c Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-5.cur differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-6.cur b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-6.cur new file mode 100755 index 00000000..d6c536f2 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-6.cur differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-7.cur b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-7.cur new file mode 100755 index 00000000..779af620 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-7.cur differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-8.cur b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-8.cur new file mode 100755 index 00000000..07c406e8 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-8.cur differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-9.cur b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-9.cur new file mode 100755 index 00000000..98bf3647 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-9.cur differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-shadow.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-shadow.png new file mode 100755 index 00000000..bb9b73e6 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/cursor-shadow.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/dot.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/dot.png new file mode 100755 index 00000000..7a6b6d81 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/dot.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/index.html new file mode 100755 index 00000000..9e356a6d --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2a/index.html @@ -0,0 +1,361 @@ + + +SoundManager Demo + + + + + + + + +
+ +
+ +
+
+
+
+
+ +
+
+ + +
+ +
+

SoundManager 2: JS/DOM + Sound Demo

+

Heavy DOM manipulation + Javascript Sound (see code for experimental ideas)

+
+ +

Click and drag to draw.. Noisily.

+
+ +
+ + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/audio/bonk.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/audio/bonk.mp3 new file mode 100755 index 00000000..2bce0460 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/audio/bonk.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/audio/fingerplop.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/audio/fingerplop.mp3 new file mode 100755 index 00000000..663155e7 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/audio/fingerplop.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/audio/fingerplop2.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/audio/fingerplop2.mp3 new file mode 100755 index 00000000..10f8bb28 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/audio/fingerplop2.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/css/animation.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/css/animation.css new file mode 100755 index 00000000..2764bc29 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/css/animation.css @@ -0,0 +1,36 @@ +body { + font-size:75%; + background:#667788; + color:#fff; + text-shadow:0 0 0 #fff; /* Safari nonsense */ +} + +h1, h2, h3 { + font:normal 3em "Helvetica Neue",georgia,"times new roman","Arial Rounded MT Bold",helvetica,verdana,tahoma,arial,"sans serif"; + font-weight:normal; + margin-bottom:0px; +} + + +h1 { + margin-top:0px; +} + +h1, h2 { + letter-spacing:-1px; /* zomg web x.0! ;) */ +} + +h2 { + font-size:2em; + margin-top:0.25em; +} + +p { + font:normal 1em verdana,tahoma,arial,"sans serif"; +} + +.point { + position:absolute; + width:32px; + height:32px; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/image/ball.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/image/ball.gif new file mode 100755 index 00000000..65bb5399 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/image/ball.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/image/point.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/image/point.png new file mode 100755 index 00000000..7770afc4 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/image/point.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/index.html new file mode 100755 index 00000000..e51dcf5b --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/index.html @@ -0,0 +1,21 @@ + + + + + + + + + +
+ +

SoundManager 2 demo: A Noisy Page

+

Example of sound tied to javascript/DOM event handlers

+ +

Click and drag for fun.

+ +
+ + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/script/animation.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/script/animation.js new file mode 100755 index 00000000..b80e9607 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/animation-2b/script/animation.js @@ -0,0 +1,97 @@ +soundManager.setup({ + preferFlash: true, + flashVersion: 9, + url: '../../swf/', + useHighPerformance: true, + wmode: 'transparent', + debugMode: false +}); + +var points = []; +var o = null; +var lastX = 0; +var lastY = 0; +var threshhold = 4; +var threshMax = 32; +var noise = null; +var screenX = 0; + +function doPaint(e) { + var x = (e||event).clientX; + var y = (e||event).clientY; + var diff = Math.max(Math.abs(x-lastX),Math.abs(y-lastY)); + if (diff>threshhold) { + lastX = x; + lastY = y; + points.push(new Point(x,y,Math.min(diff/(32),3))); + } + return false; +} + +function stopPaint() { + document.onmousemove = null; + document.onmouseup = null; + // soundManager.play('up'); +} + +function startPaint(e) { + // soundManager.play('down'); + document.onmousemove = doPaint; + document.onmouseup = stopPaint; + lastX = (e||event).clientX; + lastY = (e||event).clientY; + screenX = (window.innerWidth?window.innerWidth:document.documentElement.clientWidth||document.body.clientWidth); + e?e.stopPropagation():event.returnValue = false; + return false; +} + +function initPoints() { + o = document.createElement('img'); + o.src = 'image/point.png'; + o.className = 'point'; + document.onmousedown = startPaint; + document.onmouseup = stopPaint; +} + +function Point(x,y,scale) { + var self = this; + this.data = { + x: x, + y: y, + scale: scale, + scalePX: parseInt(32*scale) + } + this.o = o.cloneNode(false); + this.o.style.left = (x-(this.data.scalePX/2))+'px'; + this.o.style.top = (y-(this.data.scalePX/2))+'px'; + this.o.style.width = this.o.style.height = this.data.scalePX+'px'; + var screenX2 = parseInt(screenX/2); + noise.play({volume:parseInt(Math.min(1,scale/3)*100),pan:(x + + +SoundManager 2: Animation + Sound Demos + + + + + +
+ +

Javascript Animation + Sound Demos using SoundManager 2

+ +
    +
  1. Interval-based animation (with sound)
  2. +
  3. Smashable Christmas Lights
  4. +
  5. JS-DOM "painting" + Sound, V1
  6. +
  7. JS-DOM "painting" + Sound, V2
  8. +
+ +

External demo: A Noisy DOM - part of a Yahoo! User Interface blog post, Enhancing YUI-based Apps with Audio.

+ + + +
diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/api/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/api/index.html new file mode 100755 index 00000000..1b6b3b15 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/api/index.html @@ -0,0 +1,993 @@ + + + +SoundManager 2: Live API Demos and Code Examples + + + + + + + + + + + + + + + + +
+ +

SoundManager 2 / API Demo and Code Examples

+ +

Wondering where to start? This page has inline executable code examples using the SoundManager 2 API.

+ +

If you're wondering how to include SM2 in your page, the basic template will get you started.

+ +

SoundManager 2 Configurations

+ +

SM2's API features and behaviour can vary somewhat depending on client support, so it can be helpful to test under different configurations. The following are different configuration defaults for SoundManager 2. Clicking will change URL parameters and reload the page, causing SM2 to start up with the new options applied. Look at JS console output for details.

+ +

HTML5 options: HTML5-only mode (API default, where supported) | HTML5 + fast polling | HTML5 + prefer flash for MP3/MP4 formats | disable HTML5

+ +

Flash options: Flash 8 | Flash 9 (normal) | Flash 9 + highPerformance + fastPolling modes (higher JS callback frequency)

+ +
+ +
+ +

The soundManager.setup() method

+ +

In order to configure SoundManager 2 for use, you must first call the setup() method. The url property and an onready function callback are commonly used together here.

+ +
soundManager.setup({
+
+    // where to find the SWF files, if needed
+    url: '/path/to/swf-directory/',
+
+    onready: function() {
+      // SM2 has loaded, API ready to use e.g., createSound() etc.
+    },
+
+    ontimeout: function() {
+      // Uh-oh. No HTML5 support, SWF missing, Flash blocked or other issue
+    }
+
+});
+
+ +

SoundManager processes the onready and ontimeout queue in the order items were added. You can also add callbacks via soundManager.onready() and soundManager.ontimeout(), respectively. If you add listeners for these events after SM2 has loaded, your callback will be fired immediately.

+ +

A note about initialization

+ +

Keep in mind SoundManager's core methods (createSound, etc.) will not be available until soundManager's onready() event fires. The initialization time for SM2 can vary across browsers/platforms, and should effectively be assumed to be "asynchronous." Because of this, it is recommended you write your code to handle onready being fired either before or after window.onload().

+

If you wish to have SM2 always wait for window.onload() before calling onready() or ontimeout(), you can pass waitForWindowLoad: true to soundManager.setup().

+ +

Debug Output, disabling and minified versions

+

SoundManager 2 has debug mode enabled by default and will write to agents supporting console.log-style debugging, and/or a custom <div> element in the absence of a console.

+

To disable debug output, pass debugMode: false to soundManager.setup().

+

Alternately, you may use the no-debug, minified version of the SM2 javascript library (which has internal debug code removed, and will silently return false.)

+ +

Demo 1: Create + play a sound

+ +
var mySound = soundManager.createSound({
+ url: '../mpc/audio/CHINA_1.mp3'
+});
+mySound.play();
+ +

Creates a new sound object with a url, and calls its play() method.

+

Note: It is recommended you make one sound object per url, generally speaking, that you wish to play. Expressed another way: "Reduce, reuse, recycle."

+ +

Variant: Create + play sound with an id

+ +
soundManager.createSound({
+ id: 'mySound2',
+ url: '../mpc/audio/CHINA_1.mp3'
+});
+soundManager.play('mySound2');
+ + +

Creates a new sound object with the given id, and then calls soundManager.play(), specifying the id of the desired sound.

+ +

If omitted, an id will be automatically generated. If a sound object with the provided id already exists, the existing object will be returned.

+ +

Cases for providing your own id

+ +

The id parameter is optional, but makes sound objects easier to look up. It's also helpful when the object returned from createSound() wasn't stored, or isn't in scope. Calling soundManager.getSoundById('mySound2') will return the matching sound object, or null if none is found.

+ +

soundManager.play() and related convenience methods take an id string, and call the method on the given sound object. Thus, soundManager.play('foo') is functionally equivalent to soundManager.getSoundById('foo').play()

+ +

Reduce, reuse, recycle

+ +

Unless you need to track separate instances of a sound playing simultaneously, it's best to create and re-use one sound object for each unique sound resource (URL) you have. If you want to play a single sound multiple times, layered on top of itself in an overlapping/chorus style, look at the multiShot sound option (Flash 9 + HTML5 only).

+ +

Demo 2: Create with onfinish event handler + play with volume argument

+
var demo2Sound = soundManager.createSound({
+ url: '../mpc/audio/CHINA_1.mp3',
+ onfinish: function() {
+   soundManager._writeDebug(this.id + ' finished playing');
+ }
+});
+demo2Sound.play({
+  volume: 50
+});
+
+ +

(creates, then plays a new sound - a function is called when the sound finishes playing)

+ +

Demo 2a: Create with onload event handler

+
soundManager.createSound({
+ url: '../mpc/audio/CHINA_1.mp3',
+ // callback for when the sound has loaded
+ onload: function() {
+   soundManager._writeDebug(this.id + ' loaded');
+   this.play();
+ }
+}).load();
+ +

This creates and loads a sound, using the onload event callback to begin playback once the sound has loaded.

+ +

Demo 2b: Create and load with whileloading event handler

+
soundManager.createSound({
+ url: 'http://freshly-ground.com/data/audio/mpc/20060826%20-%20Armstrong.mp3?rnd=' + Math.random(),
+ // begin loading right away
+ autoLoad: true,
+ whileloading: function() {
+   soundManager._writeDebug(this.id + ': loading ' + this.bytesLoaded + ' / ' + this.bytesTotal);
+ }
+});
+ +

This creates and auto-loads a sound, showing load progress where applicable.

+ +

Demo 3: Play a pre-existing sound by id

+
soundManager.play('aDrumSound');
+ +

This plays an existing sound made earlier using soundManager.createSound(), specifying an id parameter of aDrumSound.

+

Alternately, you can reference a sound by id and call methods directly on the object itself - for example, soundManager.getSoundById('aDrumSound').play();

+ +

Demo 4a: Play a sequence of sounds via onfinish, with multiShot (Flash 9 + HTML5 only)

+
soundManager.play('aDrumSound', {
+  // allow onfinish() to fire for each "shot", instead of only last shot
+  multiShotEvents: true,
+  onfinish: function() {
+    soundManager.play('aCymbalSound');
+  }
+});
+ +

This will play an existing sound (created in-page), and uses the onfinish() callback to play a second, pre-existing sound.

+

Also note that the button can be clicked multiple times, and the sound will be "layered" as multiShot is enabled for both of these sounds when using Flash 9 or HTML5. An onfinish event will also fire as each sound finishes.

+

Bug/behaviour note: Whenever "play" is called on a SMSound object, any parameters passed in will apply to all currently-playing instances of the sound if multiShot is allowed. For example, the onfinish handler from demo 4a will apply to demo 3 if 4a is started while 3 is still playing.

+

* Multishot is Flash 9+ and HTML5 only.

+ +

Demo 4b: Create and play a sequence of new sounds via onfinish()

+
soundManager.createSound({
+ id: 'aBassDrum',
+ url: '../mpc/audio/AMB_BD_1.mp3',
+ multiShot: false,
+ // when the first sound finishes...
+ onfinish: function() {
+   // create and play the second.
+   soundManager.createSound({
+     id: 'aRimSound',
+     url: '../mpc/audio/AMB_RIM1.mp3'
+   }).play();
+ }
+});
+soundManager.play('aBassDrum');
+ +

This will create and play a new sound, using the onfinish() callback to create and play a second, new sound.

+

Note that createSound() will return an existing sound object if one already exists with the given id. You can test this by running the demo more than once.

+ +

Demo 4c: Looping a sound (conventional, onfinish()-based)

+
var s = soundManager.createSound({
+  id: 'hhCymbal',
+  url: '../mpc/audio/AMB_HHOP.mp3'
+});
+
+function loopSound(sound) {
+  sound.play({
+    onfinish: function() {
+      loopSound(sound);
+    }
+  });
+}
+
+loopSound(s);
+
+ + | +

Note that there are issues with seamlessly-looping sounds, it is "close, but not perfect" with Flash 8/9 at this point.

+ +

Demo 4d: Looping a sound (loops parameter method)

+
var s = soundManager.createSound({
+  id: 'hhCymbal',
+  url: '../mpc/audio/AMB_HHOP.mp3'
+});
+
+s.play({
+  loops: 3
+});
+
+ + | +

Looping is possible as shown above using Flash 9. With flash 8, the sound must be preloaded before looping can begin - eg. autoLoad: true, onload: function() { this.play{loops: 3} }. For tighter looping, see See Seamless Looping MP3 in Flash for further details.

+ +

HTML5 support note: Native HTML5 looping is infinite when enabled, and does not support arbitrary loop counts. For now, consider using your own function with onfinish() -> play() if you want to loop a sound a certain number of times. Refer to the above onfinish() example for a basic idea.

+ +

Demo 4e: Sound timing notifications using onPosition()

+
var s = soundManager.getSoundById('aCymbalSound'); // existing sound object
+
+// register some listeners (only do this once, they will work for subsequent plays)
+
+if (typeof addedListeners === 'undefined') {
+  addedListeners = true;
+
+  s.onPosition(500, function(eventPosition) { // fire at 0.5 seconds
+    soundManager._writeDebug('Sound ' + this.id + ' has reached position ' + eventPosition);
+  });
+
+  s.onPosition(1000, function(eventPosition) { // fire at 1 second
+    soundManager._writeDebug('Sound ' + this.id + ' has reached position ' + eventPosition);
+  });
+}
+
+s.play({
+  multiShot: false,
+  whileplaying: function() {
+    // demo only: show sound position while playing, for context
+    soundManager._writeDebug('position = ' + this.position);
+  }
+});
+
+ + +

onPosition() allows you to add an event listener for a given time (in miliseconds, watching the position property); the event fires when that time has been reached while a sound is playing.

+

Note that for multiShot cases, the listeners will only fire for the original (first) shot because its position is the only one that is tracked within Flash.

+ +

Demo 4f: Sound timing with onPosition() and clearOnPosition()

+
var s = soundManager.getSoundById('aCymbalSound'); // existing sound object
+
+// clear listeners from prior demo, if they were assigned...
+
+if (typeof addedListeners !== 'undefined') {
+
+  soundManager._writeDebug('Removing previous demo listeners...');
+  s.clearOnPosition(500); // remove 500 msec listener
+  s.clearOnPosition(1000); // remove 1000 msec listener
+
+}
+
+s.onPosition(750, function(eventPosition) { // fire at 0.75 seconds
+
+  soundManager._writeDebug('Sound ' + this.id + ' has reached position ' + eventPosition);
+  // and now, remove the listener using the eventPosition specified in this callback
+  // so next time the sound plays, this listener will not fire
+  this.clearOnPosition(eventPosition);
+
+});
+
+s.play({
+  whileplaying: function() {
+    // demo only: show sound position while playing, for context
+    soundManager._writeDebug('position = ' + this.position);
+  },
+  onfinish: function() {
+    // when the sound finishes, play it once more to show that the listener does not fire.
+    soundManager._writeDebug('Playing once more, onPosition() should not fire');
+    this.play({
+      onfinish: function() {
+        soundManager._writeDebug('"' + this.id + '" finished.');
+      }
+    });
+  }
+});
+
+ + +

When onPosition() is used, a listener is added and a callback is fired when the sound reaches the desired position. To remove the listener, clearOnPosition() is called using the same position value.

+ +

Demo 4g: Sound splicing / sampling with from: and to: parameters

+
var spliceDemo = soundManager.createSound({
+  id: 'spliceSound',
+  url: '../mpc/audio/AMB_HHOP.mp3'
+});
+
+// optional: stop before re-starting sound (covers overlapping play attempts)
+spliceDemo.stop();
+
+spliceDemo.play({
+  // start position
+  from: 500,
+  // end position
+  to: 1200,
+  onstop: function() {
+    soundManager._writeDebug('sound stopped at position ' + this.position);
+    // note that the "to" target may be over-shot by 200+ msec, depending on polling and other factors.
+  }
+});
+
+ + | +

By specifying "from" and "to" parameters to methods like play() and createSound(), you may play a sample (or segment) of audio from a larger file. An audio "sprite" of one file with many sounds is one way to think of this. Given timing accuracy of the "to" target may vary a lot, it is safest to have perhaps 500-msec gaps of silence between distinct sounds to ensure that no accidental overlaps occur.

+

To tighten the accuracy of the "to" timing, try using soundManager.useHighPerformance.

+

If HTML5 audio is being used, the sound should begin playing once a "canplay" event fires (after a connection has established), and the sound will then seek to the correct start position. When using flash, the whole audio file will be loaded before playback can begin.

+

Given limitations, Flash 9's multiShot (chorusing) mode does not apply here. If you wish to trigger a sound numerous times, call stop() before play() to reset the sound each time, or make multiple sound objects that reuse the same sprite.

+ +

Demo 4g: "Fitter, Happier" example using from: and to: parameters

+ +

+ Fitter, Happier waveform showing sound samples +

+ +

Portions of a sound can be played by specifying from and to when calling play(). This can be useful for performance, i.e., having an "audio sprite" that loads in a single HTTP request.

+ +
var fhDemo = soundManager.createSound({
+  url: 'http://freshly-ground.com/data/audio/sm2/fitter-happier-64kbps.mp3'
+});
+
+function playFromTo(nFrom, nTo) {
+  fhDemo.stop(); // optional: stop before re-starting sound (covers overlapping play attempts)
+  fhDemo.play({
+    from: nFrom,
+    to: nTo,
+    onstop: function() {
+      soundManager._writeDebug('sound stopped at position ' + this.position);
+      // note that the "to" target may be over-shot by 200+ msec, depending on polling and other factors.
+    }
+  });
+}
+
+function fitterHappier() {
+  playFromTo(128, 2100);
+}
+
+function moreProductive() {
+  playFromTo(2500, 3850);
+}
+
+function comfortable() {
+  playFromTo(4275, 5200);
+}
+
+function notDrinkingTooMuch() {
+  playFromTo(5500, 7250);
+}
+
+function regularExerciseAtTheGymThreeDaysAWeek() {
+  playFromTo(7500, 11500);
+}
+
+function atEase() {
+  // interesting edge case: flash may cut off sound near end.
+  // workarounds: use play({position:x}), or specify "to" time > duration eg. 99999.
+  playFromTo(11600, 99999);
+}
+
+// demo-specific hack: assign to the window object, so demo buttons work
+window.fitterHappier = fitterHappier;
+window.moreProductive = moreProductive;
+window.comfortable = comfortable;
+window.notDrinkingTooMuch = notDrinkingTooMuch;
+window.regularExerciseAtTheGymThreeDaysAWeek = regularExerciseAtTheGymThreeDaysAWeek;
+window.atEase = atEase;
+
+ + + + | | | | | + +

Demo 5a: Set sound parameters, then play

+
// predefined/preloaded sound
+var sound = soundManager.getSoundById('chinaCymbal');
+
+// volume at 85%
+sound.setVolume(85);
+
+// 0.25 seconds into sound
+sound.setPosition(250);
+
+// pan 75% to the left
+sound.setPan(-75);
+
+// begin playback with new settings
+sound.play();
+
+ +

This will set the position and pan of an existing, pre-loaded sound, then play it. Where applicable, these settings become the new defaults for the sound.

+ +

play() with sound options

+
var sound = soundManager.getSoundById('chinaCymbal');
+sound.play({
+  volume: 100,
+  position: 0,
+  pan: 75
+});
+

This is an elegant way of playing a sound with specific parameters "just one time", overriding the defaults applied when the sound was created.

+ +

Note that if planning to layer sounds with multiShot (Flash 9 only), this variant method will give best results as each new "channel" is started with parameters.

+ +

Demo 5b: Global sound muting

+

If not passed a sound ID, soundManager.mute() will mute all existing and newly-created sounds. soundManager.unmute() can also be passed a sound ID, and performs the inverse either on a single sound or all sounds.

+

In this demo, all sounds are globally muted and unmuted a few times. Different parameters are used to help audibly separate the sounds.

+
soundManager.mute(); // mute all sounds
+
+soundManager.createSound({
+ id: '880hz',
+ url: '../_mp3/880hz.mp3',
+ autoLoad: true,
+ onload: function() {
+   // soundManager.mute(); // mute all sounds
+   // play (muted) cymbal sound..
+   this.play({
+     volume: 75, // volume for when un-muted
+     pan: -75,   // mostly on left channel 
+     // .. and clean-up afterwards
+     onfinish: function() {
+       this.destruct();
+     }
+   });
+
+   this.setVolume(25); // new volume for when un-muted..
+
+   soundManager.play('s440hz', {
+     pan: 75,
+     onfinish: function() {
+       document.getElementById('btn-d5b').disabled = false;
+     }
+   });
+
+   // once playing, toggle all sounds some more
+   setTimeout(soundManager.unmute, 500);
+   setTimeout(soundManager.mute, 1000);
+   setTimeout(soundManager.unmute, 1500);
+   setTimeout(soundManager.mute, 2000);
+   setTimeout(soundManager.unmute, 2500);
+ }
+});
+ + + +

Demo 5c: Per-object sound muting

+
soundManager.createSound({
+ id: '880hz',
+ url: '../_mp3/880hz.mp3',
+ autoLoad: true,
+ onload: function() {
+   soundManager.mute('880hz'); // mute this - alternately, this.mute() would work here
+   soundManager.play('s440hz', { // play another sound to demo muting
+    onfinish: function() {
+      document.getElementById('btn-d5c').disabled = false;
+    }
+   });
+
+   // play 880hz (muted)..
+   this.play({
+     volume: 75,
+     // .. and clean-up afterwards
+     onfinish: function() {
+       this.destruct();
+     }
+   });
+
+   this.setVolume(50); // still muted, however..
+
+   // mute/unmute china cymbal some more
+   // mute sound calls: soundManager.mute('880hz'), or soundManager.getSoundById('880hz').mute();
+   setTimeout(this.unmute, 250);
+   setTimeout(this.mute, 500);
+   setTimeout(this.unmute, 750);
+   setTimeout(this.mute, 1000);
+   setTimeout(this.unmute, 1250);
+ }
+});
+ + + +

Demo 6: Create, play, unload and destroy a sound

+
var foo = soundManager.createSound({
+ id: 'fooSound',
+ url: '../mpc/audio/AMB_BD_1.mp3'
+});
+
+// soundManager.play('fooSound');
+
+// (Some time later on...)
+// soundManager.unload('fooSound'); - release the loaded MP3
+// soundManager.destroySound('fooSound'); - destroy the sound, freeing up memory etc. Also calls unload().
+
+// Alternate (demo) approach, call methods directly on sound object itself:
+foo.play({
+ onfinish: function() {
+   // once sound has loaded and played, unload and destroy it.
+   this.destruct(); // will also try to unload before destroying.
+ }
+});
+ + + +

Demo 7: Create, manually pre-load and finally play a sound

+
var preload = soundManager.createSound({
+  id: 'preloadSound',
+  url: '../mpc/audio/AMB_HHOP.mp3'
+});
+
+// load the sound ahead of time
+preload.load({
+  // and start playing it at onload
+  onload: function() {
+    this.play();
+  }
+});
+
+ + +

Demo 8: Create and play an invalid sound (404)

+
var bad = soundManager.createSound({
+  id: 'badSound',
+  url: 'badurl.mp3',
+  onload: function(bSuccess) {
+    soundManager._writeDebug('sound '+(bSuccess?'loaded!': 'did NOT load.'));
+  }
+});
+bad.play();
+
+ + +

Demo 9: Create and destroy a sound at once (unusual crash testcase)

+
var s = soundManager.createSound({
+  url: '../mpc/audio/AMB_HHOP.mp3'
+});
+s.play();
+s.destruct();
+
+ + +

Demo 10: Sound timing (position accuracy testcase)

+

The Flash 9 version seems to resume the sound 1 msec earlier than it should, perhaps related to the timing/delay issue most noticeable on Windows.

+
var count = 0;
+var pos = -1;
+var s = soundManager.createSound({
+  url: '../mpc/audio/CHINA_1.mp3',
+  whileplaying: function() {
+    if (count == 0) {
+      if (this.position > 1000) {
+        this.pause();
+        pos = this.position;
+        count++;
+        this.resume();
+      }
+    } else if (count == 1) {
+      soundManager._writeDebug('old position: ' + pos);
+      soundManager._writeDebug('new position: ' + this.position);
+      // See that this.position is less than pos!
+      count++;
+    }
+  },
+  onfinish: function() {
+    this.destruct();
+  }
+});
+s.play();
+ + +

Demo 11: Inline whileplaying() event assignment

+

Note that when using the Flash 9 version of SM2 with Flash 9 and 10 plugins, flash/OS-related delay conditions may result in the position property being less than the duration property, even by the end of the sound.

+
var foo = soundManager.createSound({
+  url: '../mpc/audio/CRASH_1.mp3'
+});
+foo.options.whileplaying = function() {
+  soundManager._writeDebug('whileplaying(): '+this.position+' / '+this.duration);
+}
+foo.play();
+
+// note: assign .options before calling .play(), as that "bakes" the options into a play instance object.
+// the below "late" event handler assignment will have no effect on the already-playing instance.
+foo.options.onfinish = function() { soundManager._writeDebug(this.id + ' stopped.'); }
+
+ + +

Demo 12: 48 KHz MP3 sampling rate playback issue workaround

+

To work around a known "chipmunk" sampling rate issue with 48 KHz MP3s in Flash, one can apparently load a sound using Flash 9 with stream = false, and then call play() once the sound has fully-loaded. Exactly why this works is not known.

+
var fortyeight = soundManager.createSound({
+  url: 'http://freshly-ground.com/data/audio/48khz-test.mp3'
+});
+
+if (!fortyeight.loaded) {
+  // first time loading/playing
+  fortyeight.load({
+    stream: false,
+    onload: function() {
+      // sound has fully-loaded
+      this.play();
+    }
+  });
+} else {
+  // sound has already loaded
+  fortyeight.play();
+}
+
+ + +

Demo 13: autoLoad:true + play() testcase

+

Bug testcase (Flash 8 version-specific): creating a sound with autoLoad:true and immediately calling play() does not work.

+
var autoLoadTest = soundManager.createSound({
+   id: 'autoLoadTest',
+   url: getRandomMP3URL(),
+   onload: function() {
+	soundManager._writeDebug(this.id + ' loaded.');
+   },
+   onplay: function() {
+     soundManager._writeDebug('Starting sound: '+this.id);
+   },
+   autoPlay: false,
+   autoLoad: true,
+   stream: true
+  });
+  // autoLoadTest.play(); // sound will not start
+  setTimeout(autoLoadTest.play,1000); // may work with a delay?
+
+

Under Flash 8, this case does not work as expected. Even with the delay, the sound does not begin playing as soon as expected - sometimes it fires after the sound loads, in fact. For this reason, avoid using autoLoad:true if you intend to play the sound shortly after creating it when using Flash 8.

+ + +

Demo 14: autoPlay + onfinish() testcase

+

Bug testcase (Flash 8 version-specific): onfinish() does not fire with autoPlay:true

+
var sound = soundManager.createSound({
+ id: 'demo14',
+ url: '../mpc/audio/AMB_SN13.mp3',
+ onfinish: function() {
+  soundManager._writeDebug(this.id + ' finished (now destroying)');
+  // destroy this sound
+  this.destruct();
+ },
+ autoPlay: true,
+ multiShot: false
+});
+
+ + +

Demo 15: onstop() -> unload() testcase

+

Bug testcase: unload() from onstop() does not work

+
var sound16 = soundManager.createSound({
+ id: 'demo15',
+ url: getRandomMP3URL(),
+ onstop: function() {
+  soundManager.unload(this.id);
+ },
+ onload: function() {
+   soundManager._writeDebug('loaded');
+ }
+});
+sound15.play();
+setTimeout(sound15.stop, 1500);
+
+ + +

Demo 16: Buffering event handler/property example (Flash 9 only)

+

Reporting the isBuffering property of a SMSound object

+
if (soundManager.flashVersion != 8) {
+  var sound16 = soundManager.createSound({
+    id: 'demo16',
+    url: getRandomMP3URL(),
+    onbufferchange: function() {
+      soundManager._writeDebug('Buffering '+(this.isBuffering?'started': 'stopped')+'.');
+    },
+    onload: function() {
+      soundManager._writeDebug(this.id + ' loaded.');
+    }
+  });
+  sound16.play();
+}
+
+ + +

data: URIs (HTML5 only, experimental)

+

Subject to browser support, a data: URI should work when provided to a native HTML5 Audio() instance.

+

You should not use this unless you know what you're doing and are willing to rely only on HTML5 support.

+

Additionally, data: URIs appear not to work on mobile devices (iOS: iPad, iPhone in particular.)

+

IE 9 + 10 do not support WAV under HTML5 Audio(). In addition to being the only major browser lacking .WAV support, irony is not lost on the fact that MSFT co-created the WAV/RIFF spec with IBM. (See yonder.)

+ +
+
if (soundManager.html5) {
+  soundManager.createSound({
+    // explicit type, SM2 doesn't detect MIME type in data: URIs yet
+    type: 'audio/wav',
+    // view source (or console) for the full URI.
+    url: getWaveDataURI()
+  }).play();
+}
+
+ + +
+
+ + + +
+ +
+ +

+ SoundManager 2: Live API Demos + + +

+ +

See your JS console for live debug/log output.

+ +

+ Getting Started + + +

+ + + + + + + +
+
+ +
+ + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/css/cassette-tape-ui-blur-nojs.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/css/cassette-tape-ui-blur-nojs.css new file mode 100755 index 00000000..b322853a --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/css/cassette-tape-ui-blur-nojs.css @@ -0,0 +1,30 @@ +/** + * Cassette Tape UI Prototype (09/2012) + * Non-JS view + * ALPHA build / experimental state, unsupported; use at own risk + * Requires CSS3 border-radius + support + * -------------------------------------------------- + * http://www.schillmania.com/projects/soundmanager2/ + * + * Tape UI elements (spokes, reels, textures) by Brian Scates + * http://sxates.com/ + */ + +#tape-loader { + display: none; +} + +#demo-header-wrapper { + opacity: 1 !important; +} + +.tape.draggable { + top: 50%; + left: 50%; + margin: -150px 0px 0px -240px; + opacity: 1; +} + +.tape.draggable .controls { + display: none; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/css/cassette-tape-ui-blur.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/css/cassette-tape-ui-blur.css new file mode 100755 index 00000000..8e6f5cac --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/css/cassette-tape-ui-blur.css @@ -0,0 +1,395 @@ +/** + * Cassette Tape UI Prototype (09/2012) + * ALPHA build / experimental state, unsupported; use at own risk + * Requires CSS3 border-radius + support + * -------------------------------------------------- + * http://www.schillmania.com/projects/soundmanager2/ + * + * Tape UI elements (spokes, reels, textures) by Brian Scates + * http://sxates.com/ + */ + +html { + position: relative; + width: 100%; + height: 100%; + /* prevent scrollbars within the draggable case. */ + overflow: hidden; + background: #000 url(../image/demo_backgrounds/sfatnight_1600.jpg) no-repeat 0px 0px; +} + +body { + color: #fff; +} + +.tape.draggable { + position: absolute; + display: inline-block; + margin: 0px; + box-shadow: 0px 0px 16px rgba(0,0,0,0.1); + border-color: rgba(0,0,0,0.25); + background: transparent; + border: 1px solid rgba(0,0,0,0.1); +} + +.tape.draggable .rail-left, +.tape.draggable .rail-right { + /* hack: would reuse metal texture, but not dark enough due to dynamically-applied gradient. */ + display: none; +} + +.tape.draggable .reel-mask { + background-color: rgba(255,255,255,0.1); + background-color: transparent; +} + +.tape.draggable .blur-image-wrapper { + position: absolute; + left: 0px; + top: 0px; + width: 100%; + border-radius: 12px; + overflow: hidden; + z-index: -1; +} + +.tape.draggable .blur-image { + position: absolute; + left: 0px; + top: 0px; + width: 100%; + height: 100%; + border-radius: 12px; + /* hack for now */ + margin-left: 100%; + margin-right: 100%; +} + +.tape.draggable .transparency-sheet { + /* wash out everything slightly */ + position: absolute; + left: 0px; + top: 0px; + width: 100%; + background: rgba(255,255,255,0.25); + border-radius: 12px; +} + +.tape.draggable .blur-image-wrapper, +.tape.draggable .transparency-sheet { + /* fade and blur, same height */ + height: 81%; +} + +.tape.draggable .tape-shell { + background: transparent url(../image/ma-r90-metal-pattern-v2.png); + background-size: normal; +} + +.tape.draggable .tape-gradient { + background: transparent url(../image/gradient.png) no-repeat 0px 0px; + /* TODO: use a native CSS gradient. Save 2 KB image request, but maybe slower to draw? */ + /* display: none; */ +} + +.tape.draggable .tape-shell, +.tape.draggable .tape-gradient { + position: absolute; + left: 0px; + top: 0px; + width: 100%; + height: 100%; + border-radius: 12px; + /** + * TODO: consider using webkit-mask-box-image where supported, and canvas otherwise? + */ + /* + -webkit-mask-box-image: url(../image/ma-r90-mask.png); + -moz-mask-image: url(../image/ma-r90-mask.png); + -moz-mask-image: -moz-linear-gradient(bottom, rgba(255,0,0,1), rgba(0,255,0,1), rgba(0,0,255,0), rgba(128,0,128,0)); + -moz-mask-size: 480px 300px; + */ +} + +.tape.draggable .tape-pad-holder { + background: transparent; + bottom: 0px; + height: 7px; +} + +.tape.draggable .tape-pad { + background: rgba(96,48,0,0.9); + height: 100%; + top: -1px; +} + +.tape.draggable .tape-pad-line { + display: block; + border-top: 1px solid rgba(64,32,0,0.5); + bottom: auto; + top: 0px; + margin-left: -46%; + width: 188%; +} + +.tape.draggable .controls { + top: 0px; +} + +/* a few loading transition bits */ + +.tape.draggable { + opacity: 0; +} + +.tape.draggable.ready { + opacity: 1; +} + +.tape.draggable.dropin { + -o-animation: dropin 0.75s; + -moz-animation: dropin 0.75s; + -ms-animation: dropin 0.75s; + -webkit-animation: dropin 0.75s; +} + +@-o-keyframes dropin { + 0% { + opacity: 0; + -o-transform: scale(2); + -o-animation-timing-function: ease-out; + } + 33% { + opacity: 0.5; + -o-transform: scale(0.85); + -o-animation-timing-function: ease-in-out; + } + 55% { + opacity: 1; + -o-transform: scale(1); + -o-animation-timing-function: ease-in-out; + } + 77% { + opacity: 1; + -o-transform: scale(0.98); + -o-animation-timing-function: ease-in-out; + } + 100% { + opacity: 1; + -o-transform: scale(1); + -o-animation-timing-function: ease-in-out; + } +} + +@-moz-keyframes dropin { + 0% { + opacity: 0; + -moz-transform: scale3d(2, 2, 1); + -moz-animation-timing-function: ease-out; + } + 33% { + opacity: 0.5; + -moz-transform: scale3d(0.85, 0.85, 1); + -moz-animation-timing-function: ease-in-out; + } + 55% { + opacity: 1; + -moz-transform: scale3d(1.05, 1.05, 1); + -moz-animation-timing-function: ease-in-out; + } + 77% { + opacity: 1; + -moz-transform: scale3d(0.98, 0.98, 1); + -moz-animation-timing-function: ease-in-out; + } + 100% { + opacity: 1; + -moz-transform: scale3d(1, 1, 1); + -moz-animation-timing-function: ease-in-out; + } +} + +@-ms-keyframes dropin { + 0% { + opacity: 0; + -ms-transform: scale3d(2, 2, 1); + -ms-animation-timing-function: ease-out; + } + 33% { + opacity: 0.5; + -ms-transform: scale3d(0.85, 0.85, 1); + -ms-animation-timing-function: ease-in-out; + } + 55% { + opacity: 1; + -ms-transform: scale3d(1.05, 1.05, 1); + -ms-animation-timing-function: ease-in-out; + } + 77% { + opacity: 1; + -ms-transform: scale3d(0.98, 0.98, 1); + -ms-animation-timing-function: ease-in-out; + } + 100% { + opacity: 1; + -ms-transform: scale3d(1, 1, 1); + -ms-animation-timing-function: ease-in-out; + } +} + +@-webkit-keyframes dropin { + 0% { + opacity: 0; + -webkit-transform: scale3d(2, 2, 1); + -webkit-animation-timing-function: ease-out; + } + 33% { + opacity: 0.5; + -webkit-transform: scale3d(0.85, 0.85, 1); + -webkit-animation-timing-function: ease-in-out; + } + 55% { + opacity: 1; + -webkit-transform: scale3d(1.05, 1.05, 1); + -webkit-animation-timing-function: ease-in-out; + } + 77% { + opacity: 1; + -webkit-transform: scale3d(0.98, 0.98, 1); + -webkit-animation-timing-function: ease-in-out; + } + 100% { + opacity: 1; + -webkit-transform: scale3d(1, 1, 1); + -webkit-animation-timing-function: ease-in-out; + } +} + +.tape.draggable .blur-image-wrapper { + opacity: 0; + -moz-transition: opacity 0.1s ease-out; + -webkit-transition: opacity 0.1s ease-out; + transition: opacity 0.1s ease-out; +} + +.tape.draggable.ready .blur-image-wrapper { + opacity: 1; +} + +.tape.draggable { + -moz-transition: -moz-transform 0.1s ease-out; + -moz-transform: scale3d(1, 1, 1); + -ms-transition: -ms-transform 0.1s ease-out; + -ms-transform: scale3d(1, 1, 1); + -o-transition: -o-transform 0.1s ease-out; + -o-transform: scale(1); + -webkit-transition: -webkit-transform 0.1s ease-out; + -webkit-transform: scale3d(1, 1, 1); +} + +.tape.draggable.dragging { + -ms-transform: scale3d(1.025, 1.025, 1); + -moz-transform: scale3d(1.025, 1.025, 1); + -o-transform: scale(1.025); + -webkit-transform: scale3d(1.025, 1.025, 1); +} + +.tape.draggable.dropping { + -o-animation: dragdrop 0.5s; + -ms-animation: dragdrop 0.5s; + -moz-animation: dragdrop 0.5s; + -webkit-animation: dragdrop 0.5s; +} + +@-ms-keyframes dragdrop { + 0% { + -ms-transform: scale3d(1.025, 1,025, 1); + -ms-animation-timing-function: ease-in-out; + } + 33% { + -ms-transform: scale3d(0.99, 0.99, 1); + -ms-animation-timing-function: ease-in-out; + } + 55% { + -ms-transform: scale3d(1.005, 1.005, 1); + -ms-animation-timing-function: ease-in-out; + } + 77% { + -ms-transform: scale3d(0.997, 0.997, 1); + -ms-animation-timing-function: ease-in-out; + } + 100% { + -ms-transform: scale3d(1, 1, 1); + -ms-animation-timing-function: ease-in-out; + } +} + +@-moz-keyframes dragdrop { + 0% { + -moz-transform: scale3d(1.025, 1,025, 1); + -moz-animation-timing-function: ease-in-out; + } + 33% { + -moz-transform: scale3d(0.99, 0.99, 1); + -moz-animation-timing-function: ease-in-out; + } + 55% { + -moz-transform: scale3d(1.005, 1.005, 1); + -moz-animation-timing-function: ease-in-out; + } + 77% { + -moz-transform: scale3d(0.997, 0.997, 1); + -moz-animation-timing-function: ease-in-out; + } + 100% { + -moz-transform: scale3d(1, 1, 1); + -moz-animation-timing-function: ease-in-out; + } +} + +@-o-keyframes dragdrop { + 0% { + -o-transform: scale(1.025); + -o-animation-timing-function: ease-in-out; + } + 33% { + -o-transform: scale(0.99); + -o-animation-timing-function: ease-in-out; + } + 55% { + -o-transform: scale(1.005); + -o-animation-timing-function: ease-in-out; + } + 77% { + -o-transform: scale(0.997); + -o-animation-timing-function: ease-in-out; + } + 100% { + -o-transform: scale(1); + -o-animation-timing-function: ease-in-out; + } +} + + +@-webkit-keyframes dragdrop { + 0% { + -webkit-transform: scale3d(1.025, 1,025, 1); + -webkit-animation-timing-function: ease-in-out; + } + 33% { + -webkit-transform: scale3d(0.99, 0.99, 1); + -webkit-animation-timing-function: ease-in-out; + } + 55% { + -webkit-transform: scale3d(1.005, 1.005, 1); + -webkit-animation-timing-function: ease-in-out; + } + 77% { + -webkit-transform: scale3d(0.997, 0.997, 1); + -webkit-animation-timing-function: ease-in-out; + } + 100% { + -webkit-transform: scale3d(1, 1, 1); + -webkit-animation-timing-function: ease-in-out; + } +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/css/cassette-tape-ui.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/css/cassette-tape-ui.css new file mode 100755 index 00000000..4dac4132 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/css/cassette-tape-ui.css @@ -0,0 +1,832 @@ +/** + * Cassette Tape UI Prototype (09/2012) + * ALPHA build / experimental state, unsupported; use at own risk + * Requires CSS3 border-radius + support + * -------------------------------------------------- + * http://www.schillmania.com/projects/soundmanager2/ + * + * Tape UI elements (spokes, reels, textures) by Brian Scates + * http://sxates.com/ + */ + +@font-face { + font-family: 'JustAnotherHandRegular'; + src: url('../font/justanotherhand-webfont.eot'); + src: url('../font/justanotherhand-webfont.eot?#iefix') format('embedded-opentype'), + url('../font/justanotherhand-webfont.woff') format('woff'), + url('../font/justanotherhand-webfont.ttf') format('truetype'); + font-weight: normal; + font-style: normal; +} + +.tape { + position: relative; + display: inline-block; + width: 480px; + height: 300px; + border: 1px solid rgba(0,0,0,0.1); + cursor: pointer; + margin: 0.5em; + z-index: 1; +} + +.tape, +.tape .rail-middle { + border-radius: 12px; +} + +.tape .rail-middle { + border-top-left-radius: 0px; + border-top-right-radius: 0px; +} + +.tape .left, +.tape .right { + position: absolute; + top: 45%; +} + +.tape .left { + /* the left side */ + left: 29%; +} + +.tape .right { + /* the right side */ + left: 71%; +} + +.tape .window { + position: absolute; + top: 11%; + left: 0px; + width: 100%; + height: 69%; + background: rgba(0,0,0,0.033); +} + +.tape .reel, +.tape .spokes { + border-radius: 100%; +} + +.tape .spokes { + width: 93px; + height: 93px; +} + +.tape .reel { + width: 91px; + height: 91px; + background: transparent url(../image/tape-texture.png) no-repeat 50% 50%; + border: 76px solid transparent; + border-radius: 100%; + margin-left: -121px; + margin-top: -121px; +} + +.tape .reel-mask { + position: absolute; + top: 2.4%; + width: 256px; + height: 256px; + background: #fff; + border-radius: 100%; + margin-left: -128px; + display: none\9; /* IE 8 */ +} + +.tape .reel.right { + border-width: 0px; + margin-left: -45px; + margin-top: -45px; +} + +.tape .spokes { + margin-left: -46px; + margin-top: -46px; + background: transparent url(../image/tape-spokes-sxates.png) no-repeat 50% 50%; + background-size: 100% 100%; + z-index: 5; +} + +.tape.dark .spokes { + /* hack: override */ + background-color: #ccc; +} + +.tape .spokes-overlay { + position: absolute; + top: 50%; + left: 50%; + width: 160px; + height: 160px; + background: #fff; + border-radius: 100%; + margin: -80px 0px 0px -80px; + background: transparent url(../image/tape-reel.png) no-repeat 50% 50%; + background-size: contain; +} + +.tape.clear .spokes { + background: transparent url(../image/spool-metal-black.png) no-repeat 50% 50%; +} + +.tape.clear .spokes.right { + background: transparent url(../image/spool-metal.png) no-repeat 50% 50%; +} + +.tape .label { + position: absolute; + top: 59%; + left: 11%; + width: 78.5%; + height: 16%; + background-color: #fff; + background-color: rgba(0,0,0,0.1); + border-radius: 5px; + text-indent: 0.25em; + font: normal 36px JustAnotherHandRegular, helvetica, sans-serif; + line-height: 140%; + color: #111; + text-shadow: 0px 1px 0px rgba(255,255,255,0.5); + box-shadow: 1px 1px 0px rgba(0,0,0,0.05); + /* a slightly-human element */ + /* + -moz-transform: rotate(-0.25deg); + -webkit-transform: rotate(-0.25deg); + -o-transform: rotate(-0.25deg); + transform: rotate(-0.25deg); + */ + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + z-index: 6; +} + +.tape.ma-r90 .label { + top: 62%; + width: 75%; + left: 13%; +} + +.tape.playing .tape-guide, +.tape.playing .spokes { + -moz-animation-duration: 5s; + -moz-animation-name: spin; + -moz-animation-iteration-count: infinite; + -moz-animation-timing-function: linear; + -webkit-animation-duration: 5s; + -webkit-animation-name: spin; + -webkit-animation-iteration-count: infinite; + -webkit-animation-timing-function: linear; + -ms-animation-duration: 5s; + -ms-animation-name: spin; + -ms-animation-iteration-count: infinite; + -ms-animation-timing-function: linear; + -o-animation-duration: 5s; + -o-animation-name: spin; + -o-animation-iteration-count: infinite; + -o-animation-timing-function: linear; + animation-duration: 5s; + animation-name: spin; + animation-iteration-count: infinite; + animation-timing-function: linear; +} + +.tape.playing .tape-guide { + -moz-animation-duration: 4.5s; + -webkit-animation-duration: 4.5s; + -ms-animation-duration: 4.5s; + -o-animation-duration: 4.5s; + animation-duration: 4.5s; + z-index: 2; +} + +.tape.stopped .tape-guide, +.tape.stopped .spokes { + -moz-animation: none; + -webkit-animation: none; + -ms-animation: none; + -o-animation: none; + animation: none; +} + +.tape .reel.right, +.tape .spokes.right { + -moz-animation-duration: 3.5s; + -webkit-animation-duration: 3.5s; + -ms-animation-duration: 3.5s; + -o-animation-duration: 3.5s; + animation-duration: 3.5s; +} + +.tape.clear, +.tape.clear .rail-left, +.tape.clear .rail-right { + background: #f0f0f0; +} + +.tape.clear.blue, +.tape.clear.blue .rail-left, +.tape.clear.blue .rail-right { + background: #3399cc; +} + +.tape.clear.blue .screw-tl, +.tape.clear.blue .screw-tr, +.tape.clear.blue .screw-bl, +.tape.clear.blue .screw-tm, +.tape.clear.blue .screw-bm, +.tape.clear.blue .screw-br { + border-color: rgba(0,32,96,0.5); +} + +.tape.clear.green, +.tape.clear.green .rail-left, +.tape.clear.green .rail-right { + background: #33cc33; +} + +.tape.clear.blue .window { + background: rgba(0,0,0,0.075); +} + +.tape.clear .label { + background: rgba(255,255,255,0.9); +} + +.tape.texture .rail-middle { + /* background: transparent url(../image/body-texture-strips.png); */ + background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAACCAYAAAC3zQLZAAAAH0lEQVR42u3DAQ0AAAzCMGzgX+h+H6xJA9T25rza3nwCFS8u8CRhoQAAAABJRU5ErkJggg==); +} + +.tape.clear .reel.right { + border-width: 0px; +} + +@-moz-keyframes spin { + from { + -moz-transform: rotate(360deg); + } + to { + -moz-transform: rotate(0deg); + } +} + +@-webkit-keyframes spin { + from { + -webkit-transform: rotate(360deg); + } + to { + -webkit-transform: rotate(0deg); + } +} + +@-ms-keyframes spin { + from { + -ms-transform: rotate(360deg); + } + to { + -ms-transform: rotate(0deg); + } +} + +@-o-keyframes spin { + from { + -o-transform: rotate(360deg); + } + to { + -o-transform: rotate(0deg); + } +} + +@keyframes spin { + from { + transform: rotate(360deg); + } + to { + transform: rotate(0deg); + } +} + +.screw-tl, +.screw-tr, +.screw-bl, +.screw-tm, +.screw-bm, +.screw-br { + position: absolute; + width: 3.74%; + height: 5.95%; + max-width: 32px; + max-height: 32px; + /* + background: rgba(255,255,255,0.5) url(../image/tape-screw.png) no-repeat 50% 50%; + */ + background: rgba(255,255,255,0.5) url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABAklEQVR42u2QTUvDQBCGPViRgu2lJw9Bb570kE1Dd5OQL/Ml7aE59Me8UPCXx5lSQYaNSUO9OfDAsPPuwzA3fdV13YJwiBfijXg99w7PZP430f23aACHs0OyOfFEPI+Es/M+2Yx4nMjMJlwSK0nbtoef2DL8V8puiQcbdV3vwzD8ZLjvy7FDCu9skGhrtD4aY47c9+XOwuFyXbcOwgAkA/diPE4gSdMUeZbDNhsrxHrtn7bKsgxVVaFpGhRFgTiOoTcaSilcJPR9H1EUIc/fSfaB3W6LsqyQJAm0vlAoKYvytKV8n3xT3orvaBNMEhqjEQTmekLlKXiedyWhvNl//Xl9AUz2aaW7RdRjAAAAAElFTkSuQmCC) no-repeat 50% 50%; + background-size: 100% 100%; + border: 2px solid rgba(0,0,0,0.25); + border-radius: 100%; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +/* + -moz-transform: rotate(22.5deg); + -webkit-transform: rotate(22.5deg); + transform: rotate(22.5deg); +*/ +} + +.screw-bl, +.screw-bm, +.screw-br { + border-color: rgba(0,0,0,0.5); +} + +.tape.dark .screw-tl, +.tape.dark .screw-tr, +.tape.dark .screw-bl, +.tape.dark .screw-tm, +.tape.dark .screw-bm, +.tape.dark .screw-br { +/* + background: transparent url(../image/tape-screw-dark.png) no-repeat 50% 50%; +*/ + background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAABfElEQVR42p2UW4uCUBhF5z9FNtnDZBeLytIstZvU2J0uEAT1EtQf38N+qEbOUTRhwYfuvbyfL9m2XC5xOBxwuVxwu93weDxwv9/Bmft4jBmhKBNtt9unKBZmmGUnUrbb7XC9XlPBDruCbLPZ4Hw+fwS7dISEx+MRp9NJwLKsF6ZpyjLsvoUc1us19vu9lHa7jUwmQzhH5uig6ynkZUsxDANqPg9VVTlH5cLCOJrNJirVCnS9yjkuKxWyJNDpdGCZluxYMiGfl6oWoFd18EUMBgOMx2P0+300Gg0Uf4rIZrPphIVCAbVaDd2ujcnERxD8wnU9tIwWNE2DoiiJhQKu4/IqP7tl2QkMo8VPJvlLWSwWCIJACp9ZqaShXC5xjsrR8RauVitMp1Mp9XodSk7Bdy7HOSpHR/hv4Vl83xfgi/mHLMPuSxb6/fhpjEajNLDD7ksoSIfDITzPSwKzgky6jM1mMziOEwczzKZbuefzOXhbtm2j1+tx5r7YlfoPlDTtZXQWxkUAAAAASUVORK5CYII=) no-repeat 50% 50%; + background-size: 100% 100%; + border-color: rgba(0,0,0,0.9); + opacity: 0.9; +} + +.tape.color .screw-tl, +.tape.color .screw-tr, +.tape.color .screw-bl, +.tape.color .screw-tm, +.tape.color .screw-bm, +.tape.color .screw-br { + border: 2px solid rgba(0,0,0,0.25); + box-shadow: none; +} + +.screw-tl { + top: 1.6%; + left: 1%; +} + +.screw-tr { + top: 1.6%; + right: 1%; +} + +.screw-bl { + bottom: 1.6%; + left: 1%; +} + +.screw-bm { + top: 15%; + left: 50%; + width: 3.85%; + height: 30%; + margin: 0px 0px 0px -1.925%; +} + +.screw-tm { + top: 7%; + left: 50%; + width: 3.85%; + height: 6%; + margin: 0px 0px 0px -1.925%; +} + +.screw-br { + bottom: 1.6%; + right: 1%; +} + +.rail-left, +.rail-right { + position: absolute; + bottom: 9%; + width: 3px; + height: 22.5%; + background: #ccc; + border-radius: 0px 6px 6px 0px; + border: 1px solid rgba(255,255,255,0.1); +} + +.rail-left { + left: 0px; + margin-left: -5px; + border-radius: 6px 0px 0px 6px; + border-left: none; +} + +.rail-right { + right: 0px; + margin-right: -5px; + border-right: none; +} + +.rail-middle { + position: absolute; + bottom: 0px; + width: 100%; + height: 20%; +} + +.rail-middle-outline { + position: absolute; + top: 0px; + left: 0px; + width: 66%; + height: 100%; + margin-left: 17%; + border-top: none; + border-bottom: none; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} + +.tape .rail-middle-outline { + background: transparent url(../image/rail-middle-outline.png) no-repeat 50% 100%; + background-size: contain; + z-index: 2; +} + +.hole-1, +.hole-2, +.hole-3, +.hole-4 { + position: absolute; + bottom: 5%; + background: rgba(0,0,0,0.1); + background: #fff; + width: 16px; + height: 16px; + margin: -8px 0px 0px -8px; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} + +.hole-1, +.hole-4 { + /* circles */ + border-radius: 100%; +} + +.hole-2, +.hole-3 { + width: 18px; + margin-top: -9px; + border-radius: 33%; + bottom: 15%; +} + +.hole-1 { + left: 15%; +} + +.hole-2 { + left: 30%; +} + +.hole-3 { + left: 70%; +} + +.hole-4 { + left: 85%; +} + +.tape-pad-holder { + position: absolute; + bottom: 1px; + left: 50%; + width: 15%; + height: 25%; + margin: 0px 0px 0px -7.5%; + background: #fff; +} + +.tape-pad-holder .tape-pad { + position: absolute; + bottom: 0px; + left: 50%; + width: 35%; + height: 45%; + margin: -1px 0px 0px -17.5%; + background: rgba(0,0,0,0.2); +} + +.tape.dark .tape-pad-holder .tape-pad { + background: rgba(0,0,0,0.5); +} + +.tape-pad-holder .tape-pad-line { + position: absolute; + left: 0px; + top: 50%; + width: 100%; + height: 0px; + margin-top: -2px; + border-top: 1px solid rgba(0,0,0,0.25); + /* hide by default */ + display: none; +} + +.progress-notches { + position: absolute; + top: 50%; + left: 50%; + width: 25%; + height: 2.5%; + margin: -18px 0px 0px -12.5%; + font-size: 11px; + text-align: center; + white-space: nowrap; +} + +.progress-notches div { + display: inline-block; + background: #666; + width: 2%; + margin-left: 4%; + height: 100%; + vertical-align: top; + /* due to rounding errors, this doesn't always work out. */ + width: 2px; +} + +.progress-notches div:first-of-type { + margin-left: 0px; +} + +.tape .tape-guide { + position: absolute; + top: auto; + bottom: 0px; + width: 6.875%; + height: 11%; + margin: -10.5% 0px 0px -3.4375%; + background: rgba(0,0,0,0.1) url(../image/tape-guide.png) no-repeat 50% 50%; + border-radius: 100%; +} + +.tape.color .tape-guide { + background-color: transparent; +} + +.tape .tape-guide.left { + left: 11%; +} + +.tape .tape-guide.right { + left: 89%; +} + +.tape canvas { + position: absolute; + left: 0px; + top: 0px; + width: 100%; + height: 100%; +} + +.tape canvas.connecting-tape { + visibility: hidden; +} + +.tape .tape-guide, +.tape .label { + /* stacking corrections (so tape goes through bottom holes) */ + z-index: 4; +} + +.skin-overlay { + position: absolute; + top: 0px; + left: 0px; + width: 100%; + height: 100%; + /* potentially ugly */ + background-size: contain; +} + +.tape.black-micro, +.tape.black-micro .rail-left, +.tape.black-micro .rail-right { + /* background: transparent url(../image/black-micro.png); */ + background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGAgMAAACdogfbAAAACVBMVEUWFhYbGxsiIiJSQVJ8AAAAGklEQVQIHWMQZWCYsoAhKIDBM4BBlYFBlAEAHbACv0f8IxYAAAAASUVORK5CYII=); +} + +.tape.ma-r90, +.tape.ma-r90 .rail-left, +.tape.ma-r90 .rail-right { + background: transparent url(../image/ma-r90-body-skin.png) 0px 0px no-repeat; +} + +.tape.ma-r90 .rail-right { + /* hack? */ + width: 4px; +} + +.tape.ma-r90 .rail-left, +.tape.ma-r90 .rail-right { + background-position: 0px 75%; +} + +.tape.ma-r90 .rail-middle { + background: transparent; +} + +.tape.ma-r90 .tab-left, +.tape.ma-r90 .tab-right { + position: absolute; + top: 0px; + width: 3.74%; + height: 6.1%; + max-width: 32px; + max-height: 32px; + background-color: rgb(34,142,41); +} + +.tape.ma-r90 .tab-left { + left: 5.65%; +} + +.tape.ma-r90 .tab-right { + right: 5.65%; +} + +.tape .tab-left .ridge, +.tape .tab-right .ridge { + position: absolute; + left: -10%; + top: 0px; + width: 120%; + height: 3px; + background-color: rgb(34,142,41); +} + +.tape .tab-left .notch, +.tape .tab-right .notch { + position: absolute; + left: 50%; + top: 50%; + width: 6px; + height: 7px; + margin: -3px 0px 0px -5px; + border: 2px solid rgb(33,169,43); + border-top: none; +} + +.tape .controls { + position: absolute; + left: 0px; + top: -1px; + width: 100%; + height: 20px; + margin-top: -20px; + vertical-align: bottom; + z-index: -1; + overflow: hidden; +} + +.tape .controls ul { + position: relative; + margin-top: 21px; + -moz-transition: all 0.2s ease-out; + -moz-transition-property: height, margin; + -ms-transition: all 0.2s ease-out; + -ms-transition-property: height, margin; + -o-transition: all 0.2s ease-out; + -o-transition-property: height, margin; + -webkit-transition: all 0.2s ease-out; + -webkit-transition-property: height, margin; + transition: all 0.2s ease-out; + transition-property: height, margin; +} + +.tape:hover .controls ul { + margin-top: 0px; +} + +.tape .controls .bd { + margin: 0px auto; + text-align: center; +} + +.tape .controls ul { + list-style-type: none; + padding: 0px; + font-size: 0px; /* collapse */ + background-color: rgba(255,255,255,0.9); + border-radius: 2px 2px 0px 0px; + overflow: hidden; + /* http://www.colorzilla.com/gradient-editor/ */ + background: rgb(255,255,255); /* Old browsers */ + background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(241,241,241,1) 50%, rgba(225,225,225,1) 51%, rgba(246,246,246,1) 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(50%,rgba(241,241,241,1)), color-stop(51%,rgba(225,225,225,1)), color-stop(100%,rgba(246,246,246,1))); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(241,241,241,1) 50%,rgba(225,225,225,1) 51%,rgba(246,246,246,1) 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(241,241,241,1) 50%,rgba(225,225,225,1) 51%,rgba(246,246,246,1) 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(241,241,241,1) 50%,rgba(225,225,225,1) 51%,rgba(246,246,246,1) 100%); /* IE10+ */ + background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(241,241,241,1) 50%,rgba(225,225,225,1) 51%,rgba(246,246,246,1) 100%); /* W3C */ + box-shadow: 0px 0px 2px rgba(0,0,0,0.1); +} + +#tape1 .controls.aqua ul { + /* http://www.colorzilla.com/gradient-editor/ */ + background: rgb(255,255,255); /* Old browsers */ + background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(241,241,241,1) 50%, rgba(225,225,225,1) 51%, rgba(246,246,246,1) 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(50%,rgba(241,241,241,1)), color-stop(51%,rgba(225,225,225,1)), color-stop(100%,rgba(246,246,246,1))); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(241,241,241,1) 50%,rgba(225,225,225,1) 51%,rgba(246,246,246,1) 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(241,241,241,1) 50%,rgba(225,225,225,1) 51%,rgba(246,246,246,1) 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(241,241,241,1) 50%,rgba(225,225,225,1) 51%,rgba(246,246,246,1) 100%); /* IE10+ */ + background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(241,241,241,1) 50%,rgba(225,225,225,1) 51%,rgba(246,246,246,1) 100%); /* W3C */ + box-shadow: 0px 1px 2px rgba(0,0,0,0.1); +} + +.tape .controls ul, +.tape .controls ul li a { + border: 1px solid rgba(255,255,255,0.9); +} + +.tape .controls ul li { + border: 1px solid rgba(0,0,0,0.1); + border-right: none; + border-top: none; + border-bottom: none; +} + +.tape .controls ul li:first-of-type, +.tape .controls ul li:first-of-type a { + border-left: none; +} + +.tape .controls ul { + position: relative; + border: none; + display: inline-block; + height: 20px; + overflow: hidden; +} + +.tape .controls ul li { + position: relative; + display: inline-block; + text-align: center; +} + +.tape .controls ul li a { + position: relative; + display: block; + text-decoration: none; + color: #999; + font-size: 16px; + line-height: 20px; + padding: 0px 16px; + border-left: none; + border-top: none; + border-bottom: none; +} + +.tape .controls ul:hover li a { + color: #999; + text-shadow: 0px 1px 1px #fff; +} + +.tape .controls ul li a:hover { + background: #ccc; + color: #fff; + border-color: transparent; + text-shadow: none; +} + +.tape .controls.aqua ul li a:hover { + background-color: rgba(0,0,0,0.1); + background: rgb(184,225,252); /* Old browsers */ + background: -moz-linear-gradient(top, rgba(184,225,252,1) 0%, rgba(169,210,243,1) 10%, rgba(144,186,228,1) 25%, rgba(144,188,234,1) 37%, rgba(144,191,240,1) 50%, rgba(107,168,229,1) 51%, rgba(162,218,245,1) 83%, rgba(189,243,253,1) 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(184,225,252,1)), color-stop(10%,rgba(169,210,243,1)), color-stop(25%,rgba(144,186,228,1)), color-stop(37%,rgba(144,188,234,1)), color-stop(50%,rgba(144,191,240,1)), color-stop(51%,rgba(107,168,229,1)), color-stop(83%,rgba(162,218,245,1)), color-stop(100%,rgba(189,243,253,1))); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, rgba(184,225,252,1) 0%,rgba(169,210,243,1) 10%,rgba(144,186,228,1) 25%,rgba(144,188,234,1) 37%,rgba(144,191,240,1) 50%,rgba(107,168,229,1) 51%,rgba(162,218,245,1) 83%,rgba(189,243,253,1) 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, rgba(184,225,252,1) 0%,rgba(169,210,243,1) 10%,rgba(144,186,228,1) 25%,rgba(144,188,234,1) 37%,rgba(144,191,240,1) 50%,rgba(107,168,229,1) 51%,rgba(162,218,245,1) 83%,rgba(189,243,253,1) 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, rgba(184,225,252,1) 0%,rgba(169,210,243,1) 10%,rgba(144,186,228,1) 25%,rgba(144,188,234,1) 37%,rgba(144,191,240,1) 50%,rgba(107,168,229,1) 51%,rgba(162,218,245,1) 83%,rgba(189,243,253,1) 100%); /* IE10+ */ + background: linear-gradient(to bottom, rgba(184,225,252,1) 0%,rgba(169,210,243,1) 10%,rgba(144,186,228,1) 25%,rgba(144,188,234,1) 37%,rgba(144,191,240,1) 50%,rgba(107,168,229,1) 51%,rgba(162,218,245,1) 83%,rgba(189,243,253,1) 100%); /* W3C */ + color: #fff; +} + + +.tape .controls.aqua ul li a:active { + background: #999; +} + +.tape .controls ul li:first-child a { + border-left: none; +} + +.tape .controls ul li:last-child a { + border-right: none; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/css/demo.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/css/demo.css new file mode 100755 index 00000000..01168b5b --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/css/demo.css @@ -0,0 +1,368 @@ +/** + * Cassette demo page CSS - you don't need this part. + */ + +body { + margin: 0px; + padding: 0px; + font-size: 100%; + font-family: "Helvetica Neue", Helvetica, verdana, arial, tahoma, sans-serif; + color: #fff; +} + +body#page-more { + color: #222; +} + +@font-face { + /** + * http://www.theleagueofmoveabletype.com/ostrich-sans + */ + font-family: 'ostrich-sans-roundedmedium'; + src: url('../font/ostrich-rounded-webfont.eot'); + src: url('../font/ostrich-rounded-webfont.eot?#iefix') format('embedded_opentype'), + url('../font/ostrich-rounded-webfont.woff') format('woff'), + url('../font/ostrich-rounded-webfont.ttf') format('truetype'), + url('../font/ostrich-rounded-webfont.svg#ostrich-sans_roundedmedium') format('svg'); + font-weight: normal; + font-style: normal; +} + +#demo-header-wrapper { + position: relative; + background: rgba(0,0,0,0.15); + opacity: 0; +} + +#demo-header-wrapper.visible { + opacity: 1; +} + +#demo-header-wrapper.visible { + -moz-transition: opacity 0.2s ease-in-out; + -ms-transition: opacity 0.2s ease-in-out; + -o-transition: opacity 0.2s ease-in-out; + -webkit-transition: opacity 0.2s ease-in-out; + transition: opacity 0.2s ease-in-out; +} + +#demo-header { + position: relative; + display: inline-block; + margin: 0.5em; + border-top: 2px solid #fff; + border-bottom: 2px solid #fff; + padding: 0.5em 0px; + text-shadow: 0px 1px 1px rgba(0,0,0,0.15); + white-space: nowrap; +} + +#demo-header, +.demo-subheader { + margin: 0.5em; +} + +#demo-header-wrapper.light #demo-header { + border-color: #222; + text-shadow: none; +} + +#demo-header h1, +#demo-header p, +#demo-header h2 { + font-weight: normal; + margin: 0px; + padding: 0px; +} + +#demo-header h1, +#demo-header h2 { + font-family: ostrich-sans-roundedmedium, verdana, tahoma, arial, sans-serif; +} + +#demo-header h1 { + font-size: 504%; +} + +#demo-header h2 { + font-size: 300%; +} + +#demo-header p { + background: rgba(0,0,0,0.2); + margin-bottom: 0.5em; + vertical-align: middle; + text-indent: 5px; + font-weight: 300; +} + +#demo-header-wrapper.light, +#demo-header-wrapper.light #demo-header p { + background: transparent; +} + +#demo-header-wrapper.light p { + font-size: 131%; + text-indent: 2px; +} + +#demo-header p:last-of-type { + margin-bottom: 0px; +} + +#demo-header a { + display: inline-block; + color: #fff; + text-decoration: none; + text-shadow: none; + padding: 2px; + line-height: 20px; + min-height: 20px; + background: rgba(0,0,0,0.4); +} + +#demo-header a:hover { + color: #fff; + background: rgba(32,128,255,0.5); +} + +.demo-subheader p { + max-width: 660px; + font-size: 95%; + line-height: 1.4em; +} + +.demo-subheader h2 { + font-weight: 400; + margin: 1em 0px 0px 0px; + padding: 0px; +} + +.demo-subheader h2:first-of-type { + margin-top: 0.5em; +} + +.demo-subheader p { + margin-top: 0.5em; + font-weight: 300; +} + +.demo-subheader a { + display: inline-block; + color: #222; + background-color: #f3f3f3; + text-decoration: none; + padding: 0px 3px; + margin: 0px -1px; + border-radius: 2px; + text-shadow: 0px 1px 0px #fff; +} + +.demo-subheader a:hover { + color: #fff; + background-color: rgba(32, 128, 255, 0.5); + text-shadow: none; +} + +.demo-subheader a img { + padding: 3px 0px; + vertical-align: bottom; +} + +#tape-loader { + position: absolute; + top: 50%; + left: 50%; + width: 36px; + height: 36px; + margin: -42px 0px 0px -28px; + border: 9px solid rgba(0,0,0,0.66); + border-radius: 100%; + opacity: 1; +} + +#tape-loader .spinner-box { + position: absolute; + left: -3px; + top: -3px; + width: 42px; + height: 42px; + -moz-animation-duration: 0.66s; + -moz-animation-name: spin; + -moz-animation-iteration-count: infinite; + -moz-animation-timing-function: linear; + -ms-animation-duration: 0.66s; + -ms-animation-name: spin; + -ms-animation-iteration-count: infinite; + -ms-animation-timing-function: linear; + -o-animation-duration: 0.66s; + -o-animation-name: spin; + -o-animation-iteration-count: infinite; + -o-animation-timing-function: linear; + -webkit-animation-duration: 0.66s; + -webkit-animation-name: spin; + -webkit-animation-iteration-count: infinite; + -webkit-animation-timing-function: linear; + animation-duration: 0.66s; + animation-name: spin; + animation-iteration-count: infinite; + animation-timing-function: linear; +} + +#tape-loader .spinner { + position: absolute; + left: 0px; + top: 0px; + width: 10px; + height: 10px; + border-radius: 100%; + background: rgba(255,255,255,0.75); + background: rgb(109,179,242); + background: -moz-radial-gradient(center, ellipse cover, rgba(109,179,242,1) 0%, rgba(84,163,238,1) 50%, rgba(54,144,240,1) 51%, rgba(30,105,222,1) 100%); /* FF3.6+ */ + background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%,rgba(109,179,242,1)), color-stop(50%,rgba(84,163,238,1)), color-stop(51%,rgba(54,144,240,1)), color-stop(100%,rgba(30,105,222,1))); /* Chrome,Safari4+ */ + background: -webkit-radial-gradient(center, ellipse cover, rgba(109,179,242,1) 0%,rgba(84,163,238,1) 50%,rgba(54,144,240,1) 51%,rgba(30,105,222,1) 100%); /* Chrome10+,Safari5.1+ */ + background: -o-radial-gradient(center, ellipse cover, rgba(109,179,242,1) 0%,rgba(84,163,238,1) 50%,rgba(54,144,240,1) 51%,rgba(30,105,222,1) 100%); /* Opera 12+ */ + background: -ms-radial-gradient(center, ellipse cover, rgba(109,179,242,1) 0%,rgba(84,163,238,1) 50%,rgba(54,144,240,1) 51%,rgba(30,105,222,1) 100%); /* IE10+ */ + background: radial-gradient(ellipse at center, rgba(109,179,242,1) 0%,rgba(84,163,238,1) 50%,rgba(54,144,240,1) 51%,rgba(30,105,222,1) 100%); /* W3C */ + +} + +@-moz-keyframes tape_loading { + from { + background-position: 0px 0px; + } + to { + background-position: -20px 0px; + } +} + +@-webkit-keyframes tape_loading { + from { + background-position: 0px 0px; + } + to { + background-position: -20px 0px; + } +} + + +#tape-loader, +#tape-loader.hidden { + -moz-transition: all 0.33s ease-in-out; + -moz-transition-property: opacity, -moz-transform; + -ms-transition: all 0.33s ease-in-out; + -ms-transition-property: opacity, -ms-transform; + -o-transition: all 0.33s ease-in-out; + -o-transition-property: opacity, -o-transform; + -webkit-transition: all 0.33s ease-in-out; + -webkit-transition-property: opacity, -webkit-transform; + transition: all 0.33s ease-in-out; + transition-property: opacity, transform; +} + +#tape-loader, +#tape-loader.hidden, +#tape-loader.visible.hidden { + -o-transform: scale(0); + -moz-transform: scale3d(0, 0, 1); + -webkit-transform: scale3d(0, 0, 1); + -ms-transform: scale3d(0, 0, 1); + transform: scale3d(0, 0, 1); + opacity: 0; +} + +#tape-loader.visible { + -o-transform: scale(1); + -moz-transform: scale3d(1, 1, 1); + -webkit-transform: scale3d(1, 1, 1); + -ms-transform: scale3d(1, 1, 1); + transform: scale3d(1, 1, 1); + opacity: 1; +} + +/* demo loader */ +.tape form { + margin: 0px; + padding: 0px; +} + +.tape form input { + margin: 0px; + padding: 0px; + border: none; +} + +.tape form input:-moz-placeholder { + color: #999; +} + +.tape form input { + -moz-transition: box-shadow 0.2s ease-in-out; + -ms-transition: box-shadow 0.2s ease-in-out; + -o-transition: box-shadow 0.2s ease-in-out; + -webkit-transition: box-shadow 0.2s ease-in-out; + transition: box-shadow 0.2s ease-in-out; + box-shadow: none; +} + +.tape form input:hover, +.tape form input:focus { + box-shadow: 0px 0px 12px rgb(0,192,255); +} + +/** + * Oh, what a hack! Let some of the background show through, so we don't entirely mask the header + HTML content with the blurred image. + * to truly blur the content behind the tape window, one would have to clone the entire DOM (including webfonts, etc.) + * to mix with the canvas content before blurring, and that is a fairly significant challenge at present. + */ +.tape .blur-image-wrapper .blur-image { + opacity: 0.9; +} + +/* "more" demo page */ + +#col1 { + width: 640px; + margin-right: 20px; +} + +#col2 { + width: 500px; +} + +#col1, +#col2 { + display: inline-block; + vertical-align: top; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + box-sizing: border-box; +} + +#col2 .tape { + margin-top: 1em; +} + +.thanks { + position: fixed; + bottom: 0px; + left: 0px; + margin: 0px; + width: 100%; +} + +.thanks p { + display: block; + margin: 0px; + padding: 0.75em; + background: rgba(0,0,0,0.25); + text-shadow: 0px 1px #000; + font-weight: normal; + font-size: 12px; + color: #ddd; +} + +.thanks a { + color: #99ccff; + text-decoration: none; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/JustAnotherHand_ttf_font_LICENSE.txt b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/JustAnotherHand_ttf_font_LICENSE.txt new file mode 100755 index 00000000..75b52484 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/JustAnotherHand_ttf_font_LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/justanotherhand-webfont.eot b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/justanotherhand-webfont.eot new file mode 100755 index 00000000..e3ddec1c Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/justanotherhand-webfont.eot differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/justanotherhand-webfont.ttf b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/justanotherhand-webfont.ttf new file mode 100755 index 00000000..6cb86f8b Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/justanotherhand-webfont.ttf differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/justanotherhand-webfont.woff b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/justanotherhand-webfont.woff new file mode 100755 index 00000000..1a7cf920 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/justanotherhand-webfont.woff differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/ostrich-rounded-webfont.eot b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/ostrich-rounded-webfont.eot new file mode 100755 index 00000000..b2d0adb7 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/ostrich-rounded-webfont.eot differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/ostrich-rounded-webfont.svg b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/ostrich-rounded-webfont.svg new file mode 100755 index 00000000..b8c2cb4f --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/ostrich-rounded-webfont.svg @@ -0,0 +1,141 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Copyright c 2011 by Tyler Finck All rights reserved +Designer : Tyler Finck +Foundry : Tyler Finck +Foundry URL : httpwwwsurslycom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/ostrich-rounded-webfont.ttf b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/ostrich-rounded-webfont.ttf new file mode 100755 index 00000000..a999b006 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/ostrich-rounded-webfont.ttf differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/ostrich-rounded-webfont.woff b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/ostrich-rounded-webfont.woff new file mode 100755 index 00000000..0770f4f2 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/font/ostrich-rounded-webfont.woff differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/MA-R90 metal pattern.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/MA-R90 metal pattern.png new file mode 100755 index 00000000..125e1b52 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/MA-R90 metal pattern.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/TDK MA-R90 body.psd b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/TDK MA-R90 body.psd new file mode 100755 index 00000000..45295ae8 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/TDK MA-R90 body.psd differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/Tape Mask.psd b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/Tape Mask.psd new file mode 100755 index 00000000..6c5b93d7 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/Tape Mask.psd differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/metalspool.psd b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/metalspool.psd new file mode 100755 index 00000000..b69a2ff7 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/metalspool.psd differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/metalspoolblack.psd b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/metalspoolblack.psd new file mode 100755 index 00000000..df011094 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/metalspoolblack.psd differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/rail-middle-outline-edited.psd b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/rail-middle-outline-edited.psd new file mode 100755 index 00000000..59ba41a6 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/rail-middle-outline-edited.psd differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/tape-screw-dark.psd b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/tape-screw-dark.psd new file mode 100755 index 00000000..be58c338 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/tape-screw-dark.psd differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/tape-screw.psd b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/tape-screw.psd new file mode 100755 index 00000000..9572440d Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/_src/tape-screw.psd differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/black-micro.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/black-micro.png new file mode 100755 index 00000000..9dd15af5 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/black-micro.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/body-texture-strips.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/body-texture-strips.png new file mode 100755 index 00000000..3a08ef04 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/body-texture-strips.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/demo_backgrounds/sfatnight_1600.jpg b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/demo_backgrounds/sfatnight_1600.jpg new file mode 100755 index 00000000..5eb2f725 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/demo_backgrounds/sfatnight_1600.jpg differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/gradient.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/gradient.png new file mode 100755 index 00000000..94be59fa Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/gradient.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/ma-r90-body-skin.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/ma-r90-body-skin.png new file mode 100755 index 00000000..2be4590b Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/ma-r90-body-skin.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/ma-r90-mask.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/ma-r90-mask.png new file mode 100755 index 00000000..41e7b4f4 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/ma-r90-mask.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/ma-r90-metal-pattern-v2.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/ma-r90-metal-pattern-v2.png new file mode 100755 index 00000000..cc30c618 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/ma-r90-metal-pattern-v2.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/rail-middle-outline.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/rail-middle-outline.png new file mode 100755 index 00000000..e9eaaef4 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/rail-middle-outline.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/spool-metal-black.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/spool-metal-black.png new file mode 100755 index 00000000..301eb68c Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/spool-metal-black.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/spool-metal.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/spool-metal.png new file mode 100755 index 00000000..2d6f1d19 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/spool-metal.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/spool-spokes.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/spool-spokes.png new file mode 100755 index 00000000..9f4801e8 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/spool-spokes.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/tape-guide.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/tape-guide.png new file mode 100755 index 00000000..e7397cf4 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/tape-guide.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/tape-screw-dark.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/tape-screw-dark.png new file mode 100755 index 00000000..cae8d293 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/tape-screw-dark.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/tape-screw.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/tape-screw.png new file mode 100755 index 00000000..a68c583a Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/tape-screw.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/tape-texture.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/tape-texture.png new file mode 100755 index 00000000..157b9882 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/image/tape-texture.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/index.html new file mode 100755 index 00000000..955ffa2a --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/index.html @@ -0,0 +1,143 @@ + + + + +Cassette Tape Prototype: Canvas mask + blur effects version (MA-R90-style design) + + + + + + + + + + + + + + + + +
+
+

Cassette Tape UI

+

An exercise in skeuomorphic excess. ✭  more ↬ home ↬

+
+
+ +
+
+
+
+
+ + + +
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + +
+ +
+ +
+
+ +
+
+
+ +
+

Mixtape demo includes "Render Your Heart" by SonReal. For the complete mix, see Chill With Schill: Summer iDJ Live Session on Mixcrate.

+
+ + + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/more.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/more.html new file mode 100755 index 00000000..e656d84c --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/more.html @@ -0,0 +1,414 @@ + + + + +SoundManager 2: Cassette Tape Prototype + + + + + + + + + + + + +
+ +
+ +
+

Cassette Tape UI

+

An exercise in skeuomorphic excess. main ↬

+
+ +
+ +
+ +

About

+

The Cassette Tape UI began as a silly web design idea which spawned a Tape Lamp Project and some eBay finds along the way. This page documents some analog history, and the "making-of".

+ +

Purpose

+

Following up on the Wheels Of Steel, The Cassette Tape UI is another experiment in skeuomorphic design - a term that in the context of computers, involves digital recreations of analog design elements and functionality that serve little to no practical purpose in the digital world.

+

In other words: "You know what never gets old? ... Nostalgia."

+ +

Technology

+

This experimental UI demo uses SoundManager 2 for audio playback and control. HTML5 and/or Flash can be used by SM2 under the hood, depending on support.

+

The UI is driven mostly by the whileplaying() event, which results in the spooling of cassette tape between the reels as playback progresses. The tape "connecting" the two reels is drawn dynamically on a <canvas> element, as applicable.

+

CSS animations are used to make the reels spin at different speeds, and <canvas> is also used to apply some masking and blurring effects on the home page demo.

+ +

Credits

+

Thanks go out to Brian Scates, who designed graphic elements for the tape spokes, reels and textures. Kudos are also due to design + tech friends who played with early pre-release versions, found bugs and gave feedback.

+

Web fonts used: Just Another Hand (mixtape "label"), Ostrich Sans (Demo page headers).

+ +

Inspiration

+

+ Heavy Metal: TDK MA-R90 Cassette Tape + TDK MAR-90 Cassette Tape (Back) +

+

The TDK MA-R (Metal-Alloy Reference) cassette series debuted in 1979 with a stunning design. Housed in a metal shell, the MA-R was a pretty serious piece of hardware weighing several times more than its counterparts. It was also innovative: Unlike other tapes with one-use tabs designed to be snapped and broken off, the MA-R series' tabs could be rotated in-place to prevent re-recording.

+

It turns out that cassette tapes, like many other things, are collectible. Rare and still-new, sealed models can go for hundreds of dollars online.

+

There were also some creative blends of functionality and design. It's inspiring to note that someone thought to make this tape head degausser tool transparent, exposing its unique inner circuitry.

+

+ TDK HD-01 Head Demagnetizer +

+ +

Tangential: The Lamp Project

+ +

When searching for transparent tape designs online, I found photos of a "lamp" made by a San Francisco-based architecture firm and couldn't resist a shot at making my own. While they used larger scales and incandescent lighting, my approach was to build 1x5 and 2x5 stacks using transparent Maxell DUP-120 tapes in jewel boxes, and to light the stack with a special LED panel.

+ +

+ Cassette Tape Lamps: 1x5, 2x5 +

+ +

Incandescent flood lighting was tested, and turned out to be impractical (and perhaps, fire-prone).

+ +

+ Cassette Tape Lamp: Test Build 1 (Desaturated) +

+ +

Things improved greatly with a dimmable RGB LED panel which offered consistent illumination.

+ +

+ Cassette Tape Lamp, LED Panel lighting +

+ +

After making three 2x5 lamps (120 tapes in total), it was too tempting not to stack them.

+ +

+ Cassette Tape Tower + RGB LED Panel Lighting +

+ +

Following up on the larger builds, I started making smaller 1x5-sized lamps for friends.

+ +

+ Tape Lamp @ FlickrHQ (1x1x5), HDR + Accidental Minecraft-style lighting +

+ +

See the Cassette Tape Lamp Project set for more photos.

+ +
+ +
+ +

Live Demo

+ +

Here are some cassette tape UI skin/theme variants; the styling is a mix of HTML elements and class names.

+ +

Disclaimer: This UI is a prototype, experimental and subject to change. It is not officially "supported" as a demo, and requires a fairly-modern browser that supports CSS3 and <canvas>. It does not degrade gracefully in older browsers. Use at your own risk.

+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Mixtape Demo
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Mixtape Demo
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Mixtape Demo
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
Mixtape Demo
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
Mixtape Demo
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+ +
+ +
+ + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/script/cassette-tape-ui.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/script/cassette-tape-ui.js new file mode 100755 index 00000000..3832ce70 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/script/cassette-tape-ui.js @@ -0,0 +1,1198 @@ +/** + * Cassette Tape UI Prototype (09/2012) + * ALPHA build / experimental state, unsupported; use at own risk + * Requires CSS3 border-radius + support + * -------------------------------------------------- + * http://www.schillmania.com/projects/soundmanager2/ + */ + +(function(window) { + +var caughtError = false; + +var CanvasImage = function(canvas, image) { + + /** + * https://github.com/ceramedia/examples/tree/gh-pages/canvas-blur/v5 + * original: http://www.flother.com/blog/2010/image-blur-html5-canvas/ + * + * Light layer on top of a canvas element to represent an image displayed + * within. Pass in a canvas element and an Image object and you'll see the + * image within the canvas element. Use the provided methods (e.g. blur) to + * manipulate it. + * + * @constructor + * @param {HTMLElement} element HTML canvas element. + * @param {Image} image Image object. + */ + + var width, height; + + this.image = image; + + width = this.image.width; + height = this.image.height; + + this.element = canvas || document.createElement('canvas'); + // IE 10 complains if 'auto' is used for style.width|height. + + this.element.style.width = width+'px'; + this.element.style.height = height+'px'; + this.element.width = width; + this.element.height = height; + this.context = this.element.getContext('2d'); + this.context.drawImage(this.image, 0, 0); + +}; + +CanvasImage.prototype = { + /** + * Runs a blur filter over the image. + * @param {int} strength Strength of the blur. + */ + blur: function (strength) { + this.context.globalAlpha = 0.5; // Higher alpha made it more smooth + // Add blur layers by strength to x and y + // 2 made it a bit faster without noticeable quality loss + for (var y = -strength; y <= strength; y += 2) { + for (var x = -strength; x <= strength; x += 2) { + // Apply layers + this.context.drawImage(this.element, x, y); + // Add an extra layer, prevents it from rendering lines + // on top of the images (does makes it slower though) + if (x>=0 && y>=0) { + this.context.drawImage(this.element, -(x-1), -(y-1)); + } + } + } + this.context.globalAlpha = 1.0; + } +}; + +function imageMask(imageSrc, maskSrc, canvasWidth, canvasHeight, useRepeat, oncomplete) { + + /** + * quick-and-dirty "load an image and apply a mask to it" function + * parameters: + * @imageSrc {URL} string Source image URL + * @maskSrc {URL} string Mask image URL + * @oncomplete {Function} function Callback with data: URI of masked image result + */ + + var images = [ + new Image(), + new Image() + ]; + + // CORS option? + // images[0].crossOrigin = 'anonymous'; + // images[1].crossOrigin = 'anonymous'; + + var canvas = [ + document.createElement('canvas'), + document.createElement('canvas') + ]; + + var loadCount = 0; + + var loadTarget = images.length; + + function applyMask() { + + // draw and mask image + + var srcWidth = canvasWidth; + var srcHeight = canvasHeight; + + var targetWidth = canvasWidth; + var targetHeight = canvasHeight; + + var ctx; + + var repeatPattern; + + canvas[0].width = srcWidth; + canvas[0].height = srcHeight; + + canvas[1].width = targetWidth; + canvas[1].height = targetHeight; + + ctx = [ + canvas[0].getContext('2d'), + canvas[1].getContext('2d') + ]; + + if (!useRepeat) { + + // simple 1:1 case + + ctx[0].drawImage(images[0], 0, 0); + + } else { + + // tile the image across the canvas + + repeatPattern = ctx[0].createPattern(images[0], 'repeat'); + + ctx[0].fillStyle = repeatPattern; + + ctx[0].fillRect(0, 0, targetWidth, targetHeight); + + ctx[0].fillStyle = ''; + + } + + // draw mask on target canvas + + ctx[1].drawImage(images[1], 0, 0); + + // apply the mask + + ctx[0].globalCompositeOperation = 'destination-in'; + + ctx[0].drawImage(canvas[1], 0, 0); + + ctx[0].globalCompositeOperation = null; + + // the resulting masked image + + return canvas[0]; + + } + + function imageLoaded() { + + // load handler + + this.onload = this.onerror = null; + + loadCount++; + + if (loadCount >= loadTarget) { + + // apply the mask, providing the resulting data URI to the handler + // TODO: Don't use data URL, just modify canvas directly; likely much faster. + + try { + + oncomplete(applyMask().toDataURL('image/png')); + + } catch(e) { + + // may fail with DOM exception 18 under Chrome when offline eg., file:// instead of over HTTP. + + if (typeof console !== 'undefined' && typeof console.warn !== 'undefined') { + console.warn('Unable to apply image mask, likely a security exception from offline (file://) use.', e); + if (!caughtError && typeof console.info !== 'undefined') { + console.info('Using static skin image as a workaround.'); + } + } + + // hack: try applying the body skin instead, without masking. HTML-based screw elements will overlay the skin, but, eh. this is an edge case anyway. + + if (!caughtError) { + + oncomplete('image/ma-r90-body-skin.png'); + caughtError = true; + + } else { + + oncomplete(); + + } + + } + + // cleanup? + canvas = null; + images = null; + + } + + } + + function init() { + + // preload source / target images + + images[0].onload = images[0].onerror = imageLoaded; + images[1].onload = images[1].onerror = imageLoaded; + + images[0].src = imageSrc; + images[1].src = maskSrc; + + // TODO: check .complete (cached) case? + + } + + init(); + +} + +function TapeUI(oOptions) { + + var css = { + + playing: 'playing', + stopped: 'stopped', + ready: 'ready', + dropin: 'dropin' + + }; + + var data = { + + progress: 0 + + }; + + var controlHandler; + + var sound; + + var dom = {}; + + var spoolWidth = 91; + + var borderMaxWidth = 76; + + var reelBoxWidth = 234; + + var tapeWidth = 480; + var tapeHeight = parseInt(tapeWidth/1.6, 10); + + var blurCanvas; + + var maskCanvas; + var maskCanvasLoaded; + var maskContext; + var maskImage; + var maskVisible; + + var context; + + function getBackgroundURL(node) { + + var url; + var cssprop = 'backgroundImage'; + + if (node.currentStyle) { + + // IE + url = node.currentStyle[cssprop]; + + } else if (document.defaultView && document.defaultView.getComputedStyle) { + + // Firefox + url = document.defaultView.getComputedStyle(node, '')[cssprop]; + + } else { + + // inline style? + url = node.style[cssprop]; + + } + + // HACK: strip url() and/or quotes from string + + url = url.replace('url(', '').replace(')', ''); + + url = url.replace(/\'/g, '').replace(/\"/g, ''); + + return url; + + } + + function maskedImageReady(node, uri) { + + // callback with data: URI of masked image + + if (node && uri) { + node.style.backgroundImage = uri; + } + + } + + function createMaskedImage(node) { + + // get background image (or if , src?) and data-mask-image attributes + + var imageSrc = getBackgroundURL(node), + elementWidth = node.offsetWidth, + elementHeight = node.offsetHeight, + useRepeat = !!node.getAttribute('data-image-repeat'), + maskSrc = node.getAttribute('data-mask-url'); + + return imageMask(imageSrc, maskSrc, elementWidth, elementHeight, useRepeat, function(maskURI) { + var uri = (maskURI ? 'url(' + maskURI + ')' : null); + maskedImageReady(node, uri); + }); + + } + + // canvas stuffs + + function scaleWidth(w) { + return (w * tapeWidth); + } + + function scaleHeight(h) { + return (h * tapeHeight); + } + + function initMask(callback) { + + if (!dom.node.className.match(/cutout/i)) { + return false; + } + + // draw our tape cut-outs + + maskCanvas = document.createElement('canvas'); + + maskImage = new Image(); + + // Ensure same dimensions + maskCanvas.width = tapeWidth; + maskCanvas.height = tapeHeight; + +/* + maskContext = maskCanvas.getContext('2d'); + + var spoolBoxRadius = 134; + + var spoolCoords = [ + // left + tapeWidth * 0.29, + tapeHeight * 0.45, + // right + tapeWidth * 0.71, + tapeHeight * 0.45 + ]; + + // filled shape color + maskContext.fillStyle = "black"; + + maskContext.arc(spoolCoords[0], spoolCoords[1], spoolBoxRadius, 0, 4 * Math.PI); + + maskContext.arc(spoolCoords[2], spoolCoords[3], spoolBoxRadius, 0, 4 * Math.PI); + + maskContext.fill(); +*/ + + maskImage.onload = function() { + var ctx = maskCanvas.getContext('2d'); + ctx.drawImage(this, 0, 0); + this.onload = null; + maskCanvasLoaded = true; + callback(); + }; + + // load the mask to apply + maskImage.src = 'image/ma-r90-mask.png'; + + } + + function createBlurImage(callback) { + + var url = getBackgroundURL(document.getElementsByTagName('html')[0]); + + var image = new Image(); + + // CORS option? + // image.crossOrigin = 'anonymous'; + + image.onload = image.onerror = function() { + + // in error state, w/h will be empty. + + if (this.width || this.height) { + + // make + blur + + var canvasImage = new CanvasImage(dom.blurNode, this); + + // var uri = canvasImage.element.toDataURL('image/png'); + + // + assign to DOM + + dom.blurNode.style.backgroundImage = ''; + + canvasImage.blur(2); + + } + + this.onload = this.onerror = null; + + if (callback) { + callback(); + } + + } + + image.src = url; + + } + + function center() { + + // given screen x/y, position at center. + + // don't center unless draggable. + if (!dragHandler.data.dragTarget.node) { + return false; + } + + var screenX = window.innerWidth, + screenX2 = parseInt(screenX/2, 10), + screenY = window.innerHeight, + screenY2 = parseInt(screenY/2, 10), + x, y, + node = dom.node, + blurNode = dom.blurNode; + + if (node) { + x = parseInt(screenX2 - (tapeWidth/2), 10); + y = parseInt(screenY2 - (tapeHeight/2), 10); + node.style.left = x + 'px'; + node.style.top = y + 'px'; + if (blurNode) { + blurNode.style.marginLeft = -x + 'px'; + blurNode.style.marginTop = -y + 'px'; + } + } + + } + + var readyCompleteTimer = null; + + function readyComplete(loader) { + + utils.css.add(dom.node, css.ready); + utils.css.add(dom.node, css.dropin); + + if (readyCompleteTimer) { + window.clearTimeout(readyCompleteTimer); + } + + readyCompleteTimer = window.setTimeout(function() { + utils.css.remove(dom.node, css.dropin); + // demo hack: remove the loader, too + /* + if (loader) { + document.body.removeChild(loader); + loader = null; + } + */ + }, 1000); + + } + + function ready() { + + // demo hack: hide the loading element, if present + var loader = document.getElementById('tape-loader'), + wrapper = document.getElementById('demo-header-wrapper'); + + if (loader) { + utils.css.remove(loader, 'visible'); + utils.css.add(loader, 'hidden'); + if (wrapper) { + utils.css.add(wrapper, 'visible'); + } + } + + // trigger animations after slight yield (depending on loader element) + window.setTimeout(function() { + // reposition + center(); + readyComplete(loader); + }, loader ? 300 : 1); + + } + + function init() { + + var i, j; + + sound = oOptions.sound; + + dom = { + node: oOptions.node, + canvas: oOptions.node.querySelectorAll('.connecting-tape'), + reels: oOptions.node.querySelectorAll('div.reel'), + spokes: oOptions.node.querySelectorAll('div.spokes'), + label: oOptions.node.querySelectorAll('div.label'), + maskImages: oOptions.node.querySelectorAll('.image-mask'), + blurNode: oOptions.node.querySelectorAll('.blur-image') + } + + if (dom.canvas && dom.canvas.length) { + dom.canvas = dom.canvas[0]; + initMask(function() { + // force redraw + setProgress(0, true); + }); + } else { + dom.canvas = null; + } + + // images needing masking? + if (dom.maskImages) { + for (i=0, j=dom.maskImages.length; i left guide + context.lineTo(bottomLeftPoint.from[0] + guideRadius, bottomLeftPoint.from[1] + guideRadius*2); + + // arc + context.arc(bottomLeftPoint.from[0] + guideRadius, bottomLeftPoint.from[1] + guideRadius, guideRadius, deg2rad(90), deg2rad(180), false); + + // -> left reel + context.lineTo(leftReel.left, leftReel.top); + + context.lineWidth = 0.5; + + // move to bottom middle + context.moveTo(bottomMidPoint.left, bottomMidPoint.top); + + // -> right guide + context.lineTo(bottomRightPoint.from[0] + guideRadius, bottomRightPoint.from[1]); + + // right side + context.arc(bottomRightPoint.from[0] + guideRadius, bottomRightPoint.from[1] - guideRadius, guideRadius, deg2rad(90), deg2rad(0), true); // -30 on last for curve effect + + // -> right reel + context.lineTo(rightReel.left, rightReel.top); + + context.lineWidth = 1; + + context.stroke(); + + // apply the mask (only the circular areas around the tape) + + if (maskCanvas) { + + // set composite operation + + context.globalCompositeOperation = 'destination-out'; + + context.drawImage(maskCanvas, 0, 0); + + context.globalCompositeOperation = null; + + // visibility check + + if (maskCanvasLoaded && !maskVisible) { + + maskVisible = true; + + canvas.style.visibility = 'visible'; + + } + + } + + } + + function setReelSpeed(reel, speed) { + + // base speed plus a given amount based on speed (multiplier?) + + } + + function applyProgress(progress) { + + var newFrames = 0; + + setReelSpeed(dom.reels[0], progress); + newFrames += setReelSize(0, dom.reels[0], 1-progress); + newFrames += setReelSize(1, dom.reels[1], progress); + + return newFrames; + + } + + function setProgress(progress, forceUpdate) { + + var newFrames = 0; + + forceUpdate = forceUpdate || false; + + data.progress = progress; + + newFrames = applyProgress(progress); + + if ((newFrames || forceUpdate) && dom.canvas) { + + drawConnectingTape(dom.canvas, progress, forceUpdate); + + } + + } + + function start() { + + utils.css.remove(dom.node, css.stopped); + utils.css.add(dom.node, css.playing); + + } + + function stop() { + + utils.css.remove(dom.node, css.playing); + utils.css.add(dom.node, css.stopped); + + } + + return { + + refreshBlurImage: function(callback) { + utils.css.remove(dom.node, css.dropin); + utils.css.remove(dom.node, css.ready); + return createBlurImage(function() { + utils.css.add(dom.node, css.dropin); + utils.css.add(dom.node, css.ready); + readyComplete(); + if (callback) { + callback(this); + } + }); + }, + dom: dom, + init: init, + setProgress: setProgress, + start: start, + stop: stop + + }; + +} + +var tapeUIs = []; + +function resetTapeUIs() { + + for (var i=tapeUIs.length; i--;) { + tapeUIs[i].setProgress(0); + } + +} + +var ignoreNextClick = false; + +var dragHandler = (function() { + + var css, + data, + dom, + events; + + function findPos(obj) { + var curleft = curtop = 0; + if (obj.offsetParent) { + do { + curleft += obj.offsetLeft; + curtop += obj.offsetTop; + } while (obj = obj.offsetParent); + } + return [curleft, curtop]; + } + + css = { + dragActive: 'dragging', + dropActive: 'dropping' + }; + + data = { + dragTarget: { + node: null, + blurNode: null, + blurNodeContainer: null, + x: null, + y: null, + lastX: null, + lastY: null + }, + mousedown: { + x: null, + y: null + }, + drag: { + xOffset: null, + yOffset: null + }, + background: { + xOffset: -151, + yOffset: -119 + } + }; + + events = { + mousedown: function(e) { + var target = data.dragTarget.node, + clickTarget = e.target; + if (!data.dragTarget.node) { + return true; + } + // additional safety check + if (clickTarget && clickTarget.tagName == 'INPUT') { + ignoreNextClick = true; + return true; + } + ignoreNextClick = false; + var xy = findPos(target); + data.dragTarget.x = xy[0]; + data.dragTarget.y = xy[1]; + data.mousedown.x = e.clientX; + data.mousedown.y = e.clientY; + data.drag.xOffset = data.mousedown.x - data.dragTarget.x; + data.drag.yOffset = data.mousedown.y - data.dragTarget.y; + utils.events.add(document, 'mousemove', events.mousemove); + utils.events.add(document, 'mouseup', events.mouseup); + e.preventDefault(); + return false; + }, + mousemove: function(e) { + var x, y, + node = data.dragTarget.node, + blurNode = data.dragTarget.blurNode; + if (node) { + x = (e.clientX - data.drag.xOffset); + y = (e.clientY - data.drag.yOffset); + node.style.left = x + 'px'; + node.style.top = y + 'px'; + if (blurNode) { + blurNode.style.marginLeft = -x + 'px'; + blurNode.style.marginTop = -y + 'px'; + } + if (!ignoreNextClick) { + ignoreNextClick = true; + utils.css.add(data.dragTarget.node, css.dragActive); + } + } + }, + mouseup: function(e) { + utils.css.remove(data.dragTarget.node, css.dragActive); + if (ignoreNextClick) { + // remove drag work + utils.css.add(data.dragTarget.node, css.dropActive); + window.setTimeout(function() { + utils.css.remove(data.dragTarget.node, css.dropActive); + }, 500); + } + utils.events.remove(document, 'mousemove', events.mousemove); + utils.events.remove(document, 'mouseup', events.mouseup); + e.preventDefault(); + return false; + } + + }; + + function updateLastXY() { + var target = data.dragTarget.node; + var xy = findPos(target); + data.dragTarget.lastX = xy[0]; + data.dragTarget.lastY = xy[1]; + } + + function addEvents() { + if (data.dragTarget && data.dragTarget.node) { + utils.events.add(data.dragTarget.node, 'mousedown', events.mousedown); + } + } + + function init() { + data.dragTarget.node = document.querySelector('.tape.draggable'); + data.dragTarget.blurNode = document.querySelector('.tape.draggable .blur-image'); + addEvents(); + } + + return { + data: data, + init: init + } + +}()); + +var utils = (function() { + + var addEventHandler = (typeof window.addEventListener !== 'undefined' ? function(o, evtName, evtHandler) { + return o.addEventListener(evtName,evtHandler,false); + } : function(o, evtName, evtHandler) { + o.attachEvent('on'+evtName,evtHandler); + }); + + var removeEventHandler = (typeof window.removeEventListener !== 'undefined' ? function(o, evtName, evtHandler) { + return o.removeEventListener(evtName,evtHandler,false); + } : function(o, evtName, evtHandler) { + return o.detachEvent('on'+evtName,evtHandler); + }); + + var classContains = function(o,cStr) { + return (typeof(o.className)!=='undefined'?o.className.match(new RegExp('(\s|^)'+cStr+'(\s|$)')):false); + }; + + var addClass = function(o,cStr) { + if (!o || !cStr || classContains(o,cStr)) { + return false; + } + o.className = (o.className?o.className+' ':'')+cStr; + }; + + var removeClass = function(o,cStr) { + if (!o || !cStr || classContains(o,cStr)) { + return false; + } + o.className = o.className.replace(new RegExp('( '+cStr+')|('+cStr+')','g'),''); + }; + +/* + var isChildOfNode = function(o,sNodeName) { + if (!o || !o.parentNode) { + return false; + } + sNodeName = sNodeName.toLowerCase(); + do { + o = o.parentNode; + } while (o && o.parentNode && o.nodeName.toLowerCase() !== sNodeName); + return (o.nodeName.toLowerCase() === sNodeName ? o : null); + }; +*/ + + return { + css: { + has: classContains, + add: addClass, + remove: removeClass + }, +/* + dom: { + isChildOfNode: this.isChildOfNode + }, +*/ + events: { + add: addEventHandler, + remove: removeEventHandler + } + } + +}()); + +function ControlHandler(tapeUIDOM, soundObject) { + + var soundObject; + + var css, dom, events, eventMap, soundOK; + + // percentage to jump with each click of the rewind / fast-forward buttons + var rewind_ffwd_offset = 0.033; + + dom = { + oControls: null, + play: null, + rew: null, + ffwd: null, + stop: null + }; + + events = { + mousedown: function(e) { + // need + var target = e.target, + className = e.target.className; + if (soundOK && typeof eventMap[className] !== 'undefined') { + eventMap[className](e); + return events.stopEvent(e); + } + }, + stopEvent: function(e) { + e.preventDefault(); + return false; + }, + click: function(e) { + // simple/dumb: just toggle the playstate of the tape. + if (ignoreNextClick) { + ignoreNextClick = false; + return events.stopEvent(e); + } + var target = e.target, + className = e.target.className; + if (typeof eventMap[className] == 'undefined') { + soundObject.togglePause(); + } else { + return events.mousedown(e); + } + } + }; + + eventMap = { + 'play': function(e) { + soundObject.play(); + }, + 'rew': function() { + // rewind + var newPosition = Math.max(0, soundObject.position - soundObject.duration * rewind_ffwd_offset); + if (soundObject.duration) { + soundObject.setPosition(newPosition); + // if not playing, force update? + tapeUIs[0].setProgress(newPosition/soundObject.duration); + } + }, + 'ffwd': function() { + // fast-forward + var newPosition; + if (soundObject.duration) { + newPosition = Math.min(soundObject.duration, soundObject.position + soundObject.duration * rewind_ffwd_offset); + soundObject.setPosition(newPosition); + } + }, + 'stop': function() { + // equivalent to digital pause + soundObject.pause(); + } + }; + + function addEvents() { + utils.events.add(dom.o, 'mousedown', events.mousedown); + utils.events.add(tapeUIDOM.node, 'click', events.click); + } + + function init() { + soundOK = soundManager.ok(); + dom.o = tapeUIDOM.node.querySelector('.controls'); + dom.play = dom.o.querySelector('.play'); + dom.rewind = dom.o.querySelector('.rew'); + dom.ffwd = dom.o.querySelector('.ffwd'); + dom.stop = dom.o.querySelector('.stop'); + addEvents(); + } + + init(); + +} + +function init() { + + var hasCanvas = (typeof document.createElement('canvas').getContext !== 'undefined'); + + if (!hasCanvas) { + // assume a crap browser (e.g., IE 8.) + return false; + } + + var tapes, + i, s; + + dragHandler.init(); + + function genericStart() { + for (var i=tapeUIs.length; i--;) { + tapeUIs[i].start(); + } + } + + function genericStop() { + for (var i=tapeUIs.length; i--;) { + tapeUIs[i].stop(); + } + } + + if (soundManager.ok()) { + + s = soundManager.createSound({ + id: 'tapeSound', + url: 'http://freshly-ground.com/data/audio/sm2/Chill With Schill (Summer 2012 Session Excerpt).mp3', + multiShot: false, + whileplaying: function() { + for (var i=tapeUIs.length; i--;) { + // console.log(this.position, this.durationEstimate); + tapeUIs[i].setProgress(this.position/this.durationEstimate); + } + }, + onplay: genericStart, + onfinish: genericStop, + onpause: genericStop, + onresume: genericStart + }); + + } + + tapes = document.querySelectorAll('div.tape'); + + for (i=tapes.length; i--;) { + tapeUIs.push(new TapeUI({ + node: tapes[i], + sound: s + })); + tapeUIs[tapeUIs.length-1].init(); + } + + resetTapeUIs(); + +} + +function delayInit() { + + var loader = document.getElementById('tape-loader'); + + if (loader) { + loader.className = 'visible'; + } + + window.setTimeout(function() { + init(); + }, 20); +} + +soundManager.setup({ + url: '../../swf/', + flashVersion: 9, + useHighPerformance: true, + preferFlash: false, + html5PollingInterval: 50, + onready: delayInit, + ontimeout: delayInit +}); + +// interface +window.tapeUIs = tapeUIs; + +}(window)); \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/script/demo.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/script/demo.js new file mode 100755 index 00000000..c5ba82bc --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/cassette-tape/script/demo.js @@ -0,0 +1,145 @@ +/** + * Cassette Demo page JS - you don't need this part. + */ + +(function() { + +function init() { + + // Demo-specific things: background-switching, etc. + + var bgIndex = 1, + backgrounds; + + // note: remote servers will need to serve a CORS response header for cross-domain canvas access. + backgrounds = [ + 'image/demo_backgrounds/sfatnight_1600.jpg', + 'http://freshly-ground.com/data/image/sm2/lake_1600.jpg', + 'http://freshly-ground.com/data/image/sm2/wall_of_hard_drives.jpg', + 'http://freshly-ground.com/data/image/sm2/attack_of_the_jellyfish.jpg', + 'http://freshly-ground.com/data/image/sm2/cassette_tape_lamp.jpg' + ]; + + document.getElementById('nextBackground').onclick = function(e) { + + var i, j, refreshed, + loader = document.getElementById('tape-loader'); + + function refreshDone() { + // re-hide the loader + refreshed++; + if (refreshed == tapeUIs.length) { + if (loader) { + loader.className = 'hidden'; + } + } + } + + // hack: make the loader visible again + if (loader) { + loader.className = 'visible'; + } + + document.getElementsByTagName('html')[0].style.backgroundImage = 'url(' + backgrounds[bgIndex] + ')'; + + refreshed = 0; + + for (i=0, j=tapeUIs.length; i= backgrounds.length) { + bgIndex = 0; + } + + e.preventDefault(); + return false; + + } + + // form helpers + + var form = document.getElementById('tape-form'), + defaultValue, + input; + + if (form) { + + input = form.getElementsByTagName('input')[0]; + + function submitHandler(e) { + + var inputURL = input.value, + s = soundManager.getSoundById('tapeSound'), + lastValue, + caughtSubmit; + + // URL should at least have two slashes in it, to be considered valid. + if (s && inputURL.match(/\/\//) && s.url !== inputURL) { + + s.load({ + url: inputURL + }).play(); + + } + + if (e) { + e.preventDefault(); + } + + // is the form focused? blur if so. + if (document.activeElement && document.activeElement == input) { + try { + caughtSubmit = true; + input.blur(); + } catch(ee) { + // oh well + } + } + + return false; + + } + + form.onsubmit = submitHandler; + + // reset form on load + defaultValue = input.getAttribute('data-default-value'); + + input.value = defaultValue; + + input.onfocus = function() { + + caughtSubmit = false; + + lastValue = this.value; + + this.value = ''; + + } + + input.onblur = function() { + + if (!this.value) { + + this.value = (lastValue || defaultValue); + + } + + if (!caughtSubmit) { + // user tabbed out, etc.? we may load a new URL now. + submitHandler(); + } + + } + + } + +} + +soundManager.setup({ + onready: init, + ontimeout: init +}); + +}()); diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/christmaslights.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/christmaslights.css new file mode 100755 index 00000000..3f43b529 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/christmaslights.css @@ -0,0 +1,147 @@ +/* XLSF 2007 */ + +body { + font-family:"Helvetica Neue",helvetica,georgia,"times new roman","Arial Rounded MT Bold",helvetica,verdana,tahoma,arial,"sans serif"; + font-size:75%; + color:#666; + *background:#333 url(image/bg-strip-dark.png) 0px 0px; /* IE */ +} + +#explosion-box { + position:absolute; + left:0px; + top:0px; + width:100%; + height:100%; + overflow:hidden; + background:#333 url(image/bg-strip-dark.png) 0px 0px; + background: -webkit-gradient( + linear, + left bottom, + left top, + color-stop(0, rgb(16,16,32)), + color-stop(1, rgb(32,132,202)) + ); + background: -moz-linear-gradient( + center bottom, + rgb(16,16,32) 0%, + rgb(32,132,202) 100% + ); +} + +#explosion-box-texture { + position:absolute; + left:0px; + top:0px; + width:100%; + height:100%; + background: transparent url(image/noise-pattern.png); + opacity: 0.035; +} + +h1, h1 a { + color:#999; + text-decoration:none; +} + +h1 { + color:#999; + margin-bottom:0; + margin-left:-5px; + margin-top:0; + padding-left:5px; + padding-right:5px; +} + +h1, h2, h3 { + clear:both; + float:left; + font-family:"Helvetica Neue",georgia,"times new roman","Arial Rounded MT Bold",helvetica,verdana,tahoma,arial,"sans serif"; + font-size:3em; + font-size-adjust:none; + margin-bottom:0.25em; + padding-bottom:1px; +} + +h1, h2 { + letter-spacing:-1px; + margin-bottom:0; + margin-left:-5px; + margin-top:0; + padding-left:5px; + padding-right:5px; +} + +a { + color:#6699cc; + padding:0px 2px; + text-decoration:none; +} + +a:hover { + background:#6699cc; + color:#fff; +} + +#lights { + position:absolute; + left:0px; + top:0px; + width:100%; + height:100%; + overflow:hidden; + z-index:2; + pointer-events: none; /* https://developer.mozilla.org/en/CSS/pointer-events */ +} + +.xlsf-light { + position:absolute; + z-index:2; +} + +.xlsf-angled { + -webkit-transform: rotate(45deg); + -moz-transform:rotate(45deg); + -o-transform:rotate(45deg); + transform:rotate(45deg); +} + +body.fast .xlsf-light { + opacity:0.9; +} + +.xlsf-fragment, +.xlsf-fragment-box { + pointer-events: none; /* https://developer.mozilla.org/en/CSS/pointer-events */ +} + +.xlsf-fragment { + position:absolute; + background:transparent url(image/bulbs-50x50-fragments.png) no-repeat 0px 0px; + width:50px; + height:50px; +} + +.xlsf-fragment-box { + position:absolute; + left:0px; + top:0px; + width:50px; + height:50px; + *width:100%; + *height:100%; + z-index:2; + display:none; +} + +/* +.xlsf-light.bottom { + height:49px; + border-bottom:1px solid #006600; +} + +.xlsf-light.top { + height:49px; + border-top:1px solid #009900; +} +*/ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/christmaslights.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/christmaslights.js new file mode 100755 index 00000000..0970705f --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/christmaslights.js @@ -0,0 +1,785 @@ +/** + * Christmas Light Smashfest + * + * Adapted from XLSF 2007 as originally used on http://schillmania.com/?theme=2007&christmas=1 + * Requires YUI3 library - http://yuilibrary.com/projects/yui3/ + */ + +(function() { + + var YUI_SEED_URL = 'http://yui.yahooapis.com/3.8.0/build/yui/yui-min.js'; + + function initChristmasLights() { + + YUI().use('anim', function(Y) { + + function XLSF(oTarget) { + var writeDebug = soundManager._wD; + writeDebug('XLSF()'); + var IS_MOON_COMPUTER = false; + var isIE = navigator.userAgent.match(/msie/i); + var isTouchDevice = navigator.userAgent.match(/ipad|ipod|iphone|android/i); + var self = this; + var xlsf = self; + var useAngle = window.location.href.match(/angle/i); + var useFollow = window.location.toString().match(/follow/i); + var classBase = 'xlsf-light' + (useAngle ? ' xlsf-angled' : ''); + var animDuration = 1; + var lastMouseX = 0; + var lastMouseY = 0; + var mmhTimer = null; + var activeLights = []; + var testDiv = document.createElement('div'); + var offset = 0; + var transforms = { + ie: (typeof testDiv.style['-ms-transform'] !== 'undefined' ? '-ms-transform' : null), + moz: (typeof testDiv.style.MozTransform !== 'undefined' ? 'MozTransform' : null), + opera: (typeof testDiv.style['OTransform'] !== 'undefined' ? 'OTransform' : null), + webkit: (typeof testDiv.style.webkitTransform !== 'undefined' ? 'webkitTransform' : null), + prop: null + } + transforms.prop = (transforms.moz || transforms.webkit || transforms.ie || transforms.opera); + this.oFrag = document.createDocumentFragment(); + this.oExplosionTarget = document.getElementById('explosion-box'); + if (!this.oExplosionTarget) { + this.oExplosionTarget = document.createElement('div'); + this.oExplosionTarget.id = 'explosion-box'; + document.body.appendChild(this.oExplosionTarget); + } + this.oTarget = (oTarget ? oTarget : document.documentElement); + this.oExplosionBox = document.createElement('div'); + this.oExplosionBox.className = 'xlsf-fragment-box'; + this.oExplosionFrag = document.createElement('div'); + this.oExplosionFrag.className = 'xlsf-fragment'; + this.lights = []; + this.lightClasses = { + pico: 32, + tiny: 50, + small: 64, + medium: 72, + large: 96 + } + + this.lightClass = (window.XLSF_LIGHT_CLASS || 'tiny'); // kind of light to show (32px to 96px square) + if (window.location.href.match(/size=/i)) { + this.lightClass = window.location.href.substr(window.location.href.indexOf('size=') + 5); + if (this.lightClass.indexOf('#') !== -1) { + this.lightClass = this.lightClass.substr(0, this.lightClass.indexOf('#')); + } + } + + this.lightXY = this.lightClasses[this.lightClass]; // shortcut to w/h + + function rnd(n) { + return parseInt(Math.random() * n); + } + + function plusMinus(n) { + return (parseInt(rnd(2), 10) === 1 ? n * -1 : n); + } + + this.lightGroups = { + left: [], + top: [], + right: [], + bottom: [] + } + this.lightSmashCounter = 0; + this.lightIndex = 0; + this.lightInterval = 500; + this.timer = null; + this.bgBaseX = 0; + this.bgBaseY = 0; + this.soundIDs = 0; + this.soundPan = { + panValue: 75, + left: 0, + mid: 481, + right: 962 + } + + this.initSounds = function() { + if (!soundManager.supported()) { + return false; + } + for (var i = 0; i < 6; i++) { + soundManager.createSound({ + id: 'smash' + i, + url: (window.XLSF_URL_BASE || '') + 'sound/glass' + i + '.mp3', + autoLoad: true, + multiShot: true, + volume: 25 + }); + } + self.initSounds = function() {} // safety net + } + + this.appendLights = function() { + writeDebug('xlsf.appendLights()'); + self.oTarget.appendChild(self.oFrag); + // self.oFrag = document.createDocumentFragment(); + } + + function ExplosionFragment(nType, sClass, x, y, vX, vY) { + var self = this; + this.o = xlsf.oExplosionFrag.cloneNode(true); + this.nType = nType; + this.sClass = sClass; + this.x = x; + this.y = y; + this.w = 50; + this.h = 50; + this.bgBaseX = 0; + this.bgBaseY = this.h * this.nType; + this.vX = vX * (1.5 + Math.random()); + this.vY = vY * (1.5 + Math.random()); + this.oA = null; + this.oA2 = null; + this.burstPhase = 1; // starting background offset point + this.burstPhases = 4; // 1+offset (ignore large size) + this.animDuration = 1; // how long the animations run for + this.o.style.backgroundPosition = ((this.w * -this.burstPhase) + 'px ' + (this.h * -nType) + 'px'); + + // boundary checks + if (self.sClass == 'left') { + this.vX = Math.abs(this.vX); + } else if (self.sClass == 'right') { + this.vX = Math.abs(this.vX) * -1; + } + + this.burstTween = function() { + // determine frame to show based on animation's progress vs. its total time (and don't allow overflow, in the event animation runs long.) + var phase = 1 + (Math.floor(Math.min(self.animDuration, (this.get('elapsedTime') / 1000)) * self.burstPhases)); + if (phase != self.burstPhase) { + self.burstPhase = phase; + self.o.style.backgroundPosition = ((self.w * -self.burstPhase) + 'px ' + (self.h * -nType) + 'px'); + } + } + + + this.burst = function() { + self.oA = new Y.Anim({ + node: Y.one(self.o), + to: { + marginLeft: (self.vX * (5 + Math.random() * 10)), + marginTop: (self.vY * (5 + Math.random() * 10)) + }, + duration: animDuration, + easing: Y.Easing.easeOutStrong + }); + self.oA.on('tween', self.burstTween); + self.oA.on('end', self.hide); + self.oA.run(); + } + + this.hide = function() { + if (!isIE) self.o.style.opacity = 0; + } + + this.reset = function() { + self.o.style.left = '0px'; + self.o.style.top = '0px'; + self.o.style.marginLeft = '0px'; + self.o.style.marginTop = '0px'; + if (!isIE) self.o.style.opacity = 1; + } + + this.animate = function() { + self.reset(); + self.burst(); + } + + } + + function Explosion(nType, sClass, x, y) { + var oParent = this; + var self = this; + this.o = null; + this.nType = nType; + this.sClass = sClass; + this.x = x; + this.y = y; + this.boxVX = 0; + this.boxVY = 0; + this.o = xlsf.oExplosionBox.cloneNode(true); + this.o.style.left = x + 'px'; + this.o.style.top = y + 'px'; + // this.oFrag = document.createDocumentFragment(); + this.fragments = []; + + var mX = x; + var mY = y; + var type = typeMap[nType + sClass]; + var scale = 5 + Math.random() * 10; + var shift = 2; + + this.fragments.push(new ExplosionFragment(type, sClass, mX, mY, -rnd(scale), -rnd(scale))); + this.fragments.push(new ExplosionFragment(type, sClass, mX, mY, plusMinus(rnd(shift)), -rnd(scale))); + this.fragments.push(new ExplosionFragment(type, sClass, mX, mY, rnd(scale), -rnd(scale))); + + this.fragments.push(new ExplosionFragment(type, sClass, mX, mY, -rnd(scale), plusMinus(rnd(shift)))); + this.fragments.push(new ExplosionFragment(type, sClass, mX, mY, plusMinus(rnd(shift)), plusMinus(rnd(shift)))); + this.fragments.push(new ExplosionFragment(type, sClass, mX, mY, rnd(scale), plusMinus(rnd(shift)))); + + this.fragments.push(new ExplosionFragment(type, sClass, mX, mY, rnd(scale), -rnd(scale))); + this.fragments.push(new ExplosionFragment(type, sClass, mX, mY, rnd(scale), plusMinus(rnd(shift)))); + this.fragments.push(new ExplosionFragment(type, sClass, mX, mY, rnd(scale), rnd(scale))); + + this.init = function() { + for (var i = self.fragments.length; i--;) { + self.o.appendChild(self.fragments[i].o); + } + if (!IS_MOON_COMPUTER) { + // faster rendering, particles get cropped + xlsf.oExplosionTarget.appendChild(self.o); + } else { + // slower rendering, can overlay body + xlsf.oExplosionTarget.appendChild(self.o); + } + } + + this.reset = function() { + // clean-up + // self.o.parentNode.removeChild(self.o); + self.o.style.display = 'none'; + self.o.style.marginLeft = '0px'; + self.o.style.marginTop = '0px'; + self.o.style.left = self.x + 'px'; + self.o.style.top = self.y + 'px'; + if (!isIE) self.o.style.opacity = 1; + for (var i = self.fragments.length; i--;) { + self.fragments[i].reset(); + } + } + + this.trigger = function(boxVX, boxVY) { + self.o.style.display = 'block'; + self.boxVX = boxVX; + self.boxVY = boxVY; + // boundary checks + if (self.sClass == 'right') { + self.boxVX = Math.abs(self.boxVX) * -1; + } else if (self.sClass == 'left') { + self.boxVX = Math.abs(self.boxVX); + } + for (var i = self.fragments.length; i--;) { + self.fragments[i].animate(); + } + if (!isIE && (IS_MOON_COMPUTER)) { + var oAExplode = new Y.Anim({ + node: Y.one(o), + to: { + marginLeft: 100 * self.boxVX, + marginTop: 150 * self.boxVY, + opacity: 0.01 + }, + duration: animDuration, + easing: Y.Easing.easeInStrong + }); + } else { + // even IE 7 sucks w/alpha-transparent PNG + CSS opacity. Boourns. + var oAExplode = new Y.Anim({ + node: Y.one(self.o), + to: { + marginLeft: 100 * self.boxVX, + marginTop: 150 * self.boxVY + }, + duration: animDuration, + easing: Y.Easing.easeInStrong + }); + } + oAExplode.on('end', self.reset); + oAExplode.run(); + // setTimeout(self.reset,animDuration*1000*1.5); + } + + this.init(); + + } + + function Light(sSizeClass, sClass, nType, x, y, row, col) { + var self = this; + this.o = document.createElement('div'); + this.sClass = sClass; + this.sSizeClass = sSizeClass; + this.nType = (nType || 0); + this.useY = (sClass == 'left' || sClass == 'right'); + this.state = null; + this.broken = 0; + this.w = xlsf.lightClasses[sSizeClass]; + this.h = xlsf.lightClasses[sSizeClass]; + this.x = x; + this.y = y; + this.row = row; + this.col = col; + this.bg = (window.XLSF_URL_BASE || '') + 'image/bulbs-' + this.w + 'x' + this.h + '-' + this.sClass + '.png'; + this.o.style.width = this.w + 'px'; + this.o.style.height = this.h + 'px'; + this.o.style.background = 'url(' + this.bg + ') no-repeat 0px 0px'; + this.bgBaseX = (self.useY ? -self.w * this.nType : 0); + this.bgBaseY = (!self.useY ? -self.h * this.nType : 0); + this.glassType = parseInt(Math.random() * 6); + // this.bonusSounds = ['griffin-laugh','bblaff','bblaff2']; + // this.bonusSound = null; + this.oExplosion = null; + this.soundID = 'smash' + this.glassType; + var panValue = xlsf.soundPan.panValue; // eg. +/- 80% + this.pan = parseInt(this.x <= xlsf.soundPan.mid ? -panValue + ((this.x / xlsf.soundPan.mid) * panValue) : (this.x - xlsf.soundPan.mid) / (xlsf.soundPan.right - xlsf.soundPan.mid) * panValue); + + this.setBGPos = function(x, y) { + self.o.style.backgroundPosition = ((self.bgBaseX + x) + 'px ' + (self.bgBaseY + y) + 'px'); + } + + this.setLight = function(bOn) { + if (self.broken || self.state == bOn) return false; + if (!self.w || !self.h) self.getDimensions(); + self.state = bOn; + if (self.useY) { + self.setBGPos(0, -this.h * (bOn ? 0 : 1)); + } else { + self.setBGPos(-this.w * (bOn ? 0 : 1), 0); + } + } + + this.getDimensions = function() { + self.w = self.o.offsetWidth; + self.h = self.o.offsetHeight; + self.bgBaseX = (self.useY ? -self.w * self.nType : 0); + self.bgBaseY = (!self.useY ? -self.h * self.nType : 0); + } + + this.on = function() { + self.setLight(1); + } + + this.off = function() { + self.setLight(0); + } + + this.flickr = function() { + self.setLight(Math.random() >= 0.5 ? 1 : 0); + } + + this.toggle = function() { + self.setLight(!self.state ? 1 : 0); + } + + this.explode = function(e) { + self.oExplosion.trigger(0, 1); // boooom! + } + + this.smash = function(e) { + if (self.broken) return false; + self.broken = true; + if (soundManager && soundManager.supported()) { + soundManager.play(self.soundID, { + pan: self.pan + }); + // soundManager.sounds[self.soundID].play({pan:self.pan}); + // if (self.bonusSound != null) window.setTimeout(self.smashBonus,1000); + } + self.explode(e); + var rndFrame = 2; // +parseInt(Math.random()*3); + if (self.useY) { + self.setBGPos(0, self.h * -rndFrame); + } else { + self.setBGPos(self.w * -rndFrame, 0); + } + if (!useFollow && !useAngle && transforms.prop) { + self.o.style[transforms.prop] = 'rotate(' + Math.random() * plusMinus(20) + 'deg)'; + } + xlsf.lightSmashCounter++; + for (var i = activeLights.length; i--;) { + // find this in the active array, and take it out + if (activeLights[i] === self) { + activeLights.splice(i, 1); + break; + } + } + // xlsf.doNukeCheck(); + // window.setTimeout(self.reset,3000); // respawn + } + + this.smashBonus = function() { + // soundManager.play(self.bonusSounds[self.bonusSound],urlBase+'sound/'+self.bonusSounds[self.bonusSound]+'.mp3'); + } + + this.reset = function() { + if (!self.broken) return false; + self.broken = false; + self.state = null; + xlsf.lightSmashCounter--; + // self.oExplosion.reset(); // may not be necessary + self.flickr(); + } + + this.init = function() { + self.o.className = classBase + ' ' + this.sizeClass + ' ' + this.sClass; + self.o.style.left = self.x + 'px'; + self.o.style.top = self.y + 'px'; + self.o.style.width = self.w + 'px'; + self.o.style.height = self.h + 'px'; + self.flickr(); + xlsf.oFrag.appendChild(self.o); + self.oExplosion = new Explosion(self.nType, self.sClass, self.x, self.y); + } + + this.init(); + + } // Light() + this.createLight = function(sClass, nType, x, y, row, col) { + var oLight = new Light(self.lightClass, sClass, nType, x, y, row, col); + activeLights.push(oLight); + self.lightGroups[sClass].push(oLight); + self.lights.push(oLight); + return oLight; + } + + this.rotateLights = function() { + self.lights[self.lightIndex == self.lights.length ? self.lights.length - 1 : self.lightIndex].off(); + self.lightIndex++; + if (self.lightIndex == self.lights.length) { + self.lightIndex = 0; + } + self.lights[self.lightIndex].on(); + } + + this.randomLights = function() { + self.lights[parseInt(Math.random() * self.lights.length)].toggle(); + } + + this.destroyLights = function() { + // reset counter + self.lightSmashCounter = 0; + self.startSequence(Math.random() > 0.75 ? self.destroyLight : self.destroyRandom, 33); + } + + this.destroyRandom = function() { + for (var i = 2; i--;) { + if (activeLights.length) { + activeLights[parseInt(Math.random() * activeLights.length)].smash(); + } + } + } + + this.destroyLight = function() { + var groupSize = 2; // # to smash at a time + if (self.lightSmashCounter < self.lights.length) { + var limit = Math.min(self.lightSmashCounter + groupSize, self.lights.length); + var reverseLimit = Math.max(0, self.lights.length - self.lightSmashCounter - groupSize); + for (var i = self.lightSmashCounter; i < limit; i++) { + if (self.lights[self.lightSmashCounter]) { + self.lights[self.lightSmashCounter].smash(); + } + self.lights[self.lights.length - self.lightSmashCounter].smash(); + } + } else { + self.stopSequence(); + } + } + + this.uberSmash = function() { + // make everything explode - including your CPU. + self.stopSequence(); + var ebCN = Y.D.getElementsByClassName; + /* + window.setTimeout(function(){self.smashGroup(self.lightGroups.left)},500); + window.setTimeout(function(){self.smashGroup(self.lightGroups.right)},2000); + window.setTimeout(function(){self.smashGroup(self.lightGroups.bottom)},4000); + window.setTimeout(function(){self.smashGroup(self.lightGroups.top)},6000); + */ + window.setTimeout(function() { + self.smashGroup(self.lightGroups.bottom) + }, 500); + window.setTimeout(function() { + self.smashGroup(self.lightGroups.top) + }, 3500); + + } + + this.smashGroup = function(oGroup) { + for (var i = oGroup.length; i--;) { + oGroup[i].smash(); + } + } + + this.startSequence = function(fSequence, nInterval) { + if (self.timer) self.stopSequence(); + self.timer = window.setInterval(fSequence, (typeof nInterval != 'undefined' ? nInterval : self.lightInterval)); + } + + this.stopSequence = function() { + if (self.timer) { + window.clearInterval(self.timer); + self.timer = null; + } + } + + var typeMaps = { + 'tiny': { + '0bottom': 0, + '0top': 3, + '1bottom': 1, + '1top': 2, + '2bottom': 2, + '2top': 1, + '3bottom': 3, + '3top': 0 + }, + 'other': { + '0bottom': 3, + '0top': 3, + '1bottom': 2, + '1top': 2, + '2bottom': 1, + '2top': 1, + '3bottom': 0, + '3top': 0 + } + } + + var typeMap = typeMaps[(this.lightClass === 'tiny' ? 'tiny' : 'other')]; + + var i = 0; + + /* + for (i=0; i<6; i++) { + this.createLight('left',parseInt(Math.random()*4),-2,50+i*(self.lightXY*0.7)); + this.createLight('right',parseInt(Math.random()*4),962,50+i*(self.lightXY*0.7)); + } + + for (i=0; i<27; i++) { + this.createLight('top',parseInt(Math.random()*4),20+i*(self.lightXY*0.7),23); + this.createLight('bottom',parseInt(Math.random()*4),20+i*(self.lightXY*0.7),253); + } + */ + + var j = 0; + + if (window.innerWidth || window.innerHeight) { + var screenX = window.innerWidth; // -(!isIE?24:2); + var screenY = window.innerHeight; + } else { + var screenX = (document.documentElement.clientWidth || document.body.clientWidth || document.body.scrollWidth); // -(!isIE?8:0); + var screenY = (document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight); + } + + // hack for SM2 homepage + if (document.body && document.body.className && document.body.className.match(/home/i)) { + + _id('lights').style.display = 'block'; + + // start lights to the right of

+ // offset = parseInt(document.getElementsByTagName('h1')[0].offsetWidth)+16; + var jMax = Math.floor((screenX - offset - 16) / self.lightXY); + var iMax = Math.floor((screenY - offset - 16) / self.lightXY); + + for (j = 0; j < jMax; j++) { + this.createLight('top', j % 3, offset + j * self.lightXY, 0); + // this.createLight('bottom',j%3,offset+j*self.lightXY,screenY-offset-offset+1); + } + + if (typeof isFun != 'undefined') { + for (i = 0; i < iMax; i++) { + this.createLight('left', i % 3, 0, offset + i * self.lightXY); + // this.createLight('right',i%3,screenX-offset-offset,offset+i*self.lightXY); + } + } + + + } else { + + var jMax = Math.floor((screenX) / self.lightXY); + var iMax = Math.floor((screenY - 12) / self.lightXY); + + for (i = 0; i < iMax; i++) { + for (j = 0; j < jMax; j++) { + this.createLight((i + 1) % 2 == 0 ? 'bottom' : 'top', i % 4, j * self.lightXY, i * self.lightXY, j, i); + } + } + + } + + /* + var bsCounter = 0; + for (i=0; i<8; i++) { + // plant a few random seeds.. er, sounds. + self.lights[parseInt(Math.random()*self.lights.length)].bonusSound = bsCounter++; + if (bsCounter>2) bsCounter = 0; // hack - loop through sounds + } + */ + + this.appendLights(); + + function followMouseMove(e) { + if (!self.lights.length) { + return false; + } + var x = lastMouseX; + var y = lastMouseY; + var x2 = null; + var y2 = null; + var angle = 0; + var light = null; + for (var i = self.lights.length; i--;) { + light = self.lights[i]; + if (light && !light.broken) { + x2 = light.x; + y2 = light.y; + angle = Math.atan2((y - y2), (x - x2)) * (180 / Math.PI); + if (light.col % 2 === 0) { + angle += (270 * 180 / Math.PI); + } + if (transforms.prop) { + light.o.style[transforms.prop] = 'rotate(' + angle + 'deg)'; + } + } + } + mmhTimer = null; + } + + function mouseOrTouchMove(e) { + // coordinate -> row/col check, smashy smash + var x, y, lightIndex; + if (e.targetTouches) { + if (e.targetTouches.length === 1) { + x = e.targetTouches[0].clientX - offset; + y = e.targetTouches[0].clientY; + } + } else { + x = e.clientX - offset; + y = e.clientY; + } + if (x < 0) { + // ignore off-screen values. + return; + } + lightCol = Math.floor((x / (self.lightClasses[self.lightClass] * jMax) * jMax)), lightRow = Math.floor((y / (self.lightClasses[self.lightClass] * iMax) * iMax)) + lightIndex = (jMax * lightRow) + lightCol; + if (self.lights[lightIndex]) { + self.lights[lightIndex].smash(); + } + if (useFollow) { + lastMouseX = x; + lastMouseY = y; + if (!mmhTimer) { + mmhTimer = window.setTimeout(followMouseMove, 33); // try to be nice and throttle this call, which may be expensive + } + } + } + + if (isTouchDevice) { + + document.addEventListener('touchstart', function(e) { + + // ignore pinch-to-zoom, links and so forth. + + if (e.touches && e.touches.length === 1 && e.target && e.target.nodeName !== 'A') { + + document.addEventListener('touchmove', mouseOrTouchMove, false); + document.addEventListener('touchend', function(e) { + document.removeEventListener('touchMove', mouseOrTouchMove); + }); + + mouseOrTouchMove(e); // initial touch might be a smashy one, too + e.preventDefault(); + return false; + + } + + }, false); + + } else { + + // generic event handler + + if (document.addEventListener) { + document.addEventListener('mousemove', mouseOrTouchMove, false); + } else if (document.attachEvent) { + document.attachEvent('onmousemove', mouseOrTouchMove); + } + + } + + this.startSequence(self.randomLights); + + } // --- XLSF2007() + + var xlsf = null; + + function smashInit() { + var loading = document.getElementById('loading'); + xlsf = new XLSF(document.getElementById('lights')); + window.xlsf = xlsf; // expose to global + xlsf.initSounds(); + if (loading) { + loading.style.display = 'none'; + } + } + + window.smashInit = smashInit; + + soundManager.setup({ + url: '../../swf/', + // preferFlash: true, + flashVersion: 9, + useHighPerformance: true, + wmode: 'transparent', + debugMode: false, + onready: smashInit, + ontimeout: smashInit + }); + + }); + + } + + (function() { + + // script loader helper for YUI library + // http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js + + function loadScript(sURL, onLoad) { + try { + var loadScriptHandler = function() { + var rs = this.readyState; + if (rs == 'loaded' || rs == 'complete') { + this.onreadystatechange = null; + this.onload = null; + if (onLoad) { + window.setTimeout(onLoad, 20); + } + } + } + function scriptOnload() { + this.onreadystatechange = null; + this.onload = null; + window.setTimeout(onLoad, 20); + } + var oS = document.createElement('script'); + oS.type = 'text/javascript'; + oS.setAttribute('async', true); + if (onLoad) { + oS.onreadystatechange = loadScriptHandler; + oS.onload = scriptOnload; + } + oS.src = sURL; + document.getElementsByTagName('head')[0].appendChild(oS); + } catch (e) { + // oh well + } + } + + if (typeof window.YUI === 'undefined') { + + loadScript(YUI_SEED_URL, function() { + + initChristmasLights(); + + }); + + } + + }()); + +}()); \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bg-strip-dark.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bg-strip-dark.png new file mode 100755 index 00000000..1e6e0f79 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bg-strip-dark.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/blank.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/blank.png new file mode 100755 index 00000000..078e5912 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/blank.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-32x32-bottom.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-32x32-bottom.png new file mode 100755 index 00000000..150d7fcd Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-32x32-bottom.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-32x32-left.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-32x32-left.png new file mode 100755 index 00000000..a9a04065 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-32x32-left.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-32x32-right.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-32x32-right.png new file mode 100755 index 00000000..af313069 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-32x32-right.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-32x32-top.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-32x32-top.png new file mode 100755 index 00000000..aa90b97d Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-32x32-top.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-bottom.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-bottom.png new file mode 100755 index 00000000..d3f7beee Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-bottom.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-fragments.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-fragments.png new file mode 100755 index 00000000..515bbb57 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-fragments.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-left.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-left.png new file mode 100755 index 00000000..af7d66e6 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-left.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-right.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-right.png new file mode 100755 index 00000000..f262decd Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-right.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-top.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-top.png new file mode 100755 index 00000000..b3b5797b Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50-top.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50.png new file mode 100755 index 00000000..9cd1174e Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-50x50.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-64x64-bottom.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-64x64-bottom.png new file mode 100755 index 00000000..e433692d Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-64x64-bottom.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-64x64-left.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-64x64-left.png new file mode 100755 index 00000000..6b1df77a Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-64x64-left.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-64x64-right.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-64x64-right.png new file mode 100755 index 00000000..c545a484 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-64x64-right.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-64x64-top.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-64x64-top.png new file mode 100755 index 00000000..989754cc Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-64x64-top.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-72x72-bottom.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-72x72-bottom.png new file mode 100755 index 00000000..34485096 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-72x72-bottom.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-72x72-left.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-72x72-left.png new file mode 100755 index 00000000..78578890 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-72x72-left.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-72x72-right.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-72x72-right.png new file mode 100755 index 00000000..3b714902 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-72x72-right.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-72x72-top.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-72x72-top.png new file mode 100755 index 00000000..abf299f2 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-72x72-top.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-96x96-bottom.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-96x96-bottom.png new file mode 100755 index 00000000..3be90e54 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-96x96-bottom.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-96x96-left.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-96x96-left.png new file mode 100755 index 00000000..e4a8cdd6 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-96x96-left.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-96x96-right.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-96x96-right.png new file mode 100755 index 00000000..9f34d7da Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-96x96-right.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-96x96-top.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-96x96-top.png new file mode 100755 index 00000000..b286ef1f Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/bulbs-96x96-top.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/noise-pattern.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/noise-pattern.png new file mode 100755 index 00000000..24e20821 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/image/noise-pattern.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/index.html new file mode 100755 index 00000000..0512cbb5 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/index.html @@ -0,0 +1,37 @@ + + +Smashable Christmas Lights + + + + + + + + + + + + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass0.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass0.mp3 new file mode 100755 index 00000000..c161c695 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass0.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass1.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass1.mp3 new file mode 100755 index 00000000..8d7d6b56 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass1.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass2.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass2.mp3 new file mode 100755 index 00000000..ef5f556b Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass2.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass3.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass3.mp3 new file mode 100755 index 00000000..be7886e6 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass3.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass4.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass4.mp3 new file mode 100755 index 00000000..0f328f63 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass4.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass5.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass5.mp3 new file mode 100755 index 00000000..b54513e9 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/christmas-lights/sound/glass5.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/debug.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/debug.css new file mode 100755 index 00000000..bee90c8a --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/debug.css @@ -0,0 +1,23 @@ +#soundmanager-debug { + position:fixed; + _position:absolute; /* IE <7 */ + bottom:1em; + right:1em; + width:38em; + height:30em; + overflow:auto; + padding:0px; + margin:1em; + font-family:monaco,"VT-100","lucida console",courier,system; + opacity:0.9; + color:#333; + border:1px solid #ccddee; + border-radius:3px; + background:#f3f9ff; +} + +#soundmanager-debug div { + font-size:x-small; + padding:0.2em; + margin:0px; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/basic.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/basic.html new file mode 100755 index 00000000..d2d76ba3 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/basic.html @@ -0,0 +1,37 @@ + + + +SoundManager 2: Flash blocker handling - basic example + + + + + + + + + + + + + +
+ +

SoundManager 2: Flashblock / "click to flash" handling: Basic Demo

+ +
+ +
+ +

See flashblock.css as a template for making your own SM2 + flash block implementations.

+ +
diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/flashblock.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/flashblock.css new file mode 100755 index 00000000..fa11839a --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/flashblock.css @@ -0,0 +1,130 @@ +/** + * SoundManager 2 + useFlashBlock + * ------------------------------ + * Flash positioning and flashblock / clicktoflash handling + */ + +#sm2-container { + /** + * where the SM2 flash movie goes. by default, relative container. + * set relative or absolute here, and don't touch it later or bad things will happen (see below comments.) + */ + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + /* screw IE 6, just make it display nice */ + _overflow: hidden; +} + +#sm2-container object, +#sm2-container embed { + /** + * the actual SWF movie bit. + * important: The SWF needs to be able to be moved off-screen without display: or position: changes. + * changing display: or position: or overflow: here or on parent can cause SWF reload or other weird issues after unblock + * e.g., SM2 starts but strange errors, no whileplaying() etc. + */ + width: 48px; + height: 48px; + /* some flash blockers may also respect this rule */ + max-width: 48px; + max-height: 48px; +} + +#sm2-container.swf_timedout { + /* expand to show the timed-out SWF content */ + position: relative; + width: 48px; + height: 48px; +} + +#sm2-container.swf_timedout, +#sm2-container.swf_timedout object, +#sm2-container.swf_timedout embed { + /** + * when SM2 didn't start normally, time-out case. flash blocked, missing SWF, no flash? + * 48px square flash placeholder is typically used by blockers. + */ + min-width: 48px; + min-height: 48px; +} + +#sm2-container.swf_unblocked { + /* SWF unblocked, or was never blocked to begin with; try to collapse container as much as possible. */ + width: 1px; + height: 1px; +} + +#sm2-container.swf_loaded object, +#sm2-container.swf_loaded embed, +#sm2-container.swf_unblocked object, +#sm2-container.swf_unblocked embed { + /* hide flash off-screen (relative to container) when it has loaded OK */ + left: -9999em; + top: -9999em; +} + +#sm2-container.swf_error { + /* when there is a fatal error (flash loaded, but SM2 failed) */ + display: none; +} + +#sm2-container.high_performance, +#sm2-container.high_performance.swf_timeout { + /* "high performance" case: keep on-screen at all times */ + position: absolute; + position: fixed; +} + +#sm2-container.high_performance { + overflow: hidden; + _top: -9999px; /* IE 6 hax, no position:fixed */ + _left: -9999px; + bottom: 0px; + left: 0px; + /** + * special case: show at first with w/h, hide when unblocked. + * might be bad/annoying. + * try to stay within ClickToFlash "invisible" limits (so it won't be blocked.) + */ + z-index: 99; /* try to stay on top */ +} + +#sm2-container.high_performance.swf_loaded, +#sm2-container.high_performance.swf_unblocked { + z-index: auto; +} + +#sm2-container.high_performance.swf_loaded, +#sm2-container.high_performance.swf_unblocked, +#sm2-container.high_performance.swf_unblocked object, +#sm2-container.high_performance.swf_unblocked embed { + /** + * 8x8px is required minimum to load in fx/win32 in some cases(?) + * 6x6+ good for fast performance, even better when on-screen via position:fixed + * also, clickToFlash (Safari <5.1) may auto-load "invisible" SWFs at this size + */ + height: 8px; + width: 8px; +} + +#sm2-container.high_performance.swf_loaded { + /* stay bottom/left */ + top: auto; + bottom: 0px; + left: 0px; +} + +#sm2-container.high_performance.swf_loaded object, +#sm2-container.high_performance.swf_loaded embed, +#sm2-container.high_performance.swf_unblocked object, +#sm2-container.high_performance.swf_unblocked embed { + /* high-performance case must stay on-screen */ + left: auto; + top: auto; +} + +#sm2-container.high_performance.swf_timedout { + z-index: 99; /* try to stay on top */ +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/index.html new file mode 100755 index 00000000..b09d730a --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/index.html @@ -0,0 +1,134 @@ + + + +SoundManager 2: Flash Block handling examples + + + + + + + + + + + + + + + + +
+ +

SoundManager 2: Flashblock / "click to flash" handling demos

+ +

Show SWF inline, wait indefinitely for load (click-to-run or whitelist)

+ +

You can run this demo with Flash 8 (default), Flash 9 (normal mode) or Flash 9 + highPerformance mode (higher JS callback frequency).

+ +

Where (and when) to show the SWF

+ +

To handle potential flash block cases, put <div id="sm2-container"></div> in your markup where you'd like the SWF to appear in those cases. If not specified, SM2 will create and append the #sm2-container node to the document when it starts.

+ +

When soundManager.useFlashBlock is true, SM2 will not apply styles (eg. style.position.left) directly to the flash; rather, it will assign CSS classes and you can handle it as you choose. Take a look at the related CSS file you will also need if you turn this feature on.

+ +

Handling failed start-up cases

+ +

In the blocked/failed start-up case, #sm2-container will have a class name of swf_timedout applied to it.

+ +

SM2 will start its init process, and will fire onready(), onload() and onerror() handlers accordingly. Keep in mind that while onerror() may fire at first, it may be preceded by a successful onload() if the user first loads the page and then later unblocks the flash movie.

+ +

Note that flash blockers may not run when viewing offline (via file://) content, so try viewing this demo online. For FlashBlock (under Firefox), you can also go to about:config using your address bar and change the value of flashblock.blockLocal to test while offline.

+ +

Flash Block Example

+ +

Here, Flash is appended by SM2 to the #sm2-container DIV and after a failed start attempt (if you have a blocker active), will have a swf_timedout class appended.

+ +

The SWF uses position:absolute and negative left/top values so as not to affect the normal page layout, but shifts to left:auto;top:auto (effectively left/top:0) in the blocked case, and becomes visible to the user. On a successful unblock, the movie goes back to left/top:-9999em and is hidden from view.

+ +

SoundManager 2 load status: Loading...

+ + + +
+ +
+ +

Flash Block-related CSS

+ +

When soundManager.useFlashBlock is enabled, CSS is applied to #sm2-container depending on the progress of SM2's start-up.

+

This page + demos use the rules below, fully-defined and commented in flashblock.css. Use it as a base for your own SM2 + flash block implementations.

+ +
#sm2-container {
+ /* Initial state: position:absolute/off-screen, or left/top:0 */
+}
+#sm2-container.swf_timedout {
+  /* Didn't load before time-out, show to user.
+  Maybe highlight on-screen, red border, etc..? */
+}
+#sm2-container.swf_unblocked {
+  /* Applied if movie loads successfully after
+  an unblock (flash started, so move off-screen etc.) */
+}
+#sm2-container.swf_loaded {
+  /* Applied if movie loads, regardless of whether
+  it was initially blocked */
+}
+#sm2-container.swf_error {
+  /* "Fatal" error case: SWF loaded,
+  but SM2 was unable to start for some reason.
+  (Flash security or other error case.) */
+}
+#sm2-container.high_performance {
+  /* Additional modifier for "high performance" mode
+  should apply position:fixed and left/bottom 0 to stay on-screen
+  at all times (better flash performance) */
+}
+#sm2-container.flash_debug {
+  /* Additional modifier for flash debug output mode
+  should use width/height 100% so you can read debug messages */
+}
+ +

Basic Demo

+ +

For a more minimal example, see the basic flashblock demo.

+ +
diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/method1/flashblock.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/method1/flashblock.css new file mode 100755 index 00000000..d8a9e69a --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/method1/flashblock.css @@ -0,0 +1,61 @@ +#sm2-container { + /* where the SM2 flash movie goes. */ + position:relative; +} + +#sm2-container, +#sm2-container embed, +#sm2-container.swf_timedout { + /* 48px square flash placeholder is typically used by blockers */ + width:48px; + height:48px; +} + +#sm2-container.swf_timedout { + /* likely a flash block situation. Maybe make it more bold, red, show descriptive nested elements? */ + border:1px solid red; +} + +#sm2-container object, +#sm2-container embed { + /* hide flash off-screen by default */ + position:absolute; + left:-9999em; + top:-9999em; +} + +#sm2-container.swf_timedout object, +#sm2-container.swf_timedout embed { + /* when blocked, make visible inside container */ + left:auto; + top:auto; +} + +#sm2-container object, +#sm2-container embed { + /* 6x6 is small enough to be "invisible" and not blocked by click2flash if allowed, also enough to be really fast/performant on-screen */ + width:48px; + height:48px; +} + +#sm2-container.swf_unblocked, +#sm2-container.swf_unblocked object, +#sm2-container.swf_unblocked embed { + width:6px; + height:6px; +} + +#sm2-container.high_performance { + position:absolute; + position:fixed; + _top:0px; /* IE 6 hax */ + bottom:0px; + left:0px; +} + +#sm2-container.high_performance object, +#sm2-container.high_performance embed { + position:absolute; + left:0px; + top:0px; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/method1/flashblock.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/method1/flashblock.js new file mode 100755 index 00000000..f6baa5c5 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/method1/flashblock.js @@ -0,0 +1,90 @@ +/* + + FlashBlock handler for SoundManager 2 + ------------------------------------------------------------------- + Attempt to handle and gracefully recover from flashblock conditions + Requires SoundManger v2.95a.20090717+ + + http://schillmania.com/projects/soundmanager2/ + +*/ +soundManager._flashBlock = new function() { + + var _s = this; + this.name = 'soundManager._flashblock'; + this.didTimeout = false; // did initial attempt fail? + this.timer = null; // for setTimeout call + + this.startTimer = function(nMsec) { + // soundManager._wD(_s.name+'_.starttimer()'); + _s.timer = window.setTimeout(_s.checkFlashStatus,nMsec); + }; + + this.stopTimer = function() { + // soundManager._wD(_s.name+'.stoptimer()'); + if (_s.timer) { + window.clearTimeout(_s.timer); + _s.timer = null; + } + }; + + this.checkFlashStatus = function() { + // soundManager._wD(_s.name+'.checkflashstatus()'); + var _sm = soundManager; + var oMC = _sm.oMC; // DIV (default: #sm2-container) for .SWF + var oStatus = document.getElementById('sm2-status'); // demo-only + + if (!_sm.ok()) { + // make the movie more visible, so user can fix + oMC.className = 'swf-timedout'; + _s.didTimeout = true; + var msg = 'No flash response, applying .swf-timedout CSS..'; + _sm._wD(_s.name+': '+msg); + if (oStatus) { + oStatus.innerHTML = ''+msg+''; + } + } else { + // SM2 loaded OK + // move the movie container to its proper place + oMC.className = 'swf-loaded'; + if (!_s.didTimeout) { + // SM2 didn't previously fail, no blocker active + var msg = 'SM2 loaded OK (before timeout), fast unblock or no blocker.'; + _sm._writeDebug(_s.name+'.checkFlashStatus: '+msg,1); + if (oStatus) { + oStatus.innerHTML = ''+msg+''; + } + } else { + var msg = 'SM2 recovered after block (or timeout), loaded OK.'; + _sm._wD(_s.name+': '+msg); + if (oStatus) { + oStatus.innerHTML = ''+msg+''; + } + } + // stop timer, if applicable + _s.stopTimer(); + return false; + } + }; + + soundManager.flashLoadTimeout = 0; // wait forever for flash to load - we'll set our own timeout via oninitmovie() + + soundManager.oninitmovie = function() { + // when SWF is written (or ready to start), wait and make SWF visible (time-out case) + soundManager._flashBlock.startTimer(750); + }; + + soundManager.onready(function() { + // SM2 has now initialized, either no blocking OR blocked movie was allowed/whitelisted + var fb = soundManager._flashBlock; + // Yay! recovered OK. + fb.checkFlashStatus(); + }); + + soundManager.ontimeout(function() { + // Blocking was passed (or no blocking), but then something *else* went wrong. + // stop timer, if applicable + fb.stopTimer(); + }); + +}(); diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/method1/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/method1/index.html new file mode 100755 index 00000000..c45a7932 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/flashblock/method1/index.html @@ -0,0 +1,85 @@ + + + +SoundManager 2: Flash blocker handling examples + + + + + + + + + + + + + + + + +
+ +

SoundManager 2: Flashblock / "click to flash" handling demos

+ +

Show SWF inline, wait indefinitely for load

+ +

You can run this demo with Flash 8 (default), Flash 9 (normal mode) or Flash 9 + highPerformance mode (higher JS callback frequency).

+ +

Typically SM2 appends a DIV and hides the SWF off-screen. To handle potential flash block cases, a flash container DIV with an ID of "sm2-container" is placed in the HTML. SM2 will find and append the flash movie to this element. In this case, the SWF can be targeted with CSS and is not positioned off-screen as it normally would be.

+

SM2 will start its init process, and will fire onready(), onload() and onerror() handlers accordingly. Keep in mind that while onerror() may fire at first, it may be preceded by a successful onload() if the user first loads the page and then later unblocks the flash movie.

+

Note that flash blockers may not run when viewing offline (via file://) content, so try viewing this demo online. For FlashBlock (under Firefox), you can also adjust flashblock.blockLocal under about:config in the address bar to test while offline.

+ +

CSS applied to #sm2-container, depending on state:

+
#sm2-container.movieContainer {/* Initial state: position:absolute/off-screen, or inline/relative */}
+#sm2-container.swf_timedout {/* Didn't load before time-out, show to user: On-screen, red border, etc..? */}
+#sm2-container.swf_unblocked {/* Applied if a timeout followed by an unblock (flash started.) Move off-screen. */}
+#sm2-container.high_performance {/* Additional modifier for "high performance" mode, should apply position:fixed and left/bottom 0 to stay on-screen at all times (better flash performance) */}
+#sm2-container.flash_debug {/* Additional modifier for flash debug output mode, should use width/height 100% so you can read debug messages */}
+#sm2-container.swf_error {/* Additional modifier, "something really broke" (fatal: security, missing SWF etc.) */}
+ +

SoundManager 2 load status: Loading...

+ +

Take a look at flashblock.css for implementation details.

+ +
+ +
+ +
diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index-rollup.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index-rollup.css new file mode 100755 index 00000000..016f7641 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index-rollup.css @@ -0,0 +1,39 @@ +/** + * SoundManager 2 homepage demo CSS + * -------------------------------- + * MP3 player button, Muxtape/page player, + * inline player and 360 player demo bits + * combined and minified for optimal performance. + * For raw source, see individual demo pages. + * -------------------------------- + * Source files: + * demo/play-mp3-links/css/inlineplayer.css + * demo/page-player/css/page-player.css + * demo/360-player/360player.css + * demo/360-player/360player-visualization.css + * demo/mp3-player-button/css/mp3-player-button.css + * demo/flashblock/flashblock.css + * demo/index/index.css + */ + +@font-face { + /* + * 'Chunk' font by Meredith Mandel - http://work.meredithmandel.com/#379252/Typeface-Chunk-Five + * http://www.theleagueofmoveabletype.com/fonts/4-chunk + * Provided under the SIL Open Font License (OFL) + * http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL&_sc=1 + */ + font-family: 'ChunkFiveRegular'; + src: url('_image/chunk-webfont.woff') format('woff'), + url('_image/chunk-webfont.ttf') format('truetype'), + url('_image/chunk-webfont.svg#ChunkFiveRegular') format('svg'); + font-weight: normal; + font-style: normal; +} +ul.flat{list-style-type:none;padding-left:0}ul.flat li,ul.graphic li{padding-bottom:1px}ul.flat li a{display:inline-block;padding:2px 4px 2px 4px}ul.graphic{list-style-type:none;padding-left:0;margin-left:0}ul.graphic{list-style-type:none;margin:0;padding:0}ul.graphic li{margin-bottom:2px}ul.graphic li a,ul.graphic li a.sm2_link{display:inline-block;padding-left:22px;min-height:16px;vertical-align:middle;background-color:#369;border-radius:3px;padding:3px 3px 3px 25px;min-width:19em;_width:19em;text-decoration:none;font-weight:normal;color:#f6f9ff}ul.graphic li a.sm2_link{-webkit-transition-property:hover;-webkit-transition:background-color .15s linear;-moz-transition:background-color .15s linear 0s;-o-transition-property:background-color;-o-transition-duration:.15s}ul.graphic li a,ul.graphic li a.sm2_paused:hover,ul.graphic li a.sm2_link:hover{background-image:url(play-mp3-links/image/icon_play.png);background-position:3px 50%;background-repeat:no-repeat;_background-image:url(play-mp3-links/image/icon_play.gif)}ul.graphic li a.sm2_link:hover{background-color:#036;color:#fff}ul.graphic li a.sm2_paused{background-color:#999}ul.graphic li a.sm2_paused:hover{background:#036 url(play-mp3-links/image/icon_play.png) no-repeat 3px 50%;_background-image:url(play-mp3-links/image/icon_play.gif)}ul.graphic li a.sm2_playing,ul.graphic li a.sm2_playing:hover{background:#036 url(play-mp3-links/image/icon_pause.png) no-repeat 3px 50%;_background-image:url(play-mp3-links/image/icon_pause.gif);text-decoration:none}body #sm2-container object,body #sm2-container embed{left:-9999em;top:-9999em}ul.flat a.sm2_link{border-left:6px solid #999;padding-left:4px;padding-right:4px}ul.flat a.sm2_link:hover{border-left-color:#333}ul.flat a.sm2_playing{border-left-color:#66f;background-color:#000;color:#fff;text-decoration:none}ul.flat a.sm2_playing:hover{border-left-color:#c33}ul.flat a.sm2_paused{background-color:#666;color:#fff;text-decoration:none}ul.flat a.sm2_paused:hover{border-left-color:#3c3}.spectrum-container{display:none}ul.use-spectrum li.sm2_playing .spectrum-container{position:absolute;left:0;top:0;margin-left:-266px;margin-top:-1px;display:block;background-color:#58b;border:1px solid #9cf;border-radius:4px}ul.use-spectrum .spectrum-box{position:relative;width:255px;font-size:1em;padding:2px 0;height:1.2em;overflow:hidden}ul.use-spectrum .spectrum-box .spectrum{position:absolute;left:0;top:-2px;margin-top:20px;display:block;font-size:1px;width:1px;height:1px;overflow:hidden;background-color:#fff}ul.playlist{list-style-type:none;margin:0;padding:0}ul.playlist li{position:relative;display:block;width:auto;font-size:2em;color:#666;padding:.25em .5em .25em .5em;border:0;letter-spacing:-1px;background-color:#f9f9f9;-webkit-transition-property:hover;-webkit-transition:background-color .15s ease-in-out;-moz-transition:background-color .15s linear 0s;-o-transition-property:background-color;-o-transition-duration:.15s}ul.playlist li a{display:block;text-decoration:none;font-weight:normal;color:#000;font-size:120%;outline:0;position:relative;z-index:2}ul.playlist li.sm2_playing,ul.playlist li.sm2_paused,ul.playlist li.sm2_playing a{color:#fff;border-radius:3px}ul.playlist li:hover{background-color:#eee}ul.playlist li:hover a{color:#333}ul.playlist li.sm2_playing,ul.playlist li.sm2_playing:hover{background-color:#69c}ul.playlist li.sm2_paused{background-color:#999}ul.playlist li.sm2_playing:hover a,ul.playlist li.sm2_paused a{color:#fff}ul.playlist li .controls{display:none}ul.playlist li .peak,ul.playlist.use-peak li .peak{display:none;position:absolute;top:.55em;right:.5em}ul.playlist li.sm2_playing .controls,ul.playlist li.sm2_paused .controls{position:relative;display:block}ul.playlist.use-peak li.sm2_playing .peak,ul.playlist.use-peak li.sm2_paused .peak{display:inline;display:inline-block}ul.playlist.use-peak li .peak{display:none}ul.playlist li.sm2_paused .controls{background-color:#666}ul.playlist li:hover .controls .statusbar{position:relative;cursor:ew-resize;cursor:-moz-grab;cursor:grab}ul.playlist li.sm2_paused .controls .statusbar{background-color:#ccc}ul.playlist li .controls{position:relative;margin-top:.25em;margin-bottom:.25em;background-color:#9cf}ul.playlist li .controls .statusbar{position:relative;height:.5em;background-color:#cdf;border:2px solid #fff;border-radius:2px;overflow:hidden;cursor:-moz-grab;cursor:grab}ul.playlist li .controls.dragging .statusbar{cursor:-moz-grabbing;cursor:grabbing}ul.playlist li .controls .statusbar .position,ul.playlist li .controls .statusbar .loading,ul.playlist li .controls .statusbar .annotation{position:absolute;left:0;top:0;height:.5em}ul.playlist li .controls .statusbar .position{background-color:#369;border-right:3px solid #369;border-radius:3px}ul.playlist li.sm2_paused .controls .statusbar .position{background-color:#666;border-color:#666}ul.playlist li .controls .statusbar .loading{background-color:#eee}ul.playlist li .controls .statusbar .position,ul.playlist li .controls .statusbar .loading{width:0}ul.playlist li.sm2_playing a.sm2_link,ul.playlist li.sm2_paused a.sm2_link{margin-right:4.5em}ul.playlist li .timing{position:absolute;display:none;text-align:right;right:1em;top:1em;width:auto;height:1em;padding:3px 5px;background-color:#58b;border:1px solid #9cf;border-radius:4px;letter-spacing:0;font:44% monaco,"VT-100","lucida console",courier,system;line-height:1em;vertical-align:middle}ul.playlist.use-peak li .timing{right:4.25em}ul.playlist li:hover .timing{z-index:2}ul.playlist li .timing div.sm2_timing{margin:0;padding:0;margin-top:-1em}ul.playlist li.sm2_playing .timing,ul.playlist li.sm2_paused .timing{display:block}ul.playlist li.sm2_paused .timing .sm2_position{text-decoration:blink}ul.playlist li.sm2_paused .timing,ul.playlist.use-peak li.sm2_paused .peak{background-color:#888;border-color:#ccc}ul.playlist.use-peak li .peak{display:none;zoom:1;border:1px solid #9cf;padding:2px;height:.55em;border-radius:4px;background-color:#58b;width:.8em;height:.55em;margin-top:-3px}ul.playlist.use-peak li .peak-box{position:relative;width:100%;height:.55em;overflow:hidden}ul.playlist li .peak .l,ul.playlist li .peak .r{position:absolute;left:0;top:0;width:7px;height:50px;background:#fff;border:1px solid #fff;border-radius:1px;margin-top:1em}ul.playlist li .peak .l{margin-right:1px}ul.playlist li .peak .r{left:10px}#control-template{display:none}.ui360,.sm2-360ui{position:relative}.ui360,.sm2-360ui{min-width:50px;min-height:50px}.sm2-360ui{width:50px;height:50px}.ui360,.ui360 *{vertical-align:middle}.sm2-360ui{position:relative;display:inline-block;float:left;*display:inline}.sm2-360ui.sm2_playing,.sm2-360ui.sm2_paused{z-index:10}.ui360 a{float:left;display:inline;position:relative;color:#000;text-decoration:none;left:3px;top:18px;text-indent:50px}.ui360 a.sm2_link{text-indent:0}.ui360 a,.ui360 a:hover,.ui360 a:focus{padding:2px;margin-left:-2px;margin-top:-2px}.ui360 a:hover,.ui360 a:focus{background:#eee;border-radius:3px;outline:0}.ui360 .sm2-canvas{position:absolute;left:0;top:0}.ui360 .sm2-timing{position:absolute;display:block;left:0;top:0;width:100%;height:100%;margin:0;font:11px "helvetica neue",helvetica,monaco,lucida,terminal,monospace;color:#666;text-align:center;line-height:50px}.ui360 .sm2-timing.alignTweak{text-indent:1px}.ui360 .sm2-cover{position:absolute;left:0;top:0;width:100%;height:100%;z-index:2;display:none;background-image:url(data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==)}.ui360 .sm2-360btn{position:absolute;display:block;top:50%;left:50%;width:50px;height:50px;margin-left:-25px;margin-top:-25px;border-radius:25px;cursor:pointer;z-index:3}.ui360 .sm2-360data{display:inline-block;font-family:helvetica}.sm2-inline-block .ui360 .sm2-360btn,.ui360 .sm2-360ui.sm2_playing .sm2-360btn,.ui360 .sm2-360ui.sm2_paused .sm2-360btn{width:22px;height:22px;margin-left:-11px;margin-top:-11px}.ui360 .sm2-360ui.sm2_playing .sm2-cover,.ui360 .sm2-360ui.sm2_paused .sm2-cover{display:block} +.ui360,.ui360 .sm2-360btn-default,.ui360 .sm2-360ui.sm2_paused .sm2-360btn{background:transparent url(360-player/360-button-play.png) no-reoeat;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAYAAADEtGw7AAABoUlEQVR42sWVu2oCQRhGU/s8gpVYJeQJNkZSbiH4QNuLlQZS21sJayGYaOEFVFDxNiremj9zig2uzk5YQpKFg8PMd75ZZle9E5Ff4e+Ll8tlQuNoPI2vUcCYOdbIxCmm9F5T0YgNMmS/LebSwWdNa7VayXq9ls1mI9vtVna7nQBj5lgjQxYHN7KY3QkiUbDf7+V4PMrpdArBHGtkyOJc3/n1mVaUUl+F5/PZSrABDi4dpmKH3QkixQEHlw5TsccZmsRCoSD1et1ajkuHqdg/HA5GKZPJCOTzeanVasYMLh2mYsXDIGAoDuG6rlSr1WCdBxrcsTIWazgrQiHS6bSRYJ3XDzeq2O/3+9Ltdm9IpVIhstmslEqlUAY36ii8ZrMpjUbjhmQyKeA4jhSLRWMGN+rhOZ1Oh8ANuVxOyuUy40hwo163RK/XeyPQbrdjgYNr/ILAYDB41Gf1wZnFAQfX+iM0HA5fxuPx+2g0Ej22QoYsDq61mGsymTxMp9NX/Sk2yJDFsRZfXpzXbDZ7WiwW3nw+9zUKGDPHGpkL5V//mn7OJyJZApyzeUS5AAAAAElFTkSuQmCC);*background-image:url(360-player/360-button-play.png);background-repeat:no-repeat}.ui360{background-position:14px 50%;_background:transparent url(360-player/360-button-play.gif) no-repeat 14px 50%}.ui360 .sm2-360btn-default,.ui360 .sm2-360ui.sm2_paused .sm2-360btn{background-position:50% 50%;_background:transparent url(360-player/360-button-play.gif) no-repeat 50% 50%}.ui360 .sm2-360btn-default,.ui360 .sm2-360ui.sm2_paused .sm2-360btn{cursor:pointer}.ui360 .sm2-360btn-default:hover,.ui360 .sm2-360ui.sm2_paused .sm2-360btn:hover{background:transparent url(360-player/360-button-play-light.png) no-repeat 50% 50%;_background:transparent url(360-player/360-button-play.gif) no-repeat 50% 50%;cursor:pointer}.ui360 .sm2-360ui.sm2_playing .sm2-360btn:hover,.ui360 .sm2-360btn-playing:hover{background:transparent url(360-player/360-button-pause-light.png) no-repeat 50% 50%;_background:transparent url(360-player/360-button-pause-light.gif) no-repeat 50% 50%;cursor:pointer}.ui360 .sm2-360ui.sm2_playing .sm2-timing{visibility:visible}.ui360 .sm2-360ui.sm2_buffering .sm2-timing{visibility:hidden}.ui360 .sm2-360ui .sm2-timing,.ui360 .sm2-360ui .sm2-360btn:hover+.sm2-timing,.ui360 .sm2-360ui.sm2_paused .sm2-timing{visibility:hidden}.ui360 .sm2-360ui.sm2_dragging .sm2-timing,.ui360 .sm2-360ui.sm2_dragging .sm2-360btn:hover+.sm2-timing{visibility:visible}.ui360 .sm2-360ui.sm2_playing .sm2-360btn,.ui360 .sm2-360ui.sm2_dragging .sm2-360btn,.ui360 .sm2-360ui.sm2_dragging .sm2-360btn:hover,.ui360 .sm2-360ui.sm2_dragging .sm2-360btn-playing:hover{background:transparent;cursor:auto}.ui360 .sm2-360ui.sm2_buffering .sm2-360btn,.ui360 .sm2-360ui.sm2_buffering .sm2-360btn:hover{background:transparent url(360-player/icon_loading_spinner.gif) no-repeat 50% 50%;opacity:.5;visibility:visible}.sm2-inline-list .ui360,.sm2-inline-block .ui360{position:relative;display:inline-block;float:left;_display:inline;margin-bottom:-15px}.sm2-inline-list .ui360{margin-right:-2px}.sm2-inline-block .ui360{margin-right:8px}.sm2-inline-list .ui360 a{display:none}ul.ui360playlist{list-style-type:none}ul.ui360playlist,ul.ui360playlist li{margin:0;padding:0}div.ui360 div.metadata{display:none}div.ui360 a span.metadata,div.ui360 a span.metadata *{vertical-align:baseline}.ui360-vis,.ui360-vis .sm2-360ui,.sm2-inline-list .ui360-vis{width:256px;height:256px}.ui360-vis{position:relative;padding-top:1px;padding-bottom:1px;margin-bottom:-18px;padding-left:248px;margin-left:0;background-position:22.6% 50%}.sm2-inline-list .ui360-vis{cursor:pointer}.ui360-vis a{font:14px "helvetica neue",helvetica,monaco,lucida,terminal,monospace;white-space:nowrap;text-indent:0;top:46%}.sm2-inline-list .ui360-vis a{line-height:256px;top:auto}.ui360-vis .sm2-360ui{margin-left:-256px}.ui360-vis .sm2-timing{font:bold 24px "helvetica neue",helvetica,monaco,lucida,terminal,monospace;color:#333;text-align:center;line-height:256px;text-indent:0}.sm2-inline-list .ui360-vis,.sm2-inline-list .ui360-vis .sm2-360ui{margin-left:0}.sm2-inline-list .ui360-vis{margin:8px 13px 7px 0;padding-left:0;background-position:50% 50%}.sm2-inline-list .ui360-vis .sm2-360ui{border:1px solid #eee;margin-left:-1px;margin-top:-1px}.sm2-inline-list .ui360-vis a{position:absolute;display:inline;left:0;bottom:0;top:1px;width:100%;height:99%;*height:256px;overflow:hidden;font-size:small;font-weight:300;color:#333;margin:0;padding:0;line-height:488px;*line-height:480px;text-align:center;border-radius:0}.sm2-inline-list .ui360 a:hover{background-color:transparent}.sm2-inline-list .ui360-vis:hover .sm2-360ui,.sm2-inline-list .ui360-vis a.sm2_link:hover,.sm2-inline-list .ui360-vis a.sm2_link:active,.sm2-inline-list .ui360-vis a.sm2_link:focus{background-color:transparent}.sm2-inline-list .ui360-vis:hover a.sm2_link{background-color:#fafafa;*background-color:transparent}.ui360-vis .sm2-360btn,.ui360-vis .sm2-360ui.sm2_paused .sm2-360btn,.ui360-vis .sm2-360ui.sm2_playing .sm2-360btn{width:48px;height:48px;margin-left:-24px;margin-top:-24px;border-radius:none}.ui360-vis,.ui360-vis .sm2-360ui.sm2_paused .sm2-360btn,.ui360-vis .sm2-360btn-default{background:transparent url(360-player/360-button-vis-play.png) no-repeat 50% 50%;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAABuVBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADv7++lpaXr6+uAgIDk5OQzMzPt7e1tbW3n5+dgYGDW1tZNTU10dHQ5OTnw8PCvr6/e3t6JiYlAQEDb29vo6OgrKyuqqqrq6uq4uLjf399AQEDGxsbq6uqAgIDY2Nje3t61tbXp6enU1NTu7u7r6+vl5eXt7e2fn5/n5+fDw8Ph4eHv7+/t7e3CwsLW1tbu7u7b29vw8PDm5uYgICDp6enY2Nji4uLo6Ojm5uakpKTS0tLPz8/h4eHw8PDs7Ozj4+Pa2trg4ODx8fHT09Pk5OTPz8/S0tLBwcGmpqawsLCOjo7h4eHn5+fo6OgAAADY2NjNzc3n5+cAAADd3d3Gxsbu7u7t7e0AAADX19fl5eXi4uLf39/Hx8fn5+fs7Ozg4ODR0dHX19e4uLjv7+/z8/P09PTy8vL19fXv7+/n5+fx8fH29vbs7Ozq6urm5ubo6Ojw8PDu7u7p6enr6+sAAAB/f3/Z2dn39/fh4eGOjo4ODg7t7e3l5eWWlpba2tqjo6NVVVXk5OTe3t65ubnMzMzExMTf39/GxsampqZiYmJNcTiZAAAAbXRSTlMAAQIEAwcFCAb5EdAImAXpB6oIUAoLCfsgZQ0EVrsGEr4ZYQgbsgpUYxikNd/aatQQli+R7rlUUdas6+8I+VaFruoOOV/S8Nq5sWL8UqmKUFsuHyTcrtsJm0z7C49V3NMKkdKXuk7S7oVeVSv7tAAEVwAAAu5JREFUeF6llmVz3DwURmNLsr1pmJmZmZmxzMwsybS8gXJfhl9cKXbHEK+TmZ4P/nDnOXN1NbalHD8CQ7QRGDmhnIQhBDYQnkhheRECSVIQQrLMHookAciUkHhBw1zVwuLShcJIpPDC0uJC1VxDQTaFx1srSvM3DUxU1TRVlWBjM7+0opUrQaupLSnrLK7ELIepwaCYmbiyuLOspJY38eeLykdGxzDhYQfKCmOjI+VFPkMQYF7NZD0l2DgFJrR+siYPegxBzBvqeoQxpgGw8qOuoTz3HGw9udUPCaFZIORhdS5blZOHjXWDBIdABusanb0S4MpqEw4XcNPqCrQFQQTN+XwPQ8CY5jcDUbB3KLdlg6hnQDZacqEgWA3a2rF6Jri9zWohwI6dXXK2QHZ3OqBw0qC7B6vnAPd0sxZMkHr7VNPD34YZgNrXK3EBSgPU9HJ4eIQDDDogQS4ow4QJxy4+MmKs4oYJZFhhggjQuMoKHoHzn3bsQx1HQOTClOkXLP6lviZTtjCjmn7B5g/izqszliBHTB+HDhl3PSJbwnxSS3n45HDkVLXkvCWg5Uws7eHgJ98/uKqxzLI9w3o6oXuwhd+OPNVEet0WtnU9/sWNJfz1u6cY1/VtLghQuRgk/PmBmT7hogJPXo3L8YQed3Nw8PWfuB89Eb8scUGUrl33DfH/N93BGeH6NUnkArh1O5FOuNETp2GR27cAE/iaJu6mz8HdCQnan+i96XQmdgaZ9PQ9+xMVoPJgNhrNhBKNzj5Q+E/AavH4SSz6OZRo7Mlj3oDDp7jyPJoKJfr8CpvAOUrQi6eppJaVZOrpCwTdP1cgr93UjKxoN9dka2KX8ealZtBADO3lG2+e7xRAd7Y0igOg2tYdBKD/CBIBenf/lYGJD2y8uv8OgaBDDkry3v57SlQXhL7f35OlwJOXGUBBl571JykmzCIE02T/s0tIASyf/R6Arr59fcM62G+8fnsVhdwFwq4Ov345Of/15wd0RYY81HHUTQAAAABJRU5ErkJggg==);*background-image:url(360-player/360-button-vis-play.png);_background:transparent url(360-player/360-button-vis-play.gif) no-repeat 50% 50%;cursor:pointer}.ui360-vis:hover .sm2-360btn,.ui360-vis .sm2-360btn-default:hover,.ui360-vis .sm2-360ui.sm2_paused .sm2-360btn:hover{background:transparent url(360-player/360-button-vis-play-light.png) no-repeat 50% 50%;_background:transparent url(360-player/360-button-vis-play.gif) no-repeat 50% 50%;cursor:pointer}.ui360-vis .sm2-360ui.sm2_playing .sm2-360btn:hover,.ui360-vis .sm2-360btn-playing:hover{background:transparent url(360-player/360-button-vis-pause-light.png) no-repeat 50% 50%;_background:transparent url(360-player/360-button-vis-pause-light.gif) no-repeat 50% 50%;cursor:pointer}.ui360-vis{background-position:21% 50%;_background:transparent url(360-player/360-button-vis-play.gif) no-repeat 21% 50%}.ui360-vis .sm2-360btn-default{_background:transparent url(360-player/360-button-vis-play.gif) no-repeat 50% 50%}.ui360-vis .sm2-360ui.sm2_dragging .sm2-360btn{visibility:hidden}a.sm2_button{position:relative;display:inline-block;width:18px;height:18px;text-indent:-9999px;overflow:hidden;vertical-align:middle;border-radius:6px;margin-top:-1px;-webkit-transition-property:hover;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out 0s;-o-transition-property:background-color;-o-transition-duration:.15s;*text-indent:0;*line-height:99em;*vertical-align:top}a.sm2_button:focus{outline:0}a.sm2_button,a.sm2_button.sm2_paused:hover{background-color:#39c;background-image:url(mp3-player-button/image/arrow-right-white.png);background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAKCAYAAABmBXS+AAAAbklEQVQY02NgQAL//v1jZMAF/v//vwuIs9HEUBUBTbj4HwIeA3EGVsVAxtn/qOAVUGM8uknIiv4hsV8A5ZKxKfoLVvnvHwifAzLtMKwDSQLBVSBti27dJajkcSD2RJODO3wtkOOMz/tMSJJYAxMA5dmsL0IfubQAAAAASUVORK5CYII=);*background-image:url(mp3-player-button/image/arrow-right-white.gif);background-repeat:no-repeat;background-position:5px 50%;*background-position:5px 4px}a.sm2_button:hover,a.sm2_button.sm2_playing,a.sm2_button.sm2_playing:hover{background-color:#c33}a.sm2_button.sm2_playing,a.sm2_button.sm2_playing:hover{-moz-transform:rotate(90deg);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg)}a.sm2_button.sm2_paused,a.sm2_button.sm2_paused:hover{background-color:#666}#sm2-container{position:absolute;width:1px;height:1px;overflow:hidden;_overflow:hidden}#sm2-container object,#sm2-container embed{width:48px;height:48px;max-width:48px;max-height:48px}#sm2-container.swf_timedout{position:relative;width:48px;height:48px}#sm2-container.swf_timedout,#sm2-container.swf_timedout object,#sm2-container.swf_timedout embed{min-width:48px;min-height:48px}#sm2-container.swf_unblocked{width:1px;height:1px}#sm2-container.swf_loaded object,#sm2-container.swf_loaded embed,#sm2-container.swf_unblocked object,#sm2-container.swf_unblocked embed{left:-9999em;top:-9999em}#sm2-container.swf_error{display:none}#sm2-container.high_performance,#sm2-container.high_performance.swf_timeout{position:absolute;position:fixed}#sm2-container.high_performance{overflow:hidden;_top:-9999px;_left:-9999px;bottom:0;left:0;z-index:99}#sm2-container.high_performance.swf_loaded,#sm2-container.high_performance.swf_unblocked{z-index:auto}#sm2-container.high_performance.swf_loaded,#sm2-container.high_performance.swf_unblocked,#sm2-container.high_performance.swf_unblocked object,#sm2-container.high_performance.swf_unblocked embed{height:8px;width:8px}#sm2-container.high_performance.swf_loaded{top:auto;bottom:0;left:0}#sm2-container.high_performance.swf_loaded object,#sm2-container.high_performance.swf_loaded embed,#sm2-container.high_performance.swf_unblocked object,#sm2-container.high_performance.swf_unblocked embed{left:auto;top:auto} +#sm2-container.high_performance.swf_timedout{z-index:99}body{background:#fff;color:#444;margin:0;padding:0;font:76% "helvetica neue",helvetica,arial,verdana,tahoma,"sans serif";_width:99.5%;-moz-transition:font-size .1s;-webkit-transition:font-size .1s}@media all and (min-width:1280px){body{font-size:80%}}@media all and (min-width:1600px){body{font-size:90%}body.home .sm2-speaker{max-width:226px!important}#nav>ul>li>strong>a{padding-bottom:.5em!important}}@media all and (min-width:1800px){body{font-size:105%}body.home .sm2-speaker{left:-2.5%!important;margin-left:-15%!important;margin-top:20px!important}}body.home{min-width:80em}body,#main-wrapper,#nav ul li strong a{background:#fff url(../demo/_image/noise.png)}body,#main-wrapper,#nav ul li strong a{background:#fff url(../demo/_image/tiny_grid.png);background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaAgMAAADUJKRdAAAADFBMVEX8/Pz19fX09PT29vY9qbYoAAAAaElEQVR4Xk2MoREDMRADrzSDBQcEQj71GBw4kBbSQKp4YBBw9PsJyLxtsR2tZNfx/LyPhzX7R1Ue2SfjKlicDKBNdpBXsz790Nj8kUlo+WR47PvEPfY+gb7+kMhm5801EBsLvq/z3v8Apg8pkRmgbrsAAAAASUVORK5CYII=);*background:#fff url(../demo/_image/tiny_grid.png)}#nav ul li strong a{background-position:0 5px}@font-face{font-family:'DejaVuSansMonoBook';src:url('../demo/_image/dejavusansmono-webfont.eot');src:url('../demo/_image/dejavusansmono-webfont.eot?#iefix') format('embedded-opentype'),url('../demo/_image/dejavusansmono-webfont.woff') format('woff'),url('../demo/_image/dejavusansmono-webfont.ttf') format('truetype');font-weight:normal;font-style:normal}h2.special{font-family:"ChunkFive","ChunkFiveRegular","helvetica neue",helvetica,arial,verdana,tahoma,"sans serif";font-weight:normal;display:inline}h1,h2,h3,h4{font-size:1em;margin:0;padding:0;vertical-align:middle;font-weight:300}h4.new,h4.recent,h4.flash9{min-height:24px}h1{font-size:2em;font-weight:500}h2{font-size:1.5em}h3{font-size:1.17em;font-weight:bold;border-top:.25em solid #333;border-bottom:1px dotted #999;padding-top:.25em;padding-bottom:.25em;_margin-top:1.5em}body.home h3{border-top:.25em solid #444;margin-top:1.25em}#doc .c2 h3{position:relative;background:#333;color:#fff;padding:.25em .75em;border:0;line-height:1.4em}h3,.likeh3,.home .columnar .c2 #about-sm2 h3:first-child{margin-top:1.5em}h4{margin:1.5em 0 .5em 0;font-size:1.15em;font-weight:500}h5{font-size:1.2em;font-weight:500;color:#333}.c2 h5{border-bottom:1px solid #ccc;padding-bottom:.25em}.sub-heading{color:#666;font-weight:400}h2.special a{top:-0.65em}body.home #about-header{position:relative;margin-left:18%;min-height:175px;padding-top:1.75em}body.home #about-header .feature{position:relative;vertical-align:middle;font-size:1.2em}body.home .sm2-speaker{position:absolute;left:-1.5%;top:0;margin-right:2em;margin-bottom:8px;max-width:192px;min-width:64px;width:20%;margin-left:-20%}body.home .sm2-speaker img{width:100%;max-width:226px;min-width:32px}body.home #about-sm2 h2.special,body.home #about-sm2 h3,body.home #about-sm2 h4{font-weight:500;font-size:2em;border-bottom:0;padding-bottom:0}body.home #about-sm2 h2.special{font-size:3.5em;color:#333;margin-top:.1em}body.home #about-sm2 h3{font-size:2.25em}body.home #about-sm2 b{font-weight:500}body.home #about-sm2 strong{font-weight:500;color:#333}#col3 a.button,a.feature-hot,a.feature{display:inline-block;-moz-transition:all .25s ease-in-out;-webkit-transition:all .25s ease-in-out;transition:all .25s ease-in-out;text-shadow:0 1px 0 rgba(0,0,0,0.33)}@-moz-keyframes highlight{from{box-shadow:0 0 0 rgba(255,64,64,0)}to{box-shadow:0 0 16px rgba(255,64,64,0.75)}}@-webkit-keyframes highlight{from{box-shadow:0 0 0 rgba(255,64,64,0)}to{box-shadow:0 0 16px rgba(255,64,64,0.75)}}#col3 a.feature{margin-top:0}a.feature-hot:hover,a.feature:hover,#col3 a.button:hover{-moz-animation-duration:.5s;-moz-animation-name:highlight;-moz-animation-iteration-count:infinite;-moz-animation-direction:alternate;-webkit-animation-duration:.5s;-webkit-animation-name:highlight;-webkit-animation-iteration-count:infinite;-webkit-animation-direction:alternate}body.home #about-sm2 h3{color:#444;font-weight:bold;padding-bottom:0;margin-bottom:0;font-weight:300}body.home h4{border-bottom:1px solid #e9e9e9;padding-bottom:.33em;margin-bottom:.75em}body.home #about-sm2 h4{font-weight:600;color:#777;font-size:1.3em;margin-bottom:1.25em;margin-top:.15em}body.home #about-sm2 h4 b{color:#777}body.home #about-sm2 h3+h4{color:#666;font-size:1.25em;font-weight:400;margin-bottom:2em;border-bottom:1px dotted #b0b0b0;padding-bottom:.75em}body.home .demo-more,body.home .demo-more-abs{text-align:right;font-size:85%;margin-right:.25em;white-space:nowrap}body.home .demo-more-abs{position:absolute;right:0;bottom:0}body.home #about-sm2 h4.home-shopping-network{font-style:italic}em em{color:#036;background:#e9f3ff;font-weight:bold;margin-top:-0.3em;padding:.2em .25em}pre{border-left:2px solid #f3f3f3;padding-left:.5em}dl pre{border-color:#e9f3ff}dl.alt pre{border-color:#f3f3f3}pre,code,pre code,.code,.code-block,dt,#soundmanager-debug,.c3 ul li ul li{font-family:Menlo,"DejaVu Sans Mono","DejaVuSansMonoBook",monaco,"Andale Mono","VT-100","Lucida Console","Courier New",monospace,courier,system,sans-serif}pre,code,.code,dt,#soundmanager-debug{font-weight:normal;line-height:auto;color:#069;background:#f6fcff}.no-code-highlight pre,.no-code-highlight code,.no-code-highlight .code .no-code-highlight{background:transparent}pre,#soundmanager-debug{font-size:100%}body.home p code{font-size:91%}pre code{font-size:100%}pre{line-height:1.75em}pre.specialcommentblock span span{*line-height:1.75em}.block.small{font-size:92%}p pre,p.in pre{font-size:.97em}#soundmanager-debug{background:#fff;padding-left:.75em;border:2px solid #def;font-size:85%;line-height:1.7em}body.home #soundmanager-debug{position:fixed;_position:absolute;bottom:1em;right:1em;height:12em;width:auto;overflow:auto;padding:0;margin:1em 6px 6px 1em;opacity:.95;color:#333;border:1px solid #cde;border-radius:3px;background:#f3f9ff;z-index:10;font-size:85%;line-height:1.2em}body.home #soundmanager-debug div{padding-left:.5em}#soundmanager-debug div{margin:0;padding:.25em 0;font-size:100%;color:#333}#soundmanager-debug div{background-color:#fff}#soundmanager-debug div.sm2-alt{background-color:#f3f9ff;color:#369}#live-debug{display:table;*display:block}dd pre,dd code{background:transparent}pre code{font-size:1em}pre{white-space:-moz-pre-wrap;white-space:pre-wrap;word-wrap:break-word}ul.code-block em,pre span,code span,dt span{color:#393}ul.code-block em{font-style:normal}ul.code-block span,pre span span,code span span,dt span span{color:#678}pre.block,pre.block code,div.block div.code,ul.code-block{position:relative;display:table;*display:block;border:1px solid #ccc;border-radius:3px}div.block,pre.block{background:#e9f3ff;border-color:#eee;padding:3px}pre.block code,.block .code{background:#fff;border:1px solid #cde;padding:.5em;font-size:100%;line-height:1.75em;background-image:-webkit-linear-gradient(#fcfcfc 50%,#fff 50%);background-image:-o-linear-gradient(#fcfcfc 50%,#fff 50%);background-image:linear-gradient(#fcfcfc 50%,#fff 50%);background-size:100% 3.5em;background-origin:content-box}#sm2-properties .code{background-image:none}pre.block code{padding:1em}h2 code{background:0;font-size:93%}dl{background:#f9fcff;padding-bottom:1px;border:1px solid #cde;border-radius:3px;margin-top:1em}dd{margin:1em 0;padding:0 1em;line-height:1.75em}dt{padding:0;margin:0;border-bottom:1px solid #def;padding:.5em .5em .5em .75em;background:#eef6ff;font-size:1.15em}dt.alt{background:#f3f3f3;border-bottom-color:#e6e6e6}dl:nth-child(2n+1),dl.alt{background:#fcfcfc;padding:0 0 1px 0;border-color:#ddd}dl.tight dt.alt{background:#fcfcfc}#smsound-methods dl a{font-weight:normal}#smsound-methods dt:last-of-type{border-bottom:0}h2{padding-top:.5em}#top{position:relative;padding:1em 1em 0 1.5em;max-width:95.5em;color:#fff;z-index:3;margin:0 auto}#content{background:#222 url(../demo/_image/noise-dark.png)} +#top,#top div{*zoom:1}#top h1{display:inline}#top h2{font-size:1.25em;font-weight:300;padding-top:2px}#top h1,#top h2,#version{text-shadow:0 1px 0 rgba(0,0,0,0.5)}#main-wrapper{position:relative;box-shadow:inset 0 0 16px #fff}#main{position:relative;padding:0 0 2em 0;padding-top:1px;margin:0 auto;*padding:0 1em 2em 1em;zoom:1}#main{max-width:98em}body.home #main{box-shadow:none;max-width:104em}.columnar{position:relative;margin:0;padding:0;margin:1.9em .5em .5em 1em}.columnar .c1{position:absolute;left:0;top:0;width:20em;height:30px;_position:relative;_height:auto}#doc .columnar .c1{left:auto;right:1em;_right:auto}.columnar .c1 h2{position:relative;font-size:1.2em;padding:.37em .5em;vertical-align:middle;background:#333;color:#fff;text-indent:.25em}.columnar .c1 p{margin:.5em 0 1em 0;padding-left:.5em;padding-right:.5em;font-size:.95em;line-height:1.35em;color:#666}.columnar .c1 p code{color:#369}.columnar .c2{position:relative;margin-top:0;margin-left:22em;margin-bottom:1.5em}.triple .columnar .c2{margin-right:21.25em;min-width:20em}#doc .triple .columnar .c2{margin-left:21.5em;margin-right:23em;_margin-right:0}#doc.special .triple .columnar .c2{margin-right:.75em;max-width:70em}#doc .triple .columnar .c1{margin-right:0;margin-left:21.25em}.columnar .c2 p:first-child{margin-top:.2em}.columnar .c2>.f-block:first-child>h4{margin-top:.5em}.columnar .c2 strong strong{display:block;padding:.5em;border-bottom:1px solid #999;background:#f0f6ff;color:#369}.columnar .c2 p{line-height:1.75em;padding-top:.25em;padding-bottom:.25em}p code,.columnar .c2 p code{font-size:97%}.three .columnar{position:relative}.three .columnar .c1{position:relative;width:20em}.three .columnar .c2{position:relative;margin-right:16em}.c3{position:absolute;right:1em;margin-right:16px;top:2em;width:16em;margin-top:-0.5em}#doc .c3{right:auto;margin-right:0;margin-left:16px;left:1.25em;z-index:1}#nav{position:relative;margin-top:.75em;margin-left:-0.5em}ul{line-height:1.75em}ul li{margin-bottom:.75em}#nav ul{margin:0;padding:0;line-height:1em;list-style-type:none}#nav ul li{position:relative;margin:0;padding:0;float:left;display:inline;padding-right:1px}#nav ul li ul{position:absolute;z-index:1;display:none;min-width:19em;max-width:21em;background:#39c;background:-moz-linear-gradient(top,rgba(51,153,204,0.99) 0,rgba(35,96,127,0.96) 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,rgba(51,153,204,0.99)),color-stop(100%,rgba(35,96,127,0.96)));background:-webkit-linear-gradient(top,rgba(51,153,204,0.99) 0,rgba(35,96,127,0.96) 100%);background:-o-linear-gradient(top,rgba(51,153,204,0.99) 0,rgba(35,96,127,0.96) 100%);background:-ms-linear-gradient(top,rgba(51,153,204,0.99) 0,rgba(35,96,127,0.96) 100%);background:linear-gradient(top,rgba(51,153,204,0.99) 0,rgba(35,96,127,0.96) 100%);text-shadow:0 1px 0 rgba(0,0,0,0.25);_width:19em;*top:2.3em;*left:0}#nav ul li:last-child ul{right:1px}#nav ul li:hover ul,#nav ul li ul:hover{display:block}#nav ul li ul li{float:none;display:block;width:100%}#nav ul li ul li a{display:block;width:auto;border:0;padding:.5em 0 .5em 1em;font-size:1.1em;line-height:1.1em;color:#fff;font-weight:300;color:rgba(255,255,255,0.9);border-bottom:1px dotted rgba(0,0,0,0.2);border-top:1px dotted rgba(255,255,255,0.2)}#nav ul li ul li:first-of-type a{border-top:0}#nav ul li a{display:inline-block;padding:.5em 1em;text-decoration:none;font-weight:bold;color:#fff}#nav ul li ul li a:hover{background-color:#369;background-color:rgba(0,0,0,0.45)}#nav>ul>li>a,#nav>ul>li>strong>a{color:#ddd;font-size:1.25em;font-weight:300;vertical-align:bottom}#nav ul li strong a{color:#333}#nav>ul>li>strong>a{padding-bottom:8px}#nav ul li a:hover,#nav>ul>li:hover>a{background:#39c;color:#fff;text-shadow:0 1px 0 rgba(0,0,0,0.25)}#version{position:relative;float:right;display:inline;margin-left:1em;font-size:85%;margin-bottom:0;bottom:-1em;color:#999}div.clear{clear:both;font-size:1px;line-height:1px}.note{margin-top:.5em;font-size:.95em;color:#999}.note a{color:#666;padding:1px;margin:-1px}.note a:hover{color:#fff;background:#666}.medium-note{padding-top:1.5em;font-size:1em}ul.standard{line-height:1.5em;padding-left:1.2em;*padding-left:0;color:#333;margin-top:1em;margin-bottom:1em;list-style-type:square}ul.standard li{margin-bottom:.5em}ul.standard ul{margin-top:.5em;margin-bottom:1.5em;padding-left:1.2em}.c3 ul{list-style-type:none}.c3 ul,.c3 ul li{margin:0;padding:0}.c3 h2{font-size:1.1em;text-indent:.4em}.c3 ul li a{display:block;text-decoration:none}.c3 ul li,.c3 ul li a,.c3 ul li a:hover,.c3 ul li a:focus{color:#555;_color:#555;outline:0}.c3 ul li.active{box-shadow:0 0 6px #036 inset;border-radius:1px}.c3 ul li.active a{border-radius:2px;text-shadow:0 1px 0 rgba(0,0,0,0.25)}.c3 ul li.active,.c3 ul li.active a,.c3 ul li ul li:hover,.c3 ul li ul li:hover a{color:#fff}.c3 ul li.active a:hover{_color:#fff}.c3 .box{margin-top:6px}.wedge,.c3 h2{position:relative;background:#333;color:#fff;margin:0;padding:0;height:2.101em;line-height:1.65em}.c3 h2{height:2em;line-height:2em}.c3 h2,#doc .c2 h3{text-shadow:0 1px 0 #000}.wedge{background-color:#39c}.wedge-dark{background:#333}.wedge .l,.wedge .r{border-top:1.75em solid #333}.c3 h2 .l,.c3 h2 .r{border-top:2em solid #333;border-top:2.1em solid #333\9}.wedge .l,.c3 h2 .l,.wedge .r,.wedge-dark .r,.c3 h2 .r{background:transparent url(../demo/_image/wedge.png) no-repeat;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAAEABAMAAACJ12OUAAAAGFBMVEUREREAZpkYGBgAZpkiIiIAZpkREREAZpkArR2CAAAABnRSTlMAAOvrEhJBIv9yAAAC0UlEQVR42u3ZuW0cQRCF4cIPhrG2MhDkLZgDM5ChBGQoKBlMgdgElAQ9gVACNMTZ2WOO7rraI2rcna33cdjTTTzyQ7++fzFuQPTrdDBuMAa8H04vQwNOL++HkQHTtw0CBmAekh0wf1cnYAEsAibAIGACDAI2QCdgA3QCDoBKwAFQCXgAGgEPQCPgAigEXACFgA/QJ+AD9Ak4AV0CTkCXgBfQI+C/tT0W952dubgBncH4Ae3J+AHt0QQAzdkEAM3hRACt6UQArfGEAI35hACNAGKAfQIxwD6CIGCXQRCwCyEK2KYQBWxjCAM2OYQBmyDigHUSccA6igRglUUCsAojA1imkQEs40gBFnmkAItAcoB7IjnAPZIk4JZJEnALJQu4ppIFXGNJAy65pAGXYPKAOZk8YI5mAHDOZgBwJjACmAiMACYCT7/U6+c3/fOv1R9Uf1D9QfUH1R9Uf1D9QfUH1R9Uf1D9QfUH1R9Uf1D9wefvD/4NXhwfRwQPrzy8jgw4PiIjhI90ZITwEY4MEKZsZIAwRSN5wjkZyRPOwUiaMOciacIci2QJl1QkS7iEIknCNRNJEq6RSI5wS0RyhFsgkiLc85AU4R6HZAiLNCRDWIQhCcIyC0kQllFInLBKQuKEVRASJqxzkDBhHYNECZsUJErYhCBBwjYDCRK2EUiMsEtAYoRdABIi7OcjIcJ+PBIhNKYjEUJjOBIgtGYjAUJrNOInNCcjfkJzMO47O3Px39oeixvb+cFwP67Oo8X7vHpPFu9vrPe7xblmuqsL56rtrm98y7a/vPG9OP0XDNerq7ziuDYPZZPBs3toewye/Uvb5XDsoOo+i2MPV3d67E1c3+ixjxH9qME8yIzDDvMoNY5brLPUOm2xTnPrvLf++3+0/uLgz2/1ev6rf/5W/UH1B9UfVH9Q/UH1B9UfVH9Q/UH1B9UfVH9Q/UH1B9UffPr+4D+tsZObsTO2qgAAAABJRU5ErkJggg==);*background-image:url(../demo/_image/wedge.png)}.wedge .l,.c3 h2 .l{background-position:-64px 0;position:absolute;left:0;top:0;width:16px;height:100%;margin-left:-16px}.wedge .r,.wedge-dark .r,.c3 h2 .r{background-position:-48px 0;position:absolute;right:0;top:0;width:16px;height:100%;margin-right:-16px}.wedge .l,.wedge .r{border-color:#39c}.wedge .l{background-position:-64px -64px;border-top:2em solid #39c}.wedge .r{margin-top:-15px;border-top:0;height:16px;border-bottom:2em solid #39c;background-position:0 -192px}.wedge-dark .l,.wedge-dark .r{border-color:#333}.wedge-dark .l{background-position:-64px 0}.wedge-dark .r{background-position:0 -128px}.c3 h2 .r.up{margin-top:-16px;border-top:0;height:16px;border-bottom:1.66em solid #333;background-position:0 -128px}.c3 h2 .l.flat,.wedge .l.flat,.c3 h2 .r.flat,.wedge .r.flat{background-image:none}.c3 ul{margin:0;padding:0;list-style-type:none}.c3 ul li{border:1px solid #f3f3f3;border-top:0;border-bottom:0}.c3 ul ul li{border:0}.c3 ul li{margin:0;padding:0}.c3 ul li ul li{background-color:#fcfcfc;background-color:rgba(255,255,255,0.5);font-size:97%;line-height:2.4em;text-indent:.5em;padding:0 .25em;cursor:hand;border-bottom:1px dotted #eee}.c3 ul li ul li:hover{background-color:#999;cursor:pointer;cursor:hand}.c3 ul li ul li.active{background-color:#39c;color:#fff}.c3 h3{position:relative;margin:0;padding:0;height:auto;min-height:25px;background:#39c;border:0;color:#fff;text-indent:.5em;font-size:1em;line-height:2em;text-shadow:0 1px 0 rgba(0,0,0,0.25)}.c3 h4{font-size:1em;margin:0;padding:.4em .2em .4em .75em;vertical-align:middle;color:#333;background-color:#f3f3f3;background-color:rgba(0,0,0,0.05);border-top:1px dotted #d6d6d6;border-bottom:1px dashed #e9e9e9;text-shadow:0 1px 0 #fff}.c3 h4:first-of-type{border-top-color:transparent}#get-satisfaction h2 a{color:#fff}#get-satisfaction a{color:#555}#get-satisfaction a:hover{color:#fff}.c3 h2 a{color:#fff}.c3 h2 a:hover{color:#fff;text-decoration:underline}.flash9{background-image:url(../demo/_image/flash9.png);background-repeat:no-repeat;background-position:bottom right;_background-image:none}li.flash9{background-position:bottom right}.flash9:hover,.flash9.active{background-image:url(../demo/_image/flash9-dark.png);_background-image:none}.new{background-image:url(../demo/_image/new.png);background-repeat:no-repeat;background-position:bottom right;_background-image:none}.recent{background-image:url(../demo/_image/new-bw.png);background-repeat:no-repeat;background-position:bottom right;_background-image:none}.new:hover,.new.active,.recent:hover,.recent.active{background-image:url(../demo/_image/new-dark.png);background-repeat:no-repeat;background-position:bottom right;_background-image:none} +.deprecated{font-style:italic;color:#333!important}span.nevermind,.removed{text-decoration:line-through;opacity:.33}strong.removed{font-weight:normal;opacity:.5}.padded{padding:.5em}dd.deprecation-note{color:#933;background-color:#fff6f6}.c3 p{font-size:.9em;padding-left:.75em;padding-right:.5em}.c1 pre code{margin-top:0;color:#369;margin-left:0}.c1 pre{margin-top:0;padding-top:0;margin-left:.5em}#reset-filter{position:relative;font-family:"Helvetica Neue","Helvetica",helvetica,arial,verdana,sans-serif;font-weight:300;font-size:2.5em}.c2 .option{font-size:85%;float:right;display:inline;margin-left:1em;margin-right:.5em;margin-top:3px;line-height:1em;white-space:nowrap}.c2 .option a{padding:.1em .35em .1em .35em;color:#39c}#filter-box{position:relative;display:none}#get-satisfaction{position:relative}#support-wrapper{position:relative;background:#fff;border:1px solid rgba(0,0,0,0.03);box-shadow:0 0 1px rgba(0,0,0,0.075)}#gsfn_content{position:relative;padding:.5em 0 .5em 0}#gsfn_content ul{position:relative;overflow:hidden;height:0;margin:0;-webkit-transition:height .5s ease-in-out;-moz-transition:height .5s ease-in-out;transition:height .5s ease-in-out}#gsfn_content ul li{border:0}div#gsfn_list_widget img{border:0}div#gsfn_list_widget a{text-decoration:none}div#gsfn_list_widget a.widget_title{display:block;margin-bottom:10px;font-weight:bold}div#gsfn_list_widget .powered_by{font-family:verdana,arial;margin:-0.25em 1em 0 1em;padding:.25em 0 .5em 0;border-top:1px dotted #ddd;font-size:75%}body.home div#gsfn_list_widget .powered_by{padding-bottom:0}div#gsfn_list_widget .powered_by a{font-style:italic;color:#999}div#gsfn_list_widget .powered_by a:hover{color:#333}div#gsfn_list_widget div#gsfn_content{font-size:.88em;padding-left:.5em;padding-right:.5em}div#gsfn_list_widget div#gsfn_content li{text-align:left;position:relative;clear:right;*zoom:1}div#gsfn_list_widget div#gsfn_content li:hover,div#gsfn_list_widget div#gsfn_content li:hover a{background:#39c;color:#fff}div#gsfn_list_widget div#gsfn_content a.gsfn_link{display:block;line-height:1.2em;padding:5px 0 5px 5px}div#gsfn_list_widget div#gsfn_content a.gsfn_link:hover{_color:#fff;_background-color:#39c}div#gsfn_list_widget div#gsfn_content span.time{font-size:85%;color:#999;padding-left:3px;padding-right:3px;text-align:right;float:right;display:inline;margin-top:1px}div#gsfn_list_widget div#gsfn_content li:hover span.time{color:#fff}div#gsfn_list_widget div#gsfn_content p.gsfn_summary{margin-top:2px;position:relative;z-index:2}.tight{margin-top:0}.compact{margin-bottom:.25em!important}.smaller{margin-top:0!important;margin-bottom:.25em!important}.c2 a,a.cta{margin-top:-0.3em;padding:.2em .25em;margin-left:-0.25em;margin-right:-0.25em;*margin:0;*padding:0 2px;*margin:0 -2px 0 -2px;text-decoration:none;color:#39c;border-radius:.25em;zoom:1}body.home .c2 a,body.home a.cta{text-shadow:0 1px 0 #fff}body.home .c2 a:hover,body.home a.cta:hover{text-shadow:none}pre code a,.c2 pre code a{color:#39c;font-weight:400;text-decoration:none;text-shadow:none}pre code a:hover,.c2 pre code a:hover{background-color:#39c;color:#fff;font-weight:400}.c2 a.sm2_button{border-radius:6px}.c2 a.sm2_button.type-2{border-radius:9px}.c2 a{color:#39c;font-weight:500;text-decoration:none}.c2 a.cta{text-decoration:none}a.cta span{font-size:1.5em;line-height:1em}a.cta:hover,.c2 a:hover,#sm2-options a:hover{position:relative;z-index:1;background-color:#39c;border-color:#39c;color:#fff;text-decoration:none}.c2 a.sm2_button:hover{background-color:#c33}dt a:hover span{color:#fff}a.cta-more{color:#def;font-size:.8em;position:absolute;right:0;margin:0;padding:1px;bottom:.9em;line-height:1em}a.cta-more:hover{background:#fff;color:#39c}div.html5support{clear:both;padding-top:2em}div.html5support span{padding:0 5px;display:inline-block;text-align:center;font-weight:bold;background:#ccc;color:#fff;border-radius:5px;margin-left:.5em;margin-bottom:.25em}div.html5support em{font-weight:bold}div.html5support span.true{background:#696}div.html5support span.partial{background:#933}div.html5support em.partial{color:#933}div.html5support em.true{color:#696}#nav ul li ul{box-shadow:2px 2px 2px rgba(51,153,204,0.2)}.newer{vertical-align:middle;margin-top:1em;margin-bottom:1em}.newer a,a.feature,.feature-hot{position:relative;display:inline-block;background:#39f;font-size:1.1em;line-height:1.75em;padding:0 .5em;margin:0 .125em;color:#fff;font-weight:bold;border:3px solid #cce6ff;border:3px solid rgba(255,255,255,0.66);border-radius:8px;text-decoration:none}a.feature{margin-left:0}.newer a,.feature-hot{background:#f00;border-color:#f66;color:#fff}.newer a:hover,.c2 .feature-hot:hover{background:#900;border-color:#c00}a.feature:focus,a.feature:hover{background:#f00;border-color:#f66;color:#fff}# a.warning,span.warning{font-weight:bold}a.warning,span.warning,a.warning code,span.warning code{color:#930}a.warning:hover{color:#fff;background:#930}.newer p{margin:0;padding:0}.scratched-out{display:inline-block;text-decoration:line-through;color:#999;font-size:.9em;margin-top:-0.75em;-webkit-transform:rotate(-15deg);-moz-transform:rotate(-15deg);transform:rotate(-15deg)}div.inthewild{position:relative;margin-top:1em}ul.inthewild{display:inline;margin:0 auto;list-style-type:none}ul.inthewild,ul.inthewild li{position:relative;margin:0;padding:0}ul.inthewild{margin-bottom:2em}ul.inthewild li{display:inline-block;*float:left;*display:inline;width:128px;height:64px;vertical-align:middle;text-align:center;margin:2px 0;background-color:#fcfcfc;background-color:rgba(255,255,255,0.5);border-radius:2px;border:1px solid #eee;border-color:rgba(0,0,0,0.05)}ul.inthewild a,ul.inthewild a img{border:0;vertical-align:middle}ul.inthewild a{position:absolute;left:50%;top:50%;overflow:hidden;margin:0;padding:0;border-radius:0;background:transparent url(../demo/_image/logo-sprite.png) no-repeat 0 0;line-height:96px;vertical-align:middle}ul.inthewild a:hover{background-color:transparent}ul.inthewild a span{position:absolute;text-indent:-9999em}#eight-tracks{background-position:0 0;width:64px;height:20px;margin:-10px 0 0 -32px}#audiogalaxy{width:100px;height:22px;background-position:0 -37px;margin:-11px 0 0 -50px}#discogs{background-position:0 -72px;width:55px;height:20px;margin:-10px 0 0 -27px}#hypem{background-position:0 -111px;width:80px;height:38px;margin:-19px 0 0 -40px}#lastfm{background-position:0 -176px;width:80px;height:28px;margin:-14px 0 0 -40px}#pitchfork{background-position:0 -688px;width:100px;height:20px;margin:-10px 0 0 -50px}#nyancat{background-position:0 -312px;width:64px;height:40px;margin:-20px 0 0 -32px}#soundcloud{background-position:0 -424px;width:83px;height:58px;margin:-29px 0 0 -42px}#turntable-dot-fm{background-position:0 -252px;width:100px;height:20px;margin:-10px 0 0 -50px}#baroque-me{background-position:0 -541px;width:88px;height:47px;margin:-23px 0 0 -42px}#freesound{background-position:0 -635px;width:100px;height:27px;margin:-15px 0 0 -50px}div.inthewild.active li:hover{background-color:rgba(255,255,255,0.9);border-color:#ccc;box-shadow:0 0 3px rgba(0,0,0,0.075)}.sidenote{font-size:85%;opacity:.75}ul.playlist{font-size:85%}ul.playlist li{margin-bottom:.2em}ul.playlist li a{font-size:1em;color:#333}ul.playlist li a,ul.playlist li a:hover{background:transparent;border-radius:0;line-height:1em}ul.playlist li .timing{margin-right:.1em;font-size:50%;top:.5em}ul.playlist.use-peak li .peak{height:.61em;margin-top:-5px;width:.92em}html.isSafari ul.playlist.use-peak li .peak{margin-top:-4px}ul.playlist.use-peak li .timing{right:4em}ul.playlist.use-peak li .peak-box{height:.66em}ul.playlist li .peak .l{margin-right:0}ul.playlist li .peak .l,ul.playlist li .peak .r{width:6px}ul.playlist li .peak .r{left:9px}a.not-supported{text-decoration:line-through;color:#666;opacity:.25}ul.graphic li{line-height:1.5em}ul.graphic li a,ul.graphic li a.sm2_link{min-width:17.75em;width:auto}ul.graphic li a,ul.graphic li a.sm2_link{background-color:#ddd;border-color:#ddd;color:#333;vertical-align:middle} +ul.graphic li a{background:#ddd url(../demo/play-mp3-links/image/icon_play.png) no-repeat 3px 50%;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAA6ElEQVR42q2UvQqDMBRGC47dAj6rgygIDg5OfQlHF30GX0JFURddnEQU+eoNLaSJFRUvnPzA/c4QkjwA3AIf1tJWnitsRT8I+2Q0UfTM8/yFk0UZyooiNk0ThmE4BWUoK4r0cRxxBcr+iMh+AVW0LAtkoihCURS0/ocqwkaZpgnbtrmwrmts1DGR67owDIPjeR7iOEbXdfuisiwh4zgOSb5wcZIkYo8qapoGMpZlkYALwzBElmWoqkrsUUVt20LG930EQUAHTvstVFHf95BJ05TmPVQR3dQLKCI2zzOuQNnbHu3t38gtvAF1L6rpAc8MDwAAAABJRU5ErkJggg==);*background-image:url(../demo/play-mp3-links/image/icon_play.png);_background-image:url(../demo/play-mp3-links/image/icon_play.gif)}ul.graphic li a:hover,ul.graphic li a.sm2_paused:hover,ul.graphic li a.sm2_link:hover,ul.graphic li a.sm2_playing,ul.graphic li a.sm2_playing:hover{background-color:#369;border-color:#369;color:#fff}ul.graphic li a.sm2_link{-webkit-transition-property:none;-webkit-transition:none}.c2 ul.playlist li a{margin:0;padding:0;letter-spacing:-0.02em}ul.inline-playlist{min-height:49px;min-width:512px;margin-top:4em}ul.inline-playlist li{float:left;display:inline;width:45%;margin-right:.25%}body.home .sm2-inline-list .ui360-vis{margin-right:0}body.home #special-demo-left .ui360{margin-right:4px;background-color:rgba(0,0,0,0.025);box-shadow:inset 0 0 8px rgba(0,0,0,0.075);border:1px solid rgba(0,0,0,0.075);border-radius:32px;-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;transition:all .2s ease-in-out;-moz-transition-property:background,border,box-shadow;-webkit-transition-property:background,border,box-shadow;transition-property:background,border,box-shadow}body.home #special-demo-left .ui360:hover{background-color:rgba(0,0,0,0.045);border-color:rgba(0,0,0,0.15);box-shadow:inset 0 0 5px rgba(0,0,0,0.15)}body.home #special-demo-left .ui360:last-child{margin-right:0}body.home .columnar .c2 p{font-size:1.1em;line-height:1.6em;color:#333}body.home .c2 ul.playlist li a{_color:#000}body.home .c2 ul.playlist li.sm2_paused a,body.home .c2 ul.playlist li.sm2_playing a{_color:#fff}body.home .c2 ul.standard{_margin-left:1.5em}body.home .ie6sucks{_background:transparent!important;_display:none!important}body.home .ie7sucks{*display:none!important}body.home #sm2-container{position:fixed;bottom:0;left:0;width:48px;height:48px;_margin:-8px 0 0 0}@-moz-keyframes flashblock{from{border-color:#f33}to{border-color:#fff}}@-webkit-keyframes flashblock{from{border-color:#f33}to{border-color:#fff}}body.home #sm2-container.swf_timedout{border:1px solid #f33;-moz-animation-duration:1s;-moz-animation-name:flashblock;-moz-animation-iteration-count:5;-webkit-animation-duration:1s;-webkit-animation-name:flashblock;-webkit-animation-iteration-count:5;width:48px;height:48px}body.home #sm2-container.swf_unblocked,body.home #sm2-container.swf_loaded{top:auto;left:0;bottom:0;margin:0;width:6px;height:6px}#sm2-support-warning{display:none;border:1px solid #f99;padding:.5em;margin-top:1.5em;font-weight:bold}#sm2-support{display:none;font-size:.9em!important;margin-top:1.5em}#sm2-support-warning,#sm2-support{background:#fff6f0;border:1px solid #f33}body.home #about-sm2 #sm2-support h3{border-color:#f99;margin-top:.25em}body.home #special-demo-left{min-height:70px;position:relative;float:left;display:inline;margin-right:14px;padding-right:.9em;border-right:1px dotted #e0e0e0;*border-right:0;_width:210px}body.home #special-demo-right{min-height:51px;position:relative;float:left;display:inline;margin-top:18px;*width:90px;_display:none}body.home #inline-playlist{clear:both;float:right;display:inline;width:256px;min-height:49px;margin-top:2em;padding-bottom:0}#demo-box{position:relative;float:right;display:inline;margin-top:-4px;background:#fff;padding-left:3em;width:256px;z-index:1}hr{visibility:hidden;margin:0;padding:0}.demo-block{position:relative;background:#f9f9f9;border:1px solid #e6e6e6;padding:4px;padding-top:.5em;margin-top:-0.55em;border-top:0}#demo-header{color:#333;background:#f9f9f9;border:1px solid #e6e6e6;border-bottom:0;margin-bottom:0;padding:.5em}#demos h3{padding-bottom:0;text-indent:.5em;font-weight:normal}#demos h3 a{font-weight:normal}#revision-list>li{margin-top:3em;margin-bottom:2em}#revision-list>li:first-child{margin-top:2em}body.home.has-lights{overflow-x:hidden}body.home #lights{position:absolute;border-top:1px solid #060;left:0;top:0;width:100%;z-index:4;display:none}.xlsf-light{position:absolute;margin-top:-1px}body.fast .xlsf-light{opacity:.9}.xlsf-light{opacity:.9}#explosion-box{position:absolute;left:0;top:0;width:100%;z-index:10}.xlsf-fragment{position:absolute;background:transparent url(christmas-lights/image/bulbs-50x50-fragments.png) no-repeat 0 0;width:50px;height:50px}.xlsf-fragment-box{position:absolute;left:0;top:0;width:50px;height:50px;*width:100%;*height:100%;display:none}.figure{display:inline;display:inline-block;border:1px solid #def;padding:.5em;margin:.5em 0 .5em 0}.figure .code span{padding:.25em;border:1px solid #f0f9ff;background:#fff}.figure .code span.mid{color:#666}#sm2-container.flash_debug{position:relative;width:auto;height:300px;width:100%;background:#f6f6f6;border:1px solid #ccc}#sm2-container.flash_debug object,#sm2-container.flash_debug embed{width:100%;height:100%;left:auto;top:auto}ul.file-structure ul{padding-left:1.5em}ul.file-structure li{list-style-type:square;margin-top:.25em;margin-left:0}ul.file-structure li span{color:#999}#sm2-filesizes{border:1px solid #ddd;background:#fff}#sm2-filesizes tr:nth-child(2n+1){background:#f9f9f9}#sm2-filesizes th{background:#eee;font-weight:bold;text-align:left}#sm2-filesizes th{padding:4px 6px}#sm2-filesizes td{padding:0 6px;border:1px solid #eee}#sm2-filesizes p{margin-top:.5em;margin-bottom:0}#sm2-filesizes pre{border-left:none;margin-top:.5em;margin-bottom:.5em}#sm2-filesizes .nw{white-space:nowrap}#sm2-filesizes .booyaa{background:#fff9f9;color:#900}#history li.in>p.compact{font-weight:bold}#sm2-options{position:relative;clear:both;color:#666;margin:.33em .75em 0 .75em;border-top:1px dotted #ddd}#sm2-options .options-divider{font-size:85%;color:#ccc}#sm2-options p{font-size:85%;padding-left:0;padding-bottom:0;margin-bottom:.75em}#sm2-options p:first-child{margin-top:.75em}#sm2-options a{color:#39c;text-decoration:none;padding:1px;margin-top:-2px 0 0 -2px}#without-html5{display:none}body.home #about-sm2 #inline-demo-header{margin-top:1.5em;border-bottom:1px solid #eee;padding-bottom:.5em}body.home #about-sm2 #inline-demo-header,body.home #about-sm2 .home-shopping-network{display:block}#about-sm2 a img{border:0}ul.code-block{list-style-type:none;position:relative;padding:3px;font-size:85%}ul.code-block,ul.code-block li{position:relative;margin:0;padding:0;line-height:1.5em}ul.code-block li{padding:.75em .5em}ul.code-block li:nth-child(2n+1){background-color:#fcfcfc}ul.code-block li:last-child{padding-bottom:0}ul.code-block li div{position:absolute;left:.5em;top:.75em;width:22em;z-index:2}ul.code-block li span{position:relative;display:block;padding-left:22.5em;text-indent:-2em}#soundmanager-properties ul.code-block{min-width:43em}div.oneup,div.twoup,div.threeup{position:relative;clear:both;padding:2em 1em 2.5em 1em;*zoom:1}div.oneup,div.twoup,div.threeup,#about-sm2 h2.special,#about-sm2 p{text-shadow:0 1px 0 #fff}div.oneup .column{position:relative;width:100%}div.twoup .column,div.threeup .column{position:relative;float:left;display:inline;width:33.3%;_width:32%}div.twoup .column{width:50%;_width:49%}div.oneup .column,div.twoup .column,div.threeup .column{padding-bottom:.5em}div.oneup .column-wrapper,div.twoup .column-wrapper,div.threeup .column-wrapper{margin:0 2.5em}div.oneup .column-wrapper.spaced-out,div.twoup .column-wrapper.spaced-out,div.threeup .column-wrapper.spaced-out{padding-top:6.25em}div.threeup.first{padding-top:.75em}div.threeup.first .column-wrapper{border-top:0}body.home #main .oneup p,body.home #main .twoup p,body.home #main .threeup p{font-size:1.1em;line-height:1.5em;margin-bottom:1.5em}body.home #main p.sidenote{font-size:92%;color:#666}body.home h2{margin-top:0}body.home div.c3{position:relative;float:right;display:inline;margin-left:30px;margin-top:-6px;z-index:2;margin-bottom:2.5em}body.home #inline-playlist{float:none;display:block;width:auto}body.home .sm2-inline-list .ui360-vis{margin:0 auto}body.home ul.playlist{font-size:85%}body.home ul.playlist li{font-size:1.75em;letter-spacing:-0.02em} +body.home ul.playlist .sidenote{font-size:85%}body.home .demo-more,body.home .demo-more-abs{font-size:95%}body.home ul.graphic{margin-top:1em}body.home ul.graphic{position:relative}body.home ul.graphic li{float:left;display:inline;width:50%;margin-bottom:0}body.home ul.graphic li a,body.home ul.graphic li a.sm2_link{display:block;width:auto;min-width:8em;margin-right:.5em;margin-bottom:.5em}body.home ul li a:hover,body.home ul.graphic a.sm2_playing,body.home #inline-playlist li.sm2_paused a,body.home #inline-playlist li.sm2_playing a,body.home ul.playlist li div.timing,body.home .feature-hot,body.home #html5-support-li span{text-shadow:none}body.home .feature-hot{font-size:13px}body.home ul.graphic li a,ul.playlist li a{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;*overflow:auto;*white-space:wrap}body.home ul.playlist li a,body.home ul.playlist li a:hover{line-height:1.2em}body.home .demo-more a span,body.home .demo-more-abs a span{font-size:1.5em;line-height:1em}body.home #sm2-visualization{clear:both;margin-top:2em}body.home #sm2-visualization .ui360{float:none;display:block}body.home #sm2-visualization .ui360 .sm2-360ui{border-color:rgba(0,0,0,0.05);background-color:rgba(255,255,255,0.5);box-shadow:inset 0 0 32px rgba(0,0,0,0.075)}body.home #sm2-visualization .ui360 canvas,body.home #sm2-visualization .ui360 .sm2-360ui,body.home #sm2-visualization .ui360 a{border-radius:128px}body.home #sm2-visualization .ui360 a{line-height:340px;*line-height:480px;line-height:480px\9;color:#666!important;text-shadow:0 1px 0 #fff}:root body.home #sm2-visualization .ui360 a{line-height:340px\0/IE9}body.home #sm2-visualization .ui360 a,body.home #sm2-visualization .ui360 canvas{-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;transition:all .2s ease-in-out;-moz-transition-property:background-color,border,box-shadow;-webkit-transition-property:background-color,border,box-shadow;transition-property:background-color,border,box-shadow}body.home #sm2-visualization .ui360:hover{background-color:rgba(0,0,0,0)}body.home #sm2-visualization .ui360:hover a{background-color:rgba(0,0,0,0.01);border-color:rgba(0,0,0,0.1);box-shadow:inset 0 0 32px rgba(0,0,0,0.05)}body.home #sm2-visualization .ui360 .sm2_playing canvas,body.home #sm2-visualization .ui360 .sm2_paused canvas{background-color:#fafafa;*background-color:transparent;background-color:transparent\9}body.home #sm2-visualization .ui360 .sm2_playing canvas,body.home #sm2-visualization .ui360 .sm2_paused canvas{background-color:#fafafa;box-shadow:inset 0 0 32px rgba(0,0,0,0.066)}body.home #sm2-visualization .ui360:hover .sm2_playing canvas,body.home #sm2-visualization .ui360:hover .sm2_paused canvas{background-color:#fafafa;box-shadow:inset 0 0 32px rgba(0,0,0,0.1)}body.home .gsfn_topic_list li{display:none}body.home .gsfn_topic_list .gsfn-item-1,body.home .gsfn_topic_list .gsfn-item-2,body.home .gsfn_topic_list .gsfn-item-3{display:block}div.clearfix{font-size:0;height:0;overflow:hidden}div.icons ul{list-style-type:none}div.icons ul,div.icons ul li{margin:0;padding:0}div.icons ul li,.icon{position:relative;display:inline-block;vertical-align:middle;*display:none;background:transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYAAAAAwCAYAAAAYeq1+AAAHLklEQVR42uydT4jcVBzHH6LbLV11wGIVL6OClFbL1P3zEtvDFCsIKqyn0tseFBFKXTwpIu7B017mLBSymwwevBSsiCdjdzOpW5DVg3izXsSbsf5Z3aWd+M1M3jTENpvJTEzS/X7hy0szL+l0d/r95P2SeU9QFEVRFEVRFEVRFEVRFEVRFEVRFEVRFEVRFEVRFEVRFEVRVAFqX5m91+rIMyKFLEf7QFAURVF3jwCAV3ft4849AgAcERRFUXlpenraj7rE77MG27A/pG24VioArOsHTEcum472vtXR/Nv4HLzcducOCIqqqk6fPl2Dbdgfk224Jqg9BwAV/hlti5JoZWN2H8J/E+F/sx/2euBu29W7wZ/R9iHgyC2zI9cERVVVKvzHbFtQuUCgIqCKuxXp01L7ywg2BPtjKOtcR+vDN8LA77Y7OloYreVqPRCYHW2730/+iHZSUEMFzxLs5+wlQSUqr5+9oAiAIS1KINORvyDkEe7yc9OVhwGDLSsI/ltG+MsADt9ZjjyM9mvYx3FfCKr44Im7gNJJpUopsb+zOaJ95ZKWupqhF+EluAXbob0yvXcEYhM24GvxoAz3GXAjVn/fhA0CIHP4XwhLPl0E/0Vs1+E/wqt/WJWC0MfRrqJE9Djay+jThYN9rwgqnTKETqYwqljpJG6bABheYcDHgj29Cw7++pC1dBtuwG9G9hlFAWCkYwvU6rp8AIH+s4Vw7wU6DCD80ysBYTsyAoiUgORfaPv9cdwqoLCycfIeVlBKBAC+/6oBoHg4Fxj+87AXu9Jvwc2YW7GRQdybBMDQtf9HEfh/9gIeRuhHr/r/ux1reyAIjnfmHmYFhQAgAKpVXrwW/XOB4e+H9uDFFMcsKmBE/AZcIwCGLv88CL+F8s7bWWx1YEeeN525/QQAAUAAlAcANrwUej7yXmt3Oqagso8XCf9G2pvAQd8oBNSxBECyrCDwO/I1BPcLpisncCU/ZblyBu1sFltB6+jTpqMH3yKexPnPAihn8HfsJwAIAAIgf2UP8+IBYMfDPxEAyRCwCYA0ANA+UV/qQkifRYhPY3sb5ZybWQ0IeOYV7X6c+yN1bmy/QwAQAAQAASASwtsPvZj1MdDg2Mh5mgRAsqLP92P7M9ORR9DuYJ+fxZYbhL3urX51YgLbv+MeQm8f2nVBEQAEAAFwh+Az1A3fUb8HEJyDTwGlBwDcDW/gfgoAHO0BAPszQ8DRvBVbm8B5foPVDeJcAJDnVT5HAAQAAZC/4qHdGgMAWgomBECyVGgrAKA92nbkjpUt/NV5PNPVJgCTPgBcAoAAIAAIgASlKdvgtZci/V5M6NdU/QiA4QFgAQAjhL8PeHjGBkpAjhYBgEYAEAAEAAEwEgD8qAmA8QNAlYCsEUtApv1caUYAYhcRAAQAAUAAEABqBKBuAmc0gt+7YE/HRwAEAAFAABAAIwHgVKTfKQJgXADQxgaAMPA9c+MkRwAEAAFQYgDEJ4dr8Cbw3gNA/xFNXT0FdAkeCQDh+TzD0SNPAWk4N28CF/JFBgKAALjDh7uZMFdQmR8DbQbmY6Bjewz0V8sdfFlrBe3T4ygBrXwpJ3GenxD86tyXqgAAtEZgAoAAqBIA1JX8ImzAF+OzJMb6LhT1mUlTtkkz/0/KL4I1CIBkmR3t9cE3gR35DK7WJba3RwUA/BDO83L/3DLY93wF8tOIbhMAnA66CgBQge6l+f1ju57Ut+xTQShxKojxadWdO77izh4MRwS6AoDl6t0hw78bziDqmR39UHiP4anVdf0J5icXhOGCMPm87/lhfv/hKMFPYa8Mk8FlCf+wrRMAmWYDPYEA37EGyz9qcHRaaOxXrZr6IVr/x/7eY6Dr8hBnA+WSkGMTAXB7qSmcd3OGz9tShaeDnueSkJknhwtmB/0Bo4C/UbrZAgRuIPzVQvBdbG9hewvbcAABuF9C2u69huNMR9tsX9GnCICc/7Fc0pIAGPbnp97fLjYEVMEFYTx4nmsCj6a2Iw8i0J9FkNfRfm91+iEflneOAQoN7JsZ7OuvDLbcduUxtMexqtgU82fvAMCA/ZxtEAAj/QdoxY5pJSwIMwjQCi4JWS/7ovCp+pRICPerquSDkcHgvZmXZ+4zw/CHgxHAeRETl4TMGwDU2FThkUsry4cX+xvwknKxwZ9c20+xKHxT9ScAxv6Y6FW1/KPpRgCwNhsCAFYAoHK7yeol3ayDa4L6vwCwELpoAMSvgrzYZ8KA64ISRT3NlNF2qQCgRgAhBNT+NgAwePKnQwBQ1QeAnQMAbEHtRQDUMkLAhmslGwF8M1gzAK3a//GaNmHduvoHBOQ5QVF5q0KPs9ocmVFVl+Vo70aWjPw2tp7w9f4KYHjNlWcFRVEUdfcIoT9lOvK86WjvwbXYa08CDB/i9QXAYJ+gKIqiqH/bgwMSAAAAAEH/X7cjUAEAAAAAAAAAAAAAAA4CNogIgRLqd00AAAAASUVORK5CYII=) no-repeat;width:32px;height:24px;padding-right:4px;text-indent:-999em;overflow:hidden;cursor:help;opacity:.75}div.icons ul li:hover,.icon:hover{opacity:1}.icon{display:inline-block;*display:none;width:32px;height:30px;margin-left:16px;margin-top:5px;opacity:.85;cursor:default}div.icons ul li.desktop{background-position:-11px -12px;height:24px}div.icons ul li.laptop{background-position:-59px -13px;height:22px}div.icons ul li.ipad{background-position:-109px -10px;width:28px;height:28px}div.icons ul li.iphone{background-position:-256px -9px;width:22px;height:28px}div.icons ul li.android{background-position:-299px -7px;width:28px;height:32px}.icon.performance,div.icons ul li.performance{background-position:-205px -9px}.icon.performance{width:18px;height:28px;margin-top:-7px}.icon.music-note,div.icons ul li.music-note{background-position:-155px -13px}.icon.music-note{width:19px;height:23px;margin-top:-4px}.icon.package,div.icons ul li.package{background-position:-347px -7px;height:28px}.icon.package{width:22px;margin-top:-8px}.bonus-demos{position:relative;list-style-type:none}.bonus-demos,.bonus-demos li{margin:0;padding:0}.bonus-demos li{float:left;display:inline;width:24%;margin-right:1%;text-align:center}.bonus-demos li img{border-radius:4px}#client-requests ul.flat{list-style-type:none;padding-left:.5em;margin-top:.5em}#client-requests ul.flat li{margin-bottom:0} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index-rollup.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index-rollup.js new file mode 100755 index 00000000..8a527118 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index-rollup.js @@ -0,0 +1,200 @@ +/** + * SoundManager 2 homepage demo JS + * ------------------------------- + * MP3 player button, Muxtape/page player, + * inline player and 360 player demo bits + * combined and minified for optimal performance. + * For raw source, see individual demo pages. + * -------------------------------- + * Source files: + * demo/play-mp3-links/script/inlineplayer.js + * demo/page-player/script/page-player.js + * demo/mp3-player-button/script/mp3-player-button.js + * demo/360-player/script/berniecode-animator.js + * demo/360-player/script/360player.js + * demo/index.js + */ + +/* + + Animator.js 1.1.9 + + This library is released under the BSD license: + + Copyright (c) 2006, Bernard Sumption. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions and + the following disclaimer in the documentation and/or other materials + provided with the distribution. Neither the name BernieCode nor + the names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + DAMAGE. + +*/ +function InlinePlayer(){var a=this,c=this,b=soundManager,d=navigator.userAgent.match(/msie/i);this.playableClass="inline-playable";this.excludeClass="inline-exclude";this.links=[];this.sounds=[];this.soundsByURL=[];this.indexByURL=[];this.lastSound=null;this.soundCount=0;this.config={playNext:!1,autoPlay:!1};this.css={sDefault:"sm2_link",sLoading:"sm2_loading",sPlaying:"sm2_playing",sPaused:"sm2_paused"};this.addEventHandler="undefined"!==typeof window.addEventListener?function(a,b,c){return a.addEventListener(b, +c,!1)}:function(a,b,c){a.attachEvent("on"+b,c)};this.removeEventHandler="undefined"!==typeof window.removeEventListener?function(a,b,c){return a.removeEventListener(b,c,!1)}:function(a,b,c){return a.detachEvent("on"+b,c)};this.classContains=function(a,b){return"undefined"!=typeof a.className?a.className.match(RegExp("(\\s|^)"+b+"(\\s|$)")):!1};this.addClass=function(b,c){if(!b||!c||a.classContains(b,c))return!1;b.className=(b.className?b.className+" ":"")+c};this.removeClass=function(b,c){if(!b|| +!c||!a.classContains(b,c))return!1;b.className=b.className.replace(RegExp("( "+c+")|("+c+")","g"),"")};this.getSoundByURL=function(b){return"undefined"!=typeof a.soundsByURL[b]?a.soundsByURL[b]:null};this.isChildOfNode=function(a,b){if(!a||!a.parentNode)return!1;b=b.toLowerCase();do a=a.parentNode;while(a&&a.parentNode&&a.nodeName.toLowerCase()!=b);return a.nodeName.toLowerCase()==b?a:null};this.events={play:function(){c.removeClass(this._data.oLink,this._data.className);this._data.className=c.css.sPlaying; +c.addClass(this._data.oLink,this._data.className)},stop:function(){c.removeClass(this._data.oLink,this._data.className);this._data.className=""},pause:function(){c.removeClass(this._data.oLink,this._data.className);this._data.className=c.css.sPaused;c.addClass(this._data.oLink,this._data.className)},resume:function(){c.removeClass(this._data.oLink,this._data.className);this._data.className=c.css.sPlaying;c.addClass(this._data.oLink,this._data.className)},finish:function(){c.removeClass(this._data.oLink, +this._data.className);this._data.className="";if(c.config.playNext){var a=c.indexByURL[this._data.oLink.href]+1;ac?"0"+c:c):{min:d,sec:c}};this.getSoundByObject=function(b){return"undefined"!== +typeof a.soundsByObject[b.id]?a.soundsByObject[b.id]:null};this.getPreviousItem=function(a){if(a.previousElementSibling)a=a.previousElementSibling;else for(a=a.previousSibling;a&&a.previousSibling&&1!==a.previousSibling.nodeType;)a=a.previousSibling;return"li"!==a.nodeName.toLowerCase()?null:a.getElementsByTagName("a")[0]};this.playPrevious=function(b){b||(b=a.lastSound);if(!b)return!1;(b=a.getPreviousItem(b._data.oLI))&&c.handleClick({target:b});return b};this.getNextItem=function(a){if(a.nextElementSibling)a= +a.nextElementSibling;else for(a=a.nextSibling;a&&a.nextSibling&&1!==a.nextSibling.nodeType;)a=a.nextSibling;return"li"!==a.nodeName.toLowerCase()?null:a.getElementsByTagName("a")[0]};this.playNext=function(b){b||(b=a.lastSound);if(!b)return!1;(b=a.getNextItem(b._data.oLI))&&c.handleClick({target:b});return b};this.setPageTitle=function(b){if(!a.config.updatePageTitle)return!1;try{document.title=(b?b+" - ":"")+a.pageTitle}catch(c){a.setPageTitle=function(){return!1}}};this.events={play:function(){c.removeClass(this._data.oLI, +this._data.className);this._data.className=c.css.sPlaying;c.addClass(this._data.oLI,this._data.className);a.setPageTitle(this._data.originalTitle)},stop:function(){c.removeClass(this._data.oLI,this._data.className);this._data.className="";this._data.oPosition.style.width="0px";a.setPageTitle();a.resetPageIcon()},pause:function(){if(c.dragActive)return!1;c.removeClass(this._data.oLI,this._data.className);this._data.className=c.css.sPaused;c.addClass(this._data.oLI,this._data.className);a.setPageTitle(); +a.resetPageIcon()},resume:function(){if(c.dragActive)return!1;c.removeClass(this._data.oLI,this._data.className);this._data.className=c.css.sPlaying;c.addClass(this._data.oLI,this._data.className)},finish:function(){c.removeClass(this._data.oLI,this._data.className);this._data.className="";this._data.oPosition.style.width="0px";a.config.playNext?c.playNext(this):(a.setPageTitle(),a.resetPageIcon())},whileloading:function(){function b(){this._data.oLoading.style.width=100*(this.bytesLoaded/this.bytesTotal)+ +"%";!this._data.didRefresh&&this._data.metadata&&(this._data.didRefresh=!0,this._data.metadata.refresh())}if(c.config.useThrottling){var l=new Date;if(l&&50 | Load failed, d\'oh! '+(b.sandbox.noRemote? +" Possible cause: Flash sandbox is denying remote URL access.":b.sandbox.noLocal?"Flash denying local filesystem access":"404?")+"";setTimeout(function(){a.innerHTML=c},5E3)}},whileplaying:function(){var d=null;if(c.dragActive||!c.config.useThrottling){a.updateTime.apply(this);9<=b.flashVersion&&(c.config.usePeakData&&this.instanceOptions.usePeakData&&a.updatePeaks.apply(this),(c.config.useWaveformData&&this.instanceOptions.useWaveformData||c.config.useEQData&&this.instanceOptions.useEQData)&& +a.updateGraph.apply(this));if(this._data.metadata&&(d=new Date)&&500c.config.flashVersion||!c.config.useWaveformData&&!c.config.useEQData)return!1;var a=this._data.oGraph.getElementsByTagName("div"),b;if(c.config.useWaveformData)for(b=255;b--;)a[255-b].style.marginTop=9+Math.ceil(-8*this.waveformData.left[b])+"px";else for(b=255;b--;)a[255-b].style.marginTop=17+Math.ceil(-9*this.eqData[b])+"px"};this.resetGraph=function(){if(!c.config.useEQData||9>c.config.flashVersion)return!1;var a=this._data.oGraph.getElementsByTagName("div"),b= +!c.config.useEQData?"9px":"17px",d=!c.config.fillGraph?"1px":"32px",e;for(e=255;e--;)a[255-e].style.marginTop=b,a[255-e].style.height=d};this.updateTime=function(){var b=a.strings.timing.replace("%s1",a.getTime(this.position,!0)),b=b.replace("%s2",a.getTime(a.getDurationEstimate(this),!0));this._data.oTiming.innerHTML=b};this.getTheDamnTarget=function(a){return a.target||(window.event?window.event.srcElement:null)};this.withinStatusBar=function(b){return a.isChildOfClass(b,"playlist")&&a.isChildOfClass(b, +"controls")};this.handleClick=function(d){if(2===d.button)return c.config.allowRightClick||c.stopEvent(d),c.config.allowRightClick;var l=a.getTheDamnTarget(d),r,e,f;if(!l)return!0;a.dragActive&&a.stopDrag();if(a.withinStatusBar(l))return!1;"a"!==l.nodeName.toLowerCase()&&(l=a.getParentByNodeName(l,"a"));if(!l)return!0;l.getAttribute("href");if(!l.href||!b.canPlayLink(l)&&!a.hasClass(l,"playable")||a.hasClass(l,"exclude"))return!0;a.initUL(a.getParentByNodeName(l,"ul"));a.initItem(l);r=l.href;(e=a.getSoundByObject(l))? +(a.setPageTitle(e._data.originalTitle),e===a.lastSound?2!==e.readyState?1!==e.playState?e.play():e.togglePause():b._writeDebug("Warning: sound failed to load (security restrictions, 404 or bad format)",2):(a.lastSound&&a.stopSound(a.lastSound),g&&e._data.oTimingBox.appendChild(g),e.togglePause())):(e=b.createSound({id:l.id,url:decodeURI(r),onplay:a.events.play,onstop:a.events.stop,onpause:a.events.pause,onresume:a.events.resume,onfinish:a.events.finish,type:l.type||null,whileloading:a.events.whileloading, +whileplaying:a.events.whileplaying,onmetadata:a.events.metadata,onload:a.events.onload}),r=a.oControls.cloneNode(!0),f=l.parentNode,f.appendChild(r),g&&f.appendChild(g),a.soundsByObject[l.id]=e,e._data={oLink:l,oLI:f,oControls:a.select("controls",f),oStatus:a.select("statusbar",f),oLoading:a.select("loading",f),oPosition:a.select("position",f),oTimingBox:a.select("timing",f),oTiming:a.select("timing",f).getElementsByTagName("div")[0],oPeak:a.select("peak",f),oGraph:a.select("spectrum-box",f),className:a.css.sPlaying, +originalTitle:l.innerHTML,metadata:null},g&&e._data.oTimingBox.appendChild(g),e._data.oLI.getElementsByTagName("ul").length&&(e._data.metadata=new Metadata(e)),l=a.strings.timing.replace("%s1",a.config.emptyTime),l=l.replace("%s2",a.config.emptyTime),e._data.oTiming.innerHTML=l,a.sounds.push(e),a.lastSound&&a.stopSound(a.lastSound),a.resetGraph.apply(e),e.play());a.lastSound=e;return a.stopEvent(d)};this.handleMouseDown=function(b){p&&b.touches&&(b=b.touches[0]);if(2===b.button)return c.config.allowRightClick|| +c.stopEvent(b),c.config.allowRightClick;var l=a.getTheDamnTarget(b);if(!l||!a.withinStatusBar(l))return!0;a.dragActive=!0;a.lastSound.pause();a.setPosition(b);p?d.add(document,"touchmove",a.handleMouseMove):d.add(document,"mousemove",a.handleMouseMove);a.addClass(a.lastSound._data.oControls,"dragging");return a.stopEvent(b)};this.handleMouseMove=function(b){p&&b.touches&&(b=b.touches[0]);if(a.dragActive)if(a.config.useThrottling){var c=new Date;20b;b++)a.vuMeterData[b]=[];for(b=0;16>b;b++)for(c=0;16>c;c++)f.setAttribute("width",16),f.setAttribute("height",16),d.fillStyle=g,d.fillRect(0,0,7,15),d.fillRect(8,0,7,15),d.fillStyle=e,d.fillRect(0,15-b,7,16-(16-b)),d.fillRect(8,15-c,7,16-(16-c)),d.clearRect(0,3,16,1),d.clearRect(0,7,16,1),d.clearRect(0, +11,16,1),a.vuMeterData[b][c]=f.toDataURL("image/png")};this.testCanvas=function(){var a=document.createElement("canvas"),b=null;if(!a||"undefined"===typeof a.getContext)return null;b=a.getContext("2d");if(!b||"function"!==typeof a.toDataURL)return null;try{a.toDataURL("image/png")}catch(c){return null}return a};this.initItem=function(b){b.id||(b.id="pagePlayerMP3Sound"+a.soundCount++);a.addClass(b,a.css.sDefault)};this.initUL=function(c){9<=b.flashVersion&&a.addClass(c,a.cssBase)};this.init=function(h){function l(b){d[b](document, +"click",a.handleClick);p?(d[b](document,"touchstart",a.handleMouseDown),d[b](document,"touchend",a.stopDrag)):(d[b](document,"mousedown",a.handleMouseDown),d[b](document,"mouseup",a.stopDrag));d[b](window,"unload",q)}h?(b._writeDebug("pagePlayer.init(): Using custom configuration"),this.config=this._mergeObjects(h,this.config)):b._writeDebug("pagePlayer.init(): Using default configuration");var r,v,k,u;this.cssBase=[];b.useFlashBlock=!0;9<=b.flashVersion?(b.defaultOptions.usePeakData=this.config.usePeakData, +b.defaultOptions.useWaveformData=this.config.useWaveformData,b.defaultOptions.useEQData=this.config.useEQData,this.config.usePeakData&&this.cssBase.push("use-peak"),(this.config.useWaveformData||this.config.useEQData)&&this.cssBase.push("use-spectrum"),this.cssBase=this.cssBase.join(" "),this.config.useFavIcon&&((f=a.testCanvas())&&m?a.createVUData():this.config.useFavIcon=!1)):(this.config.usePeakData||this.config.useWaveformData||this.config.useEQData)&&b._writeDebug("Page player: Note: soundManager.flashVersion = 9 is required for peak/waveform/EQ features."); +e=document.createElement("div");e.innerHTML='
\n
\n
\n
\n
\n
\n
\n
\n %s1 / %s2\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
'; +if(9<=b.flashVersion){g=a.select("spectrum-container",e);g=e.removeChild(g);r=a.select("spectrum-box",g);v=r.getElementsByTagName("div")[0];k=document.createDocumentFragment();u=null;for(h=256;h--;)u=v.cloneNode(!1),u.style.left=h+"px",k.appendChild(u);r.removeChild(v);r.appendChild(k)}else e.removeChild(a.select("spectrum-container",e)),e.removeChild(a.select("peak",e));a.oControls=e.cloneNode(!0);h=a.select("timing-data",e);a.strings.timing=h.innerHTML;h.innerHTML="";h.id="";q=function(){l("remove")}; +l("add");b._writeDebug("pagePlayer.init(): Ready",1);a.config.autoStart&&c.handleClick({target:c.getByClassName("playlist","ul")[0].getElementsByTagName("a")[0]})}}soundManager.useFlashBlock=!0;soundManager.onready(function(){pagePlayer=new PagePlayer;pagePlayer.init("undefined"!==typeof PP_CONFIG?PP_CONFIG:null)}); +function BasicMP3Player(){var a=this,c=this,b=soundManager,d=navigator.userAgent.match(/ipad|iphone/i),f=navigator.userAgent.match(/msie/i);this.excludeClass="button-exclude";this.links=[];this.sounds=[];this.soundsByURL={};this.indexByURL={};this.lastSound=null;this.soundCount=0;this.config={playNext:!1,autoPlay:!1};this.css={sDefault:"sm2_button",sLoading:"sm2_loading",sPlaying:"sm2_playing",sPaused:"sm2_paused"};this.includeClass=this.css.sDefault;this.addEventHandler="undefined"!==typeof window.addEventListener? +function(a,b,c){return a.addEventListener(b,c,!1)}:function(a,b,c){a.attachEvent("on"+b,c)};this.removeEventHandler="undefined"!==typeof window.removeEventListener?function(a,b,c){return a.removeEventListener(b,c,!1)}:function(a,b,c){return a.detachEvent("on"+b,c)};this.classContains=function(a,b){return"undefined"!==typeof a.className?a.className.match(RegExp("(\\s|^)"+b+"(\\s|$)")):!1};this.addClass=function(b,c){if(!b||!c||a.classContains(b,c))return!1;b.className=(b.className?b.className+" ": +"")+c};this.removeClass=function(b,c){if(!b||!c||!a.classContains(b,c))return!1;b.className=b.className.replace(RegExp("( "+c+")|("+c+")","g"),"")};this.getSoundByURL=function(b){return"undefined"!==typeof a.soundsByURL[b]?a.soundsByURL[b]:null};this.isChildOfNode=function(b,a){if(!b||!b.parentNode)return!1;a=a.toLowerCase();do b=b.parentNode;while(b&&b.parentNode&&b.nodeName.toLowerCase()!==a);return b.nodeName.toLowerCase()===a?b:null};this.events={play:function(){c.removeClass(this._data.oLink, +this._data.className);this._data.className=c.css.sPlaying;c.addClass(this._data.oLink,this._data.className)},stop:function(){c.removeClass(this._data.oLink,this._data.className);this._data.className=""},pause:function(){c.removeClass(this._data.oLink,this._data.className);this._data.className=c.css.sPaused;c.addClass(this._data.oLink,this._data.className)},resume:function(){c.removeClass(this._data.oLink,this._data.className);this._data.className=c.css.sPlaying;c.addClass(this._data.oLink,this._data.className)}, +finish:function(){c.removeClass(this._data.oLink,this._data.className);this._data.className="";if(c.config.playNext){var b=c.indexByURL[this._data.oLink.href]+1;b=Math.abs(this.state-this.target)?this.state=this.target:this.state+=a;try{this.propagate()}finally{this.options.onStep.call(this),this.target==this.state&&(window.clearInterval(this.intervalId),this.intervalId=null,this.options.onComplete.call(this))}},play:function(){this.seekFromTo(0,1)},reverse:function(){this.seekFromTo(1,0)},inspect:function(){for(var a="#"}};Animator.applyDefaults=function(a,c){c=c||{};var b,d={};for(b in a)d[b]=void 0!==c[b]?c[b]:a[b];return d};Animator.makeArray=function(a){if(null==a)return[];if(!a.length)return[a];for(var c=[],b=0;b=b?b:2-b}}; +Animator.tx={easeInOut:function(a){return-Math.cos(a*Math.PI)/2+0.5},linear:function(a){return a},easeIn:Animator.makeEaseIn(1.5),easeOut:Animator.makeEaseOut(1.5),strongEaseIn:Animator.makeEaseIn(2.5),strongEaseOut:Animator.makeEaseOut(2.5),elastic:Animator.makeElastic(1),veryElastic:Animator.makeElastic(3),bouncy:Animator.makeBounce(1),veryBouncy:Animator.makeBounce(3)}; +function NumericalStyleSubject(a,c,b,d,f){this.els=Animator.makeArray(a);this.property="opacity"==c&&window.ActiveXObject?"filter":Animator.camelize(c);this.from=parseFloat(b);this.to=parseFloat(d);this.units=null!=f?f:"px"} +NumericalStyleSubject.prototype={setState:function(a){a=this.getStyle(a);for(var c=0,b=0;b=d;d++)a=Math.max(0,Math.min(255,parseInt(b[d]))),c+=ColorStyleSubject.toColorPart(a);return c}if(b=ColorStyleSubject.parseColor.hexRe.exec(a)){if(3==b[1].length){for(d=0;3>d;d++)c+=b[1].charAt(d)+b[1].charAt(d);return c}return"#"+b[1]}return!1};ColorStyleSubject.toColorPart=function(a){255a?"0"+c:c};ColorStyleSubject.parseColor.rgbRe=/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i; +ColorStyleSubject.parseColor.hexRe=/^\#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function DiscreteStyleSubject(a,c,b,d,f){this.els=Animator.makeArray(a);this.property=Animator.camelize(c);this.from=b;this.to=d;this.threshold=f||0.5}DiscreteStyleSubject.prototype={setState:function(a){for(var c=0;c=a?(this.forwards=!1,this.animators[this.current].seekTo(0)):(this.forwards=!0,this.animators[this.current].seekTo(1))}}; +function Accordion(a){this.setOptions(a);a=this.options.initialSection;var c;this.options.rememberance&&(c=document.location.hash.substring(1));this.rememberanceTexts=[];this.ans=[];for(var b=this,d=0;da?1:0);this.options.rememberance&&(document.location.hash=this.rememberanceTexts[a])}};var threeSixtyPlayer,ThreeSixtyPlayer; +(function(a){function c(){var b=this,c=this,f=soundManager,e=navigator.userAgent,h=e.match(/msie/i),g=e.match(/opera/i),k=e.match(/safari/i),m=e.match(/chrome/i);e.match(/firefox/i);var p=e.match(/ipad|iphone/i),q="undefined"===typeof a.G_vmlCanvasManager&&"undefined"!==typeof document.createElement("canvas").getContext("2d"),n=g||m?359.9:360;this.excludeClass="threesixty-exclude";this.links=[];this.sounds=[];this.soundsByURL=[];this.indexByURL=[];this.lastTouchedSound=this.lastSound=null;this.soundCount= +0;this.vuMeter=this.oUIImageMap=this.oUITemplate=null;this.callbackCount=0;this.peakDataHistory=[];this.config={playNext:!1,autoPlay:!1,allowMultiple:!1,loadRingColor:"#ccc",playRingColor:"#000",backgroundRingColor:"#eee",segmentRingColor:"rgba(255,255,255,0.33)",segmentRingColorAlt:"rgba(0,0,0,0.1)",loadRingColorMetadata:"#ddd",playRingColorMetadata:"rgba(128,192,256,0.9)",circleDiameter:null,circleRadius:null,animDuration:500,animTransition:a.Animator.tx.bouncy,showHMSTime:!1,scaleFont:!0,useWaveformData:!1, +waveformDataColor:"#0099ff",waveformDataDownsample:3,waveformDataOutside:!1,waveformDataConstrain:!1,waveformDataLineRatio:0.64,useEQData:!1,eqDataColor:"#339933",eqDataDownsample:4,eqDataOutside:!0,eqDataLineRatio:0.54,usePeakData:!0,peakDataColor:"#ff33ff",peakDataOutside:!0,peakDataLineRatio:0.5,useAmplifier:!0,fontSizeMax:null,scaleArcWidth:1,useFavIcon:!1};this.css={sDefault:"sm2_link",sBuffering:"sm2_buffering",sPlaying:"sm2_playing",sPaused:"sm2_paused"};this.addEventHandler="undefined"!== +typeof a.addEventListener?function(b,a,c){return b.addEventListener(a,c,!1)}:function(b,a,c){b.attachEvent("on"+a,c)};this.removeEventHandler="undefined"!==typeof a.removeEventListener?function(b,a,c){return b.removeEventListener(a,c,!1)}:function(b,a,c){return b.detachEvent("on"+a,c)};this.hasClass=function(b,a){return"undefined"!==typeof b.className?b.className.match(RegExp("(\\s|^)"+a+"(\\s|$)")):!1};this.addClass=function(a,c){if(!a||!c||b.hasClass(a,c))return!1;a.className=(a.className?a.className+ +" ":"")+c};this.removeClass=function(a,c){if(!a||!c||!b.hasClass(a,c))return!1;a.className=a.className.replace(RegExp("( "+c+")|("+c+")","g"),"")};this.getElementsByClassName=function(a,c,d){var e=d||document;d=[];var f,g=[];if("undefined"!==typeof c&&"string"!==typeof c)for(f=c.length;f--;){if(!g||!g[c[f]])g[c[f]]=e.getElementsByTagName(c[f])}else g=c?e.getElementsByTagName(c):e.all||e.getElementsByTagName("*");if("string"!==typeof c)for(f=c.length;f--;)for(e=g[c[f]].length;e--;)b.hasClass(g[c[f]][e], +a)&&d.push(g[c[f]][e]);else for(f=0;fc?"0"+c:c):{min:d,sec:c}};this.clearCanvas=function(a){var b=null,c;a.getContext&&(b=a.getContext("2d"));b&&(c=a.offsetWidth,a= +a.offsetHeight,b.clearRect(-(c/2),-(a/2),c,a))};this.updatePlaying=function(){var a=this._360data.showHMSTime?b.getTime(this.position,!0):parseInt(this.position/1E3,10),c=b.config.scaleArcWidth;this.bytesLoaded&&(this._360data.lastValues.bytesLoaded=this.bytesLoaded,this._360data.lastValues.bytesTotal=this.bytesTotal);this.position&&(this._360data.lastValues.position=this.position);this.durationEstimate&&(this._360data.lastValues.durationEstimate=this.durationEstimate);b.drawSolidArc(this._360data.oCanvas, +b.config.backgroundRingColor,this._360data.width,this._360data.radius*c,b.deg2rad(n),!1);b.drawSolidArc(this._360data.oCanvas,this._360data.metadata?b.config.loadRingColorMetadata:b.config.loadRingColor,this._360data.width,this._360data.radius*c,b.deg2rad(n*(this._360data.lastValues.bytesLoaded/this._360data.lastValues.bytesTotal)),0,!0);0!==this._360data.lastValues.position&&b.drawSolidArc(this._360data.oCanvas,this._360data.metadata?b.config.playRingColorMetadata:b.config.playRingColor,this._360data.width, +this._360data.radius*c,b.deg2rad(1===this._360data.didFinish?n:n*(this._360data.lastValues.position/this._360data.lastValues.durationEstimate)),0,!0);this._360data.metadata&&this._360data.metadata.events.whileplaying();a!==this._360data.lastTime&&(this._360data.lastTime=a,this._360data.oTiming.innerHTML=a);(this.instanceOptions.useWaveformData||this.instanceOptions.useEQData)&&q&&b.updateWaveform(this);b.config.useFavIcon&&b.vuMeter&&b.vuMeter.updateVU(this)};this.updateWaveform=function(a){if(!b.config.useWaveformData&& +!b.config.useEQData||!f.features.waveformData&&!f.features.eqData||!a.waveformData.left.length&&!a.eqData.length&&!a.peakData.left)return!1;a._360data.oCanvas.getContext("2d");var c=parseInt(a._360data.circleDiameter/2,10)/2,d,e,g,k,h,m,p,n,q;if(b.config.useWaveformData){g=b.config.waveformDataDownsample;g=Math.max(1,g);k=256/g;p=b.config.waveformDataOutside?1:b.config.waveformDataConstrain?0.5:0.565;c=b.config.waveformDataOutside?0.7:0.75;n=b.deg2rad(360/k*b.config.waveformDataLineRatio);for(d=0;256> +d;d+=g)h=b.deg2rad(360*(1*(d/k)/g)),m=h+n,e=a.waveformData.left[d],0>e&&b.config.waveformDataConstrain&&(e=Math.abs(e)),b.drawSolidArc(a._360data.oCanvas,b.config.waveformDataColor,a._360data.width*p*(2-b.config.scaleArcWidth),1.25*(a._360data.radius*c)*e,m,h,!0)}if(b.config.useEQData){g=b.config.eqDataDownsample;g=Math.max(1,g);k=192;p=b.config.eqDataOutside?1:0.565;e=b.config.eqDataOutside?-1:1;c=b.config.eqDataOutside?0.5:0.75;n=b.deg2rad(360/(k/g)*b.config.eqDataLineRatio);q=b.deg2rad(1===a._360data.didFinish? +360:360*(a._360data.lastValues.position/a._360data.lastValues.durationEstimate));for(d=0;dq?b.config.eqDataColor:b.config.playRingColor,a._360data.width*p,a._360data.radius*c*a.eqData.left[d]*e,m,h,!0)}if(b.config.usePeakData&&!a._360data.animating){c=a.peakData.left||a.peakData.right;k=3;for(d=0;d',' ','
','
']}; +this.uiTest=function(a){var c=document.createElement("div"),d,e;c.className="sm2-360ui";d=document.createElement("div");d.className="ui360"+(a?" "+a:"");c=d.appendChild(c.cloneNode(!0));d.style.position="absolute";d.style.left="-9999px";a=document.body.appendChild(d);e=b.getUIHTML(c.offsetWidth);c.innerHTML=e[1]+e[2]+e[3];c=parseInt(c.offsetWidth,10);e=parseInt(c/2,10);a=b.getElementsByClassName("sm2-timing","div",a)[0];a=parseInt(b.getStyle(a,"font-size"),10);isNaN(a)&&(a=null);d.parentNode.removeChild(d); +return{circleDiameter:c,circleRadius:e,fontSizeMax:a}};this.init=function(){f._writeDebug("threeSixtyPlayer.init()");var c=b.getElementsByClassName("ui360","div"),d,e,g=[],k=!1,m=0,n,q,t,s,w;d=0;for(e=c.length;da;a++)c.vuMeterData[a]=[];for(a=0;16>a;a++)for(b=0;16>b;b++)c.vuDataCanvas.setAttribute("width",16),c.vuDataCanvas.setAttribute("height",16),e.fillStyle=h,e.fillRect(0,0,7,15),e.fillRect(8,0,7,15),e.fillStyle= +f,e.fillRect(0,15-a,7,16-(16-a)),e.fillRect(8,15-b,7,16-(16-b)),e.clearRect(0,3,16,1),e.clearRect(0,7,16,1),e.clearRect(0,11,16,1),c.vuMeterData[a][b]=c.vuDataCanvas.toDataURL("image/png")};this.testCanvas=function(){var a=document.createElement("canvas"),b=null;if(!a||"undefined"===typeof a.getContext)return null;b=a.getContext("2d");if(!b||"function"!==typeof a.toDataURL)return null;try{a.toDataURL("image/png")}catch(c){return null}return a};this.init=function(){a.config.useFavIcon&&(c.vuDataCanvas= +c.testCanvas(),c.vuDataCanvas&&(h||e)?c.createVUData():a.config.useFavIcon=!1)};this.init()};c.prototype.Metadata=function(a,c){soundManager._wD("Metadata()");var f=this,e=a._360data.oUI360,h=e.getElementsByTagName("ul")[0].getElementsByTagName("li");navigator.userAgent.match(/firefox/i);var g;this.lastWPExec=0;this.refreshInterval=250;this.totalTime=0;this.events={whileplaying:function(){var e=a._360data.width,g=a._360data.radius,h=a.durationEstimate||1E3*f.totalTime,q=null,n,l;n=0;for(l=f.data.length;n< +l;n++)q=0===n%2,c.drawSolidArc(a._360data.oCanvas,q?c.config.segmentRingColorAlt:c.config.segmentRingColor,e,g/2,c.deg2rad(360*(f.data[n].endTimeMS/h)),c.deg2rad(360*((f.data[n].startTimeMS||1)/h)),!0);e=new Date;e-f.lastWPExec>f.refreshInterval&&(f.refresh(),f.lastWPExec=e)}};this.refresh=function(){var c,d,e=null,f=a.position,g=a._360data.metadata.data;c=0;for(d=g.length;c=g[c].startTimeMS&&f<=g[c].endTimeMS){e=c;break}e!==g.currentItem&&e

";_id("search-results").style.display="block";_id("filter-box").style.display= +"block";m?(_id("filter-box").style.paddingBottom="0px",_id("filter-box").style.display="none"):(_id("filter-box").style.paddingBottom="0px",navigator.userAgent.match(/msie/i)||(_id("filter-box").style.paddingBottom=Math.max(0,(document.documentElement.scrollTop||window.scrollY)-utils.getOffY(_id("filter-box"))-parseInt(_id("filter-box").offsetHeight)-20)+"px"),_id("filter-box").style.display="block");lastSelected?lastSelected==b?utils.toggleClass(lastSelected,"active"):(utils.removeClass(lastSelected, +"active"),utils.addClass(b,"active")):utils.addClass(b,"active");lastSelected=b;"undefined"!==typeof a.preventDefault&&a.preventDefault();return!1}}function getLiveData(){getDynamicData();var a=document.domain&&document.domain.match(/schillmania.com/i)&&"undefined"!=typeof re_;loadScript("http://include.reinvigorate.net/re_.js");setTimeout(function(){"undefined"!=typeof re_&&re_(a?"f6795-v062d0xv4u":"u8v2l-jvr8058c6n")},3E3)} +function getDynamicData(){loadScript("http://www.schillmania.com/services/soundmanager2/info/?version="+soundManager.versionNumber+"&rnd="+parseInt(1048576*Math.random()))} +function loadScript(a,c){function b(){this.onload=this.onreadystatechange=null;window.setTimeout(c,20)}var d=function(){var a=this.readyState;if("loaded"==a||"complete"==a)this.onload=this.onreadystatechange=null,window.setTimeout(c,20)},f=document.createElement("script");f.type="text/javascript";c&&(f.onreadystatechange=d,f.onload=b);f.src=a;document.getElementsByTagName("head")[0].appendChild(f)}function doAltShortcuts(){} +function fixLinks(){if(document.location.protocol.match(/http/i))return!1;for(var a=document.getElementsByTagName("a"),c=null,b=null,d=a.length;d--;)if(c=a[d].href.toString(),!c.match(/http/i)&&!utils.hasClass(a[d],"norewrite")&&(c.match(/doc/i)||c.match(/demo/i)||c.match(/../)))b=Math.max(c.lastIndexOf("?"),-1),b=Math.max(c.lastIndexOf("#"),b),b=Math.max(c.lastIndexOf("/")+1,b),-1==b&&(b=c.length),c.match(/\.html/i)||a[d].setAttribute("href",c.substr(0,b)+"index.html"+c.substr(b))} +function ie6Sucks(){if(!navigator.userAgent.match(/msie 6/i))return!1;var a=_id("nav").getElementsByTagName("li")[1],c=a.getElementsByTagName("a")[0],b=a.getElementsByTagName("ul")[0];c.onclick=function(){b.style.display="block";setTimeout(function(){document.onclick=function(){b.style.display="none";document.onclick=null}},20);return!1}}function doVersion(){var a=_id("version");if(!a)return!1;a.innerHTML=soundManager.versionNumber} +function doChristmasLights(){IS_CHRISTMAS&&(window.XLSF_URL_BASE="demo/christmas-lights/",window.XLSF_LIGHT_CLASS="pico",loadScript("demo/christmas-lights/christmaslights.js",function(){"undefined"!=typeof smashInit&&setTimeout(function(){smashInit()},20)}))} +if(window.is_home){soundManager.useHTML5Audio=!0;document.location.href.match(/sm2-usehtml5audio=1/i)?soundManager.useHTML5Audio=!0:document.location.href.match(/sm2-usehtml5audio=0/i)&&(soundManager.useHTML5Audio=!1);soundManager.setup({preferFlash:!1,useFlashBlock:!0,useHighPerformance:!0,bgColor:"#ffffff",debugMode:!1,url:"swf/",wmode:"transparent"});var PP_CONFIG={autoStart:!1,playNext:!0,useThrottling:!1,usePeakData:!0,useWaveformData:!1,useEQData:!1,useFavIcon:!1};threeSixtyPlayer.config={playNext:!1, +autoPlay:!1,allowMultiple:!0,loadRingColor:"#ccc",playRingColor:"#000",backgroundRingColor:"#eee",circleDiameter:256,circleRadius:128,scaleArcWidth:1,animDuration:500,animTransition:Animator.tx.bouncy,showHMSTime:!0,useWaveformData:!0,waveformDataColor:"#0099ff",waveformDataDownsample:2,waveformDataOutside:!1,waveformDataConstrain:!1,waveformDataLineRatio:0.73,useEQData:!0,eqDataColor:"#339933",eqDataDownsample:2,eqDataOutside:!0,eqDataLineRatio:0.69,usePeakData:!0,peakDataColor:"#ff33ff",peakDataOutside:!0, +peakDataLineRatio:0.5,useAmplifier:!0};navigator.platform.match(/win32/i)&&navigator.userAgent.match(/firefox/i)&&(soundManager.useHighPerformance=!1);var checkBadSafari=function(){var a=navigator.userAgent;!document.location.href.match(/sm2-usehtml5audio/i)&&(!window.location.toString().match(/sm2\-ignorebadua/i)&&a.match(/safari/i)&&!a.match(/chrome/i)&&a.match(/OS X 10_6_([3-7])/i))&&(a=document.createElement("li"),a.innerHTML='Note: Partial HTML5 in effect. Using Flash for MP3/MP4 formats (if available) for this browser/OS due to HTML5 audio load/play failures in Safari 4 + 5 on Snow Leopard 10.6.3 - 10.6.7 (purportedly fixed in OS X 10.6.8 and 10.7 "Lion.") Issue caused by bugs in QuickTime X and/or underlying frameworks. See bugs.webkit.org #32519. (Safari on iOS, Leopard and Windows OK, however.)

Try HTML5 anyway? (some MP3 playback may intermittently fail.)', +_id("html5-audio-notes").appendChild(a))};soundManager.onready(function(){_id("sm2-support").style.display="none";_id("sm2-support-warning").style.display="none";soundManager.didFlashBlock&&soundManager.createSound({id:"success",url:"demo/_mp3/mouseover.mp3"}).play();doChristmasLights();var a,c=!1;a=navigator;var b=a.plugins,d,f=window.ActiveXObject;if(b&&b.length)(a=a.mimeTypes)&&(a["application/x-shockwave-flash"]&&a["application/x-shockwave-flash"].enabledPlugin&&a["application/x-shockwave-flash"].enabledPlugin.description)&& +(c=!0);else if("undefined"!==typeof f){try{d=new f("ShockwaveFlash.ShockwaveFlash")}catch(e){}c=!!d}a=c;b=soundManager;if(b.useHTML5Audio&&b.hasHTML5){(c=document.getElementById("html5-support-li"))&&c.parentNode.removeChild(c);d=document.createElement("div");d.id="html5-support-li";d.className="html5support";c=[];f=!1;for(item in b.audioFormats)b.audioFormats.hasOwnProperty(item)&&(f=soundManager.filePattern.test("."+item),c.push(''+(b.html5[item]?"<":"")+item+(b.html5[item]?">":"")+""));d.innerHTML=['This browser\'s <HTML5> vs. Flash support:

',c.join(""),'
',soundManager.html5.mp3||soundManager.html5.mp4?a&&soundManager.preferFlash? +'Preferring flash for MP3/MP4; try preferFlash=false for HTML5-only mode.':soundManager.html5Only?"HTML5-only mode."+(!soundManager.canPlayMIME("audio/aac")?' Try preferFlash=true for MP4 support as needed.': +""):"  Some flash required; allowing HTML5 to play MP3/MP4, as supported.

":"Flash is required for this browser to play MP3/MP4.",""].join("");_id("html5-audio-notes").appendChild(d);_id("without-html5").style.display="inline"}else _id("without-html5").style.display="none";checkBadSafari();c=utils.getElementsByClassName("button-exclude","a",_id("inline-playlist")).concat(utils.getElementsByClassName("exclude","a",_id("graphic-playlist")));a=0;for(b=c.length;a

Oh snap!

'+(soundManager.hasHTML5?"The flash portion of ": +"")+"SoundManager 2 was unable to start. "+(soundManager.useHTML5Audio?soundManager.hasHTML5?"

Some HTML5 audio support is present, but flash is needed for MP3/MP4 support on this page.":"

No HTML5 support was found, so flash is required.":"")+'

All links to audio will degrade gracefully.

If you have a flash blocker, try allowing the SWF to run - it may be visible below.

'+(soundManager.useAltURL?"Viewing offline? You may need to change a Flash security setting.": +"Other possible causes: Missing .SWF, or no Flash?")+' Not to worry, as guided help is provided.

Troubleshooting

',d=navigator.userAgent.match(/(ipad|iphone|ipod)/i);if(soundManager.html5.mp3&&soundManager.html5.mp4)return soundManager._wD("Special homepage case: Flash appears to blocked, HTML5 support for MP3/MP4 exists; trying HTML5-only mode..."),soundManager.useHTML5Audio= +!0,soundManager.preferFlash=!1,setTimeout(function(){soundManager.reboot();soundManager.onready(function(){a.innerHTML='

Support note

SoundManager 2 tried to start using HTML5 + Flash, but rebooted in HTML5-only mode as flash was blocked. Visualization demo features will not be shown in this mode. To enable flash, whitelist the blocked movie and reload this page.

'+(soundManager.useAltURL?'

Running offline? Flash may be blocked due to security restrictions; see troubleshooting for more.': +"")+"

";a.style.marginBottom="1.5em";a.style.display="block"})},1),!1;a.innerHTML=b;c.innerHTML='

SoundManager 2 could not start. See below for details.

';if(d||soundManager.getMoviePercent())_id("flashblocker").style.display="none",d&&(_id("flash-offline").style.display="none");a.style.marginBottom="1.5em";a.style.display="block";c.style.display="inline-block"})} +function startStuff(){navigator.userAgent.match(/safari/i)&&(document.getElementsByTagName("html")[0].className="isSafari");doVersion();ie6Sucks();fixLinks();getLiveData();doAltShortcuts()}document.addEventListener?document.addEventListener("DOMContentLoaded",startStuff,!1):window.onload=startStuff; diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index.css new file mode 100755 index 00000000..e98629a4 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index.css @@ -0,0 +1,2926 @@ +body { + background:#fff; + color: #444; /* scandalous. */ + margin:0px; + padding:0px; + font:76% "helvetica neue",helvetica,arial,verdana,tahoma,"sans serif"; + /* wacky IE 6 horizontal scrollbar hack */ + _width:99.5%; + /* a little fun: transition font size with @media shift. */ + -moz-transition: font-size 0.1s; + -webkit-transition: font-size 0.1s; +} + +@media all and (min-width: 1280px) { + /* holy CSS3 media queries, Batman! (in this case, larger screen widths get this rule.) */ + body { + font-size: 80%; + } +} + +@media all and (min-width: 1600px) { + /* holy CSS3 media queries, Batman! (in this case, larger screen widths get this rule.) */ + body { + font-size: 90%; + } + body.home .sm2-speaker { + max-width: 226px !important; + } + /* nav vertical align tweak */ + #nav > ul > li > strong > a { + padding-bottom: 0.5em !important; + } +} + +@media all and (min-width: 1800px) { + /* holy CSS3 media queries, Batman! (in this case, larger screen widths get this rule.) */ + body { + font-size: 105%; + } + body.home .sm2-speaker { + left: -2.5% !important; + margin-left: -15% !important; + margin-top: 20px !important; + } +} + +body.home { + min-width: 80em; +} + +body, +#main-wrapper, +#nav ul li strong a { + background: #fff url(../demo/_image/noise.png); +} + +body, +#main-wrapper, +#nav ul li strong a { + background: #fff url(../demo/_image/tiny_grid.png); + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaAgMAAADUJKRdAAAADFBMVEX8/Pz19fX09PT29vY9qbYoAAAAaElEQVR4Xk2MoREDMRADrzSDBQcEQj71GBw4kBbSQKp4YBBw9PsJyLxtsR2tZNfx/LyPhzX7R1Ue2SfjKlicDKBNdpBXsz790Nj8kUlo+WR47PvEPfY+gb7+kMhm5801EBsLvq/z3v8Apg8pkRmgbrsAAAAASUVORK5CYII=); + /* old IE */ + *background: #fff url(../demo/_image/tiny_grid.png); +} + +#nav ul li strong a { + background-position: 0px 5px; +} + +/* below block commented out as it crashes YUI Compressor (as of 12/2011) - moved out to make-rollups script. */ + +/* +* "Chunk" font by Meredith Mandel - http://work.meredithmandel.com/#379252/Typeface-Chunk-Five +* http://www.theleagueofmoveabletype.com/fonts/4-chunk +* Provided under the SIL Open Font License (OFL) +* http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL&_sc=1 +*/ + +/* +@font-face { + font-family: 'ChunkFiveRegular'; + src: url('_image/chunk-webfont.woff') format('woff'), + url('_image/chunk-webfont.ttf') format('truetype'), + url('_image/chunk-webfont.svg#ChunkFiveRegular') format('svg'); + font-weight: normal; + font-style: normal; +} +*/ + +@font-face { + /** + * DejaVu font license + * http://dejavu-fonts.org/wiki/index.php?title=Main_Page + */ + font-family: 'DejaVuSansMonoBook'; + src: url('../demo/_image/dejavusansmono-webfont.eot'); + src: url('../demo/_image/dejavusansmono-webfont.eot?#iefix') format('embedded-opentype'), + url('../demo/_image/dejavusansmono-webfont.woff') format('woff'), + url('../demo/_image/dejavusansmono-webfont.ttf') format('truetype'); + font-weight: normal; + font-style: normal; +} + +h2.special { + font-family:"ChunkFive","ChunkFiveRegular","helvetica neue",helvetica,arial,verdana,tahoma,"sans serif"; + font-weight: normal; + display: inline; +} + +h1, h2, h3, h4 { + font-size: 1em; + margin: 0px; + padding: 0px; + vertical-align: middle; + font-weight: 300; +} + +h4.new, +h4.recent, +h4.flash9 { + min-height: 24px; +} + +h1 { + font-size: 2em; + font-weight: 500; +} + +h2 { + font-size: 1.5em; +} + +h3 { + font-size: 1.17em; + font-weight: bold; + border-top: 0.25em solid #333; + border-bottom: 1px dotted #999; + padding-top: 0.25em; + padding-bottom: 0.25em; + _margin-top: 1.5em; /* fark IE6 */ +} + +body.home h3 { + border-top: 0.25em solid #444; + margin-top: 1.25em; +} + +#doc .c2 h3 { + position: relative; + background: #333; + color: #fff; + padding: 0.25em 0.75em; + border: none; + line-height: 1.4em; /* windoze alignment */ +} + +h3, +.likeh3, +.home .columnar .c2 #about-sm2 h3:first-child { /* silly override */ + margin-top:1.5em; +} + +h4 { + margin:1.5em 0px 0.5em 0px; + font-size:1.15em; + font-weight: 500; +} + +h5 { + font-size:1.2em; + font-weight: 500; + color:#333; +} + +.c2 h5 { + border-bottom:1px solid #ccc; + padding-bottom:0.25em; +} + +.sub-heading { + color: #666; + font-weight: 400; +} + +h2.special a { + /* download SM2 link */ + top: -0.65em; +} + +body.home #about-header { + /* speaker image, etc. */ + position: relative; + margin-left: 18%; + min-height: 175px; + padding-top: 1.75em; +} + +body.home #about-header .feature { + /* special alignment tweak */ + position: relative; + vertical-align: middle; + font-size: 1.2em; +} + +body.home .sm2-speaker { + position: absolute; + left: -1.5%; + top: 0px; + margin-right: 2em; + margin-bottom: 8px; + max-width: 192px; + min-width: 64px; + width: 20%; + margin-left: -20%; +} + +body.home .sm2-speaker img { + width:100%; + max-width:226px; + min-width:32px; +} + +body.home #about-sm2 h2.special, +body.home #about-sm2 h3, +body.home #about-sm2 h4 { + font-weight:500; + font-size:2em; + border-bottom:none; + padding-bottom:0px; +} + +body.home #about-sm2 h2.special { + font-size:3.5em; + color: #333; + margin-top:0.1em; +} + +body.home #about-sm2 h3 { + font-size: 2.25em; +} + +body.home #about-sm2 b { + font-weight: 500; +} + +body.home #about-sm2 strong { + font-weight: 500; + color: #333; +} + +#col3 a.button, /* "newer version available" */ +a.feature-hot, +a.feature { + display: inline-block; + -moz-transition: all 0.25s ease-in-out; + -webkit-transition: all 0.25s ease-in-out; + transition: all 0.25s ease-in-out; + text-shadow: 0px 1px 0px rgba(0,0,0,0.33); +} + +@-moz-keyframes highlight { + from { + box-shadow: 0px 0px 0px rgba(255,64,64,0); + } + to { + box-shadow: 0px 0px 16px rgba(255,64,64,0.75); + } +} + +@-webkit-keyframes highlight { + from { + box-shadow: 0px 0px 0px rgba(255,64,64,0); + } + to { + box-shadow: 0px 0px 16px rgba(255,64,64,0.75); + } +} + +#col3 a.feature { + /* "newer version available" hack */ + margin-top: 0px; +} + +a.feature-hot:hover, +a.feature:hover, +#col3 a.button:hover { + -moz-animation-duration: 0.5s; + -moz-animation-name: highlight; + -moz-animation-iteration-count: infinite; + -moz-animation-direction: alternate; + -webkit-animation-duration: 0.5s; + -webkit-animation-name: highlight; + -webkit-animation-iteration-count: infinite; + -webkit-animation-direction: alternate; +} + +body.home #about-sm2 h3 { + color:#444; + font-weight: bold; + padding-bottom: 0px; + margin-bottom: 0px; + font-weight: 300; +} + +body.home h4 { + border-bottom: 1px solid #e9e9e9; + padding-bottom: 0.33em; + margin-bottom: 0.75em; +} + +body.home #about-sm2 h4 { + font-weight: 600; + color: #777; + font-size: 1.3em; + margin-bottom: 1.25em; + margin-top: 0.15em; +} + +body.home #about-sm2 h4 b { + color: #777; +} + +body.home #about-sm2 h3 + h4 { + /* sub-headers directly under headers */ + color: #666; + font-size: 1.25em; + font-weight: 400; + margin-bottom: 2em; + border-bottom: 1px dotted #b0b0b0; + padding-bottom: 0.75em; +} + +body.home .demo-more, +body.home .demo-more-abs { + text-align:right; + font-size:85%; + margin-right:0.25em; + white-space:nowrap; +} + +body.home .demo-more-abs { + position:absolute; + right:0px; + bottom:0px; +} + +body.home #about-sm2 h4.home-shopping-network { + font-style:italic; +} + +em em { + /* special highlight */ + color:#003366; + background:#e9f3ff; + font-weight:bold; + margin-top:-0.3em; + padding:0.2em 0.25em; +} + +pre { + border-left:2px solid #f3f3f3; + padding-left:0.5em; +} + +dl pre { + border-color:#e9f3ff; +} + +dl.alt pre { + border-color:#f3f3f3; +} + +pre, +code, +pre code, +.code, +.code-block, +dt, +#soundmanager-debug, +.c3 ul li ul li { + font-family:Menlo,"DejaVu Sans Mono","DejaVuSansMonoBook",monaco,"Andale Mono","VT-100","Lucida Console","Courier New",monospace,courier,system,sans-serif; +} + +pre, +code, +.code, +dt, +#soundmanager-debug { + font-weight:normal; + line-height:auto; + color:#006699; + background:#f6fcff; +} + +.no-code-highlight pre, +.no-code-highlight code, +.no-code-highlight .code +.no-code-highlight { + background: transparent; +} + +pre, +#soundmanager-debug { + font-size: 100%; +} + +body.home p code { + font-size: 91%; +} + +pre code { + /* don't scale further down, of course... */ + font-size: 100%; +} + +pre { + line-height:1.75em; +} + +pre.specialcommentblock span span { + *line-height:1.75em; +} + +.block.small { + font-size:92%; +} + +p pre, +p.in pre { + font-size:0.97em; +} + +#soundmanager-debug { + background:#fff; + padding-left:0.75em; + border:2px solid #ddeeff; + font-size: 85%; + line-height:1.7em; +} + +body.home #soundmanager-debug { + position:fixed; + _position:absolute; /* IE <7 */ + bottom:1em; + right:1em; + height:12em; + width:auto; + overflow:auto; + padding:0px; + margin:1em 6px 6px 1em; + opacity:0.95; + color:#333; + border:1px solid #ccddee; + border-radius:3px; + background:#f3f9ff; + z-index:10; + font-size: 85%; + line-height:1.2em; +} + +body.home #soundmanager-debug div { + padding-left:0.5em; +} + +#soundmanager-debug div { + margin:0px; + padding:0.25em 0px; + font-size: 100%; + color:#333; +} + +#soundmanager-debug div { + background-color:#fff; +} + +#soundmanager-debug div.sm2-alt { + background-color: #f3f9ff; + color:#336699; +} + +#live-debug { + display:table; + *display:block; +} + +dd pre, +dd code { + background:transparent; +} + +pre code { + font-size:1em; +} + +pre { + white-space:-moz-pre-wrap; + white-space:pre-wrap; + word-wrap:break-word; /* IE */ +} + +ul.code-block em, +pre span, +code span, +dt span { + color:#339933; +} + +ul.code-block em { + font-style: normal; +} + +ul.code-block span, +pre span span, +code span span, +dt span span { + color:#667788; +} + +pre.block, +pre.block code, +div.block div.code, +ul.code-block { + position:relative; + display:table; + *display:block; + border:1px solid #ccc; + border-radius:3px; +} + +div.block, +pre.block { + background:#e9f3ff; + border-color:#eee; + padding:3px; +} + +pre.block code, +.block .code { + background:#fff; + border:1px solid #ccddee; + padding:0.5em; + font-size: 100%; + line-height:1.75em; + background-image: -webkit-linear-gradient(#fcfcfc 50%, #fff 50%); + background-image: -o-linear-gradient(#fcfcfc 50%, #fff 50%); + background-image: linear-gradient(#fcfcfc 50%, #fff 50%); + background-size: 100% 3.5em; + background-origin: content-box; +} + +#sm2-properties .code { + /* special case: no zebra striping for this one. */ + background-image: none; +} + +pre.block code { + padding: 1em; +} + +h2 code { + /* common header stuffs */ + background: none; + font-size: 93%; +} + +dl { + background:#f9fcff; + padding-bottom: 1px; + border: 1px solid #ccddee; + border-radius: 3px; + margin-top: 1em; +} + +dd { + margin:1em 0px; + padding:0px 1em; + line-height:1.75em; +} + +dt { + padding:0px; + margin:0px; + border-bottom:1px solid #ddeeff; + padding:0.5em 0.5em 0.5em 0.75em; + background:#eef6ff; + font-size:1.15em; +} + +dt.alt { + background:#f3f3f3; + border-bottom-color:#e6e6e6; +} + +dl:nth-child(2n+1), +dl.alt { + background:#fcfcfc; + padding:0px 0px 1px 0px; + border-color:#ddd; +} + +dl.tight dt.alt { + background: #fcfcfc; +} + +#smsound-methods dl a { + font-weight: normal; +} + +#smsound-methods dt:last-of-type { + border-bottom: none; +} + +h2 { + padding-top:0.5em; +} + +#top { + position:relative; + padding:1em 1em 0px 1.5em; + max-width: 95.5em; + color:#fff; + z-index:3; + margin: 0px auto; +} + +#content { /* #top #content */ + background: #222 url(../demo/_image/noise-dark.png); +} + +#top, +#top div { + *zoom:1; +} + +#top h1 { + /* special christmas light case */ + display:inline; +} + +#top h2 { + /* tagline */ + font-size:1.25em; + font-weight:300; + padding-top:2px; +} + +#top h1, +#top h2, +#version { + text-shadow: 0px 1px 0px rgba(0,0,0,0.5); +} + +#main-wrapper { + position: relative; + /* fade out the body texture */ + /* + border: 1px solid #fff; + */ + box-shadow: inset 0px 0px 16px #fff; +} + +#main { + position:relative; + padding:0px 0px 2em 0px; + padding-top:1px; + margin:0px auto; + *padding:0px 1em 2em 1em; + zoom:1; + /* + box-shadow: 0px 0px 32px rgba(0,0,0,0.05); + */ +} + +#main { + max-width: 98em; +} + +body.home #main { + box-shadow: none; + max-width: 104em; +} + +.columnar { + position:relative; + margin:0px; + padding:0px; + margin:1.9em 0.5em 0.5em 1em; /* slight left tweak */ +} + +.columnar .c1 { + position:absolute; + left:0px; + top:0px; + width:20em; + height:30px; + _position:relative; /* IE 6 hackery */ + _height:auto; +} + +#doc .columnar .c1 { + left:auto; + right:1em; + _right:auto; +} + +.columnar .c1 h2 { + position:relative; + font-size:1.2em; + padding:0.37em 0.5em; + vertical-align:middle; + background:#333; + color:#fff; + text-indent: 0.25em; +} + +.columnar .c1 p { + margin:0.5em 0px 1em 0px; + padding-left:0.5em; + padding-right:0.5em; + font-size:0.95em; + line-height:1.35em; + color:#666; +} + +.columnar .c1 p code { + color:#336699; +} + +.columnar .c2 { + position:relative; + margin-top:0px; + margin-left:22em; + margin-bottom:1.5em; +} + +.triple .columnar .c2 { + margin-right:21.25em; + min-width:20em; +} + +#doc .triple .columnar .c2 { + margin-left:21.5em; + margin-right:23em; + _margin-right:0px; /* not you, IE 6. */ +} + +#doc.special .triple .columnar .c2 { + /* override case: make c2 extra-wide. */ + margin-right: 0.75em; + max-width: 70em; +} + +#doc .triple .columnar .c1 { + margin-right:0px; + margin-left:21.25em; +} + +.columnar .c2 p:first-child { + margin-top:0.2em; +} + +.columnar .c2 > .f-block:first-child > h4 { + margin-top:0.5em; +} + +.columnar .c2 strong strong { + display:block; + padding:0.5em; + border-bottom:1px solid #999; + background:#f0f6ff; + color:#336699; +} + +.columnar .c2 p { + line-height:1.75em; + padding-top: 0.25em; + padding-bottom: 0.25em; +} + +p code, +.columnar .c2 p code { + font-size: 97%; +} + +.three .columnar { + position:relative; +} + +.three .columnar .c1 { + position:relative; + width:20em; +} + +.three .columnar .c2 { + position:relative; + margin-right:16em; +} + +.c3 { + position:absolute; + right:1em; + margin-right:16px; + top:2em; + width:16em; + margin-top:-0.5em; +} + +#doc .c3 { + right:auto; + margin-right:0px; + margin-left:16px; + left:1.25em; + z-index: 1; +} + +#nav { + position:relative; + margin-top:0.75em; + margin-left:-0.5em; +} + +ul { + /* lists inside main content area */ + line-height: 1.75em; +} + +ul li { + margin-bottom: 0.75em; +} + +#nav ul { + margin:0px; + padding:0px; + line-height:1em; + list-style-type:none; +} + +#nav ul li { + position:relative; + margin:0px; + padding:0px; + float:left; + display:inline; + padding-right:1px; +} + +#nav ul li ul { + position:absolute; + z-index:1; + display:none; + min-width:19em; + max-width:21em; + background:#3399cc; + background: -moz-linear-gradient(top, rgba(51,153,204,0.99) 0%, rgba(35,96,127,0.96) 100%); /* FF3.6+ */ + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(51,153,204,0.99)), color-stop(100%,rgba(35,96,127,0.96))); /* Chrome,Safari4+ */ + background: -webkit-linear-gradient(top, rgba(51,153,204,0.99) 0%,rgba(35,96,127,0.96) 100%); /* Chrome10+,Safari5.1+ */ + background: -o-linear-gradient(top, rgba(51,153,204,0.99) 0%,rgba(35,96,127,0.96) 100%); /* Opera 11.10+ */ + background: -ms-linear-gradient(top, rgba(51,153,204,0.99) 0%,rgba(35,96,127,0.96) 100%); /* IE10+ */ + background: linear-gradient(top, rgba(51,153,204,0.99) 0%,rgba(35,96,127,0.96) 100%); /* W3C */ + text-shadow: 0px 1px 0px rgba(0,0,0,0.25); + _width:19em; + *top:2.3em; + *left:0px; +} + +#nav ul li:last-child ul { + right:1px; +} + +#nav ul li:hover ul, +#nav ul li ul:hover { + display:block; +} + +#nav ul li ul li { + float: none; + display: block; + width: 100%; +} + +#nav ul li ul li a { + display: block; + width: auto; + border: none; + padding: 0.5em 0px 0.5em 1em; + font-size: 1.1em; + line-height: 1.1em; + color: #fff; + font-weight: 300; + color:rgba(255,255,255,0.9); + border-bottom: 1px dotted rgba(0,0,0,0.2); + border-top: 1px dotted rgba(255,255,255,0.2); +} + +#nav ul li ul li:first-of-type a { + border-top: none; +} + +#nav ul li a { + display: inline-block; + padding: 0.5em 1em; + text-decoration: none; + font-weight: bold; + color: #fff; +} + +#nav ul li ul li a:hover { + background-color: #336699; + background-color: rgba(0,0,0,0.45); +} + +#nav>ul>li>a, +#nav>ul>li>strong>a { + /* top-level links */ + color:#ddd; + font-size: 1.25em; + font-weight: 300; + vertical-align: bottom; +} + +#nav ul li strong a { + color:#333; +} + +#nav > ul > li > strong > a { + /* tweak for good browsers that respect larger font size */ + padding-bottom: 8px; +} + +#nav ul li a:hover, +#nav>ul>li:hover>a { + /* top-level */ + background: #3399cc; + color:#fff; + text-shadow: 0px 1px 0px rgba(0,0,0,0.25); +} + +#version { + position:relative; + float:right; + display:inline; + margin-left:1em; + font-size:85%; + margin-bottom:0px; + bottom: -1em; + color:#999; +} + +div.clear { + clear:both; + font-size:1px; + line-height:1px; +} + +.note { + margin-top:0.5em; + font-size:0.95em; + color:#999; +} + +.note a { + color:#666; + padding:1px; + margin:-1px; +} + +.note a:hover { + color:#fff; + background:#666; +} + +.medium-note { + padding-top:1.5em; + font-size:1em; +} + +ul.standard { + line-height:1.5em; + padding-left:1.2em; + *padding-left:0px; + color:#333; + margin-top:1em; + margin-bottom:1em; + list-style-type:square; +} + +ul.standard li { + margin-bottom:0.5em; +} + +ul.standard ul { + margin-top:0.5em; + margin-bottom:1.5em; + padding-left:1.2em; +} + +.c3 ul { + list-style-type:none; +} + +.c3 ul, +.c3 ul li { + margin:0px; + padding:0px; +} + +.c3 h2 { + font-size:1.1em; + text-indent:0.4em; +} + +.c3 ul li a { + display: block; + text-decoration:none; +} + +.c3 ul li, +.c3 ul li a, +.c3 ul li a:hover, +.c3 ul li a:focus { + color:#555; + _color:#555; + outline:none; +} + +.c3 ul li.active { + box-shadow: 0 0 6px #003366 inset; + border-radius: 1px; +} + +.c3 ul li.active a { + border-radius: 2px; + text-shadow: 0px 1px 0px rgba(0,0,0,0.25); +} + +.c3 ul li.active, +.c3 ul li.active a, +.c3 ul li ul li:hover, +.c3 ul li ul li:hover a { + color: #fff; +} + +.c3 ul li.active a:hover { + _color:#fff; +} + +.c3 .box { + margin-top:6px; +} + +.wedge, +.c3 h2 { + position:relative; + background:#333; + color:#fff; + margin:0px; + padding:0px; + height:2.101em; + line-height:1.65em; +} + +.c3 h2 { + height:2em; + line-height:2em; +} + +.c3 h2, +#doc .c2 h3 { + text-shadow: 0px 1px 0px #000; +} + +.wedge { + background-color:#3399cc; +} + +.wedge-dark { + background:#333; +} + +.wedge .l, +.wedge .r { + border-top:1.75em solid #333; +} + +.c3 h2 .l, +.c3 h2 .r { + border-top: 2em solid #333; + border-top: 2.1em solid #333\9; /* IE 8 */ +} + +.wedge .l, +.c3 h2 .l, +.wedge .r, +.wedge-dark .r, +.c3 h2 .r { + background:transparent url(../demo/_image/wedge.png) no-repeat; + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAAEABAMAAACJ12OUAAAAGFBMVEUREREAZpkYGBgAZpkiIiIAZpkREREAZpkArR2CAAAABnRSTlMAAOvrEhJBIv9yAAAC0UlEQVR42u3ZuW0cQRCF4cIPhrG2MhDkLZgDM5ChBGQoKBlMgdgElAQ9gVACNMTZ2WOO7rraI2rcna33cdjTTTzyQ7++fzFuQPTrdDBuMAa8H04vQwNOL++HkQHTtw0CBmAekh0wf1cnYAEsAibAIGACDAI2QCdgA3QCDoBKwAFQCXgAGgEPQCPgAigEXACFgA/QJ+AD9Ak4AV0CTkCXgBfQI+C/tT0W952dubgBncH4Ae3J+AHt0QQAzdkEAM3hRACt6UQArfGEAI35hACNAGKAfQIxwD6CIGCXQRCwCyEK2KYQBWxjCAM2OYQBmyDigHUSccA6igRglUUCsAojA1imkQEs40gBFnmkAItAcoB7IjnAPZIk4JZJEnALJQu4ppIFXGNJAy65pAGXYPKAOZk8YI5mAHDOZgBwJjACmAiMACYCT7/U6+c3/fOv1R9Uf1D9QfUH1R9Uf1D9QfUH1R9Uf1D9QfUH1R9Uf1D9wefvD/4NXhwfRwQPrzy8jgw4PiIjhI90ZITwEY4MEKZsZIAwRSN5wjkZyRPOwUiaMOciacIci2QJl1QkS7iEIknCNRNJEq6RSI5wS0RyhFsgkiLc85AU4R6HZAiLNCRDWIQhCcIyC0kQllFInLBKQuKEVRASJqxzkDBhHYNECZsUJErYhCBBwjYDCRK2EUiMsEtAYoRdABIi7OcjIcJ+PBIhNKYjEUJjOBIgtGYjAUJrNOInNCcjfkJzMO47O3Px39oeixvb+cFwP67Oo8X7vHpPFu9vrPe7xblmuqsL56rtrm98y7a/vPG9OP0XDNerq7ziuDYPZZPBs3toewye/Uvb5XDsoOo+i2MPV3d67E1c3+ixjxH9qME8yIzDDvMoNY5brLPUOm2xTnPrvLf++3+0/uLgz2/1ev6rf/5W/UH1B9UfVH9Q/UH1B9UfVH9Q/UH1B9UfVH9Q/UH1B9UffPr+4D+tsZObsTO2qgAAAABJRU5ErkJggg==); + *background-image:url(../demo/_image/wedge.png); +} + +.wedge .l, +.c3 h2 .l { + background-position: -64px 0px; + position:absolute; + left:0px; + top:0px; + width:16px; + height:100%; + margin-left:-16px; +} + +.wedge .r, +.wedge-dark .r, +.c3 h2 .r { + background-position: -48px 0px; + position:absolute; + right:0px; + top:0px; + width:16px; + height:100%; + margin-right:-16px; +} + +.wedge .l, +.wedge .r { + border-color:#3399cc; +} + +.wedge .l { + background-position:-64px -64px; + border-top: 2em solid #3399cc +} + +.wedge .r { + margin-top:-15px; + border-top:none; + height:16px; + border-bottom:2em solid #3399cc; + background-position:0px -192px; +} + +.wedge-dark .l, +.wedge-dark .r { + border-color:#333; +} + +.wedge-dark .l { + background-position:-64px 0px; +} + +.wedge-dark .r { + background-position:0px -128px; +} + +.c3 h2 .r.up { + margin-top:-16px; + border-top:none; + height:16px; + border-bottom:1.66em solid #333; + background-position:0px -128px; +} + +.c3 h2 .l.flat, +.wedge .l.flat, +.c3 h2 .r.flat, +.wedge .r.flat { + background-image:none; +} + +.c3 ul { + margin:0px; + padding:0px; + list-style-type:none; +} + +.c3 ul li { + border:1px solid #f3f3f3; + border-top:none; + border-bottom:none; +} + +.c3 ul ul li { + border:none; +} + +.c3 ul li { + margin:0px; + padding:0px; +} + +.c3 ul li ul li { + background-color: #fcfcfc; + background-color: rgba(255,255,255,0.5); + font-size: 97%; + line-height:2.4em; + text-indent:0.5em; + padding: 0px 0.25em; + cursor:hand; + border-bottom: 1px dotted #eee; +} + +.c3 ul li ul li:hover { + background-color:#999; + cursor:pointer; + cursor:hand; +} + +.c3 ul li ul li.active { + background-color:#3399cc; + color:#fff; +} + +.c3 h3 { + position: relative; + margin: 0px; + padding: 0px; + height: auto; + min-height: 25px; + background: #3399cc; + border: none; + color: #fff; + text-indent: 0.5em; + font-size: 1em; + line-height: 2em; + text-shadow: 0px 1px 0px rgba(0,0,0,0.25); +} + +.c3 h4 { + font-size:1em; + margin:0px; + padding:0.4em 0.2em 0.4em 0.75em; + vertical-align:middle; + color:#333; + background-color: #f3f3f3; + background-color: rgba(0,0,0,0.05); + border-top: 1px dotted #d6d6d6; + border-bottom: 1px dashed #e9e9e9; + text-shadow: 0px 1px 0px #fff; +} + +.c3 h4:first-of-type { + border-top-color: transparent; +} + +#get-satisfaction h2 a { + color:#fff; +} + +#get-satisfaction a { + color:#555; +} + +#get-satisfaction a:hover { + color:#fff; +} + +.c3 h2 a { + color:#fff; +} + +.c3 h2 a:hover { + color:#fff; + text-decoration:underline; +} + +.flash9 { + background-image:url(../demo/_image/flash9.png); + background-repeat:no-repeat; + background-position:bottom right; + _background-image:none; +} + +li.flash9 { + background-position:bottom right; +} + +.flash9:hover, +.flash9.active { + background-image:url(../demo/_image/flash9-dark.png); + _background-image:none; +} + +.new { + background-image:url(../demo/_image/new.png); + background-repeat:no-repeat; + background-position:bottom right; + _background-image:none; +} + +.recent { + background-image:url(../demo/_image/new-bw.png); + background-repeat:no-repeat; + background-position:bottom right; + _background-image:none; +} + +.new:hover, +.new.active, +.recent:hover, +.recent.active { + background-image:url(../demo/_image/new-dark.png); + background-repeat:no-repeat; + background-position:bottom right; + _background-image:none; +} + +.deprecated { + font-style: italic; + color: #333 !important; +} + +span.nevermind, +.removed { + text-decoration:line-through; + opacity:0.33; +} + +strong.removed { + font-weight: normal; + opacity:0.5; +} + +.padded { + padding:0.5em; +} + +dd.deprecation-note { + color: #993333; + background-color: #fff6f6; +} + +.c3 p { + font-size:0.9em; + padding-left:0.75em; + padding-right:0.5em; +} + +.c1 pre code { + margin-top:0px; + color:#336699; + margin-left:0px; +} + +.c1 pre { + margin-top:0px; + padding-top:0px; + margin-left:0.5em; +} + +#reset-filter { + position:relative; + font-family:"Helvetica Neue","Helvetica",helvetica,arial,verdana,sans-serif; + font-weight:300; + font-size:2.5em; +} + +.c2 .option { + font-size:85%; + float:right; + display:inline; + margin-left:1em; + margin-right:0.5em; + margin-top:3px; + line-height:1em; + white-space:nowrap; +} + +.c2 .option a { + padding:0.1em 0.35em 0.1em 0.35em; + color:#3399cc; +} + +#filter-box { + position:relative; + display:none; +} + +#get-satisfaction { + position:relative; +} + +#support-wrapper { + position: relative; + background: #fff; + border: 1px solid rgba(0,0,0,0.03); + box-shadow: 0px 0px 1px rgba(0,0,0,0.075); +} + +#gsfn_content { + position: relative; + padding:0.5em 0px 0.5em 0px; +} + +#gsfn_content ul { + position: relative; + /* initially, hide and then expand. */ + overflow: hidden; + height: 0px; + margin: 0px; + /* smooth height transitions, why not */ + -webkit-transition: height 0.5s ease-in-out; + -moz-transition: height 0.5s ease-in-out; + transition: height 0.5s ease-in-out; +} + +#gsfn_list_widget.loaded ul { + /* JS callback assigns this class when load is complete */ +} + +#gsfn_content ul li { + border:none; +} + +div#gsfn_list_widget img { + border: none; +} + +div#gsfn_list_widget a { + text-decoration:none; +} + +div#gsfn_list_widget a.widget_title { + display: block; + margin-bottom: 10px; + font-weight: bold; +} + +div#gsfn_list_widget .powered_by { + font-family:verdana,arial; + margin:-0.25em 1em 0px 1em; + padding:0.25em 0px 0.5em 0px; + border-top: 1px dotted #ddd; + font-size:75%; +} + +body.home div#gsfn_list_widget .powered_by { + padding-bottom: 0px; +} + +div#gsfn_list_widget .powered_by a { + font-style: italic; + color: #999; +} + +div#gsfn_list_widget .powered_by a:hover { + color:#333; +} + +div#gsfn_list_widget div#gsfn_content { + font-size:0.88em; + padding-left:0.5em; + padding-right:0.5em; +} + +div#gsfn_list_widget div#gsfn_content li { + text-align:left; + position: relative; + clear:right; + *zoom:1; +} + +div#gsfn_list_widget div#gsfn_content li:hover, +div#gsfn_list_widget div#gsfn_content li:hover a { + background:#3399cc; + color:#fff; +} + +div#gsfn_list_widget div#gsfn_content a.gsfn_link { + display:block; + line-height:1.2em; + padding:5px 0px 5px 5px; +} + +div#gsfn_list_widget div#gsfn_content a.gsfn_link:hover { + _color:#fff; + _background-color:#3399cc; +} + +div#gsfn_list_widget div#gsfn_content span.time { + font-size: 85%; + color:#999; + padding-left:3px; + padding-right:3px; + text-align:right; + float:right; + display:inline; + margin-top:1px; +} + +div#gsfn_list_widget div#gsfn_content li:hover span.time { + color:#fff; +} + +div#gsfn_list_widget div#gsfn_content p.gsfn_summary { + margin-top: 2px; + position:relative; + z-index:2; +} + +.tight { + margin-top:0px; +} + +.compact { + margin-bottom:0.25em !important; +} + +.smaller { + margin-top: 0px !important; + margin-bottom: 0.25em !important; +} + +.c2 a, +a.cta { + margin-top:-0.3em; + padding:0.2em 0.25em; + margin-left: -0.25em; + margin-right: -0.25em; + *margin: 0px; + *padding: 0px 2px; + *margin: 0px -2px 0px -2px; + text-decoration:none; + color:#3399cc; + border-radius:0.25em; + zoom:1; +} + +body.home .c2 a, +body.home a.cta { + text-shadow: 0px 1px 0px #fff; +} + +body.home .c2 a:hover, +body.home a.cta:hover { + text-shadow: none; +} + +pre code a, +.c2 pre code a { + color: #3399cc; + font-weight: 400; + text-decoration: none; + text-shadow: none; +} + +pre code a:hover, +.c2 pre code a:hover { + background-color: #3399cc; + color: #fff; + font-weight: 400; +} + +/* redefine for simple mp3 button demo */ +.c2 a.sm2_button { + border-radius:6px; +} + +.c2 a.sm2_button.type-2 { + border-radius:9px; +} + +.c2 a { + color:#3399cc; + font-weight:500; + text-decoration:none; +} + +.c2 a.cta { + text-decoration:none; +} + +a.cta span { + font-size:1.5em; + line-height:1em; +} + +a.cta:hover, +.c2 a:hover, +#sm2-options a:hover { + position: relative; + z-index: 1; + background-color:#3399cc; + border-color:#3399cc; + color:#fff; + text-decoration:none; +} + +.c2 a.sm2_button:hover { + /* arg. not specific enough, redefine here. */ + background-color:#cc3333; +} + +dt a:hover span { + color: #fff; +} + +a.cta-more { + color:#ddeeff; + font-size:0.8em; + position:absolute; + right:0px; + margin:0px; + padding:1px; + bottom:0.9em; + line-height:1em; +} + +a.cta-more:hover { + background:#fff; + color:#3399cc; +} + +div.html5support { + clear: both; + padding-top: 2em; +} + +div.html5support span { + padding:0px 5px; + display:inline-block; + text-align:center; + font-weight:bold; + background:#ccc; + color:#fff; + border-radius:5px; + margin-left:0.5em; + margin-bottom:0.25em; +} + +div.html5support em { + font-weight:bold; +} + +div.html5support span.true { + background:#669966; +} + +div.html5support span.partial { + background:#993333; +} + +div.html5support em.partial { + color:#993333; +} + +div.html5support em.true { + color:#669966; +} + +#nav ul li ul { + /* eh, why not. */ + box-shadow:2px 2px 2px rgba(51,153,204,0.2); +} + +.newer { + vertical-align: middle; + margin-top: 1em; + margin-bottom: 1em; +} + +.newer a, +a.feature, +.feature-hot { + position:relative; + display:inline-block; + background:#3399ff; + font-size: 1.1em; + line-height: 1.75em; + padding: 0px 0.5em; + margin: 0px 0.125em; + color:#fff; + font-weight:bold; + border:3px solid #cce6ff; + border:3px solid rgba(255,255,255,0.66); + border-radius:8px; + text-decoration:none; +} + +a.feature { + margin-left:0px; +} + +.newer a, +.feature-hot { + background:#ff0000; + border-color:#ff6666; + color:#fff; +} + +.newer a:hover, +.c2 .feature-hot:hover { + background:#990000; + border-color:#cc0000; +} + +a.feature:focus, +a.feature:hover { + background:#ff0000; + border-color:#ff6666; + color:#fff; +} +# +a.warning, +span.warning { + font-weight:bold; +} + +a.warning, +span.warning, +a.warning code, +span.warning code { + color:#993300; +} + +a.warning:hover { + color:#fff; + background:#993300; +} + +.newer p { + margin:0px; + padding:0px; +} + +.scratched-out { + display: inline-block; + text-decoration:line-through; + color:#999; + font-size:0.9em; + margin-top:-0.75em; + -webkit-transform:rotate(-15deg); + -moz-transform:rotate(-15deg); + transform:rotate(-15deg); +} + +div.inthewild { + position: relative; + margin-top:1em; +} + +ul.inthewild { + display: inline; + margin: 0px auto; + list-style-type: none; +} + +ul.inthewild, +ul.inthewild li { + position: relative; + margin: 0px; + padding: 0px; +} + +ul.inthewild { + margin-bottom: 2em; +} + +ul.inthewild li { + display: inline-block; + *float: left; + *display: inline; + width: 128px; + height: 64px; + vertical-align: middle; + text-align: center; + margin: 2px 0px; + background-color: #fcfcfc; + background-color: rgba(255,255,255,0.5); + border-radius: 2px; + border: 1px solid #eee; + border-color: rgba(0,0,0,0.05) +} + +ul.inthewild a, +ul.inthewild a img { + border:none; + vertical-align:middle; +} + +ul.inthewild a { + position: absolute; + left: 50%; + top: 50%; + overflow:hidden; + margin: 0px; + padding: 0px; + border-radius: 0px; + background: transparent url(../demo/_image/logo-sprite.png) no-repeat 0px 0px; + line-height: 96px; + vertical-align: middle; +} + +ul.inthewild a:hover { + background-color: transparent; +} + +ul.inthewild a span { + position:absolute; + text-indent:-9999em; +} + +#eight-tracks { + background-position: 0 0; + width: 64px; + height: 20px; + margin: -10px 0px 0px -32px; +} + +#audiogalaxy { + width: 100px; + height: 22px; + background-position: 0 -37px; + margin: -11px 0px 0px -50px; +} + +#discogs { + background-position: 0 -72px; + width: 55px; + height: 20px; + margin: -10px 0px 0px -27px; +} + +#hypem { + background-position: 0 -111px; + width: 80px; + height: 38px; + margin: -19px 0px 0px -40px; +} + +#lastfm { + background-position: 0 -176px; + width: 80px; + height: 28px; + margin: -14px 0px 0px -40px; +} + +#pitchfork { + background-position: 0 -688px; + width: 100px; + height: 20px; + margin: -10px 0px 0px -50px; +} + +#nyancat { + background-position: 0 -312px; + width: 64px; + height: 40px; + margin: -20px 0px 0px -32px; +} + +#soundcloud { + background-position: 0 -424px; + width: 83px; + height: 58px; + margin: -29px 0px 0px -42px; +} + +#turntable-dot-fm { + background-position: 0 -252px; + width: 100px; + height: 20px; + margin: -10px 0px 0px -50px; +} + +#baroque-me { + background-position: 0 -541px; + width: 88px; + height: 47px; + margin: -23px 0px 0px -42px; +} + +#freesound { + background-position: 0 -635px; + width: 100px; + height: 27px; + margin: -15px 0px 0px -50px; +} + +div.inthewild.active li:hover { + background-color: rgba(255,255,255,0.9); + border-color: #ccc; + box-shadow: 0px 0px 3px rgba(0,0,0,0.075); +} + +/* homepage-specific demo shiz */ + +.sidenote { + font-size:85%; + opacity:0.75; +} + +ul.playlist { + font-size:85%; +} + +ul.playlist li { + margin-bottom:0.2em; +} + +ul.playlist li a { + font-size:1em; + color:#333; +} + +ul.playlist li a, +ul.playlist li a:hover { + background:transparent; + border-radius:0px; + line-height:1em; +} + +ul.playlist li .timing { + margin-right: 0.1em; + font-size: 50%; + top: 0.5em; +} + +ul.playlist.use-peak li .peak { + /* overrides */ + height:0.61em; + margin-top:-5px; + width:0.92em; +} + +html.isSafari ul.playlist.use-peak li .peak { + margin-top:-4px; /* dumb tweak */ +} + +ul.playlist.use-peak li .timing { + right:4em; +} + +ul.playlist.use-peak li .peak-box { + height:0.66em; +} + +ul.playlist li .peak .l { + margin-right:0px; +} + +ul.playlist li .peak .l, +ul.playlist li .peak .r { + width:6px; +} + +ul.playlist li .peak .r { + left:9px; +} + +a.not-supported { + /* give user a hint that the format doesn't work */ + text-decoration:line-through; + color:#666; + opacity:0.25; +} + +ul.graphic li { + line-height:1.5em; +} + +ul.graphic li a, +ul.graphic li a.sm2_link { + min-width:17.75em; + width:auto; +} + +ul.graphic li a, +ul.graphic li a.sm2_link { + background-color:#ddd; + border-color:#ddd; + color:#333; + vertical-align:middle; +} + +ul.graphic li a { + background:#ddd url(../demo/play-mp3-links/image/icon_play.png) no-repeat 3px 50%; + background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAA6ElEQVR42q2UvQqDMBRGC47dAj6rgygIDg5OfQlHF30GX0JFURddnEQU+eoNLaSJFRUvnPzA/c4QkjwA3AIf1tJWnitsRT8I+2Q0UfTM8/yFk0UZyooiNk0ThmE4BWUoK4r0cRxxBcr+iMh+AVW0LAtkoihCURS0/ocqwkaZpgnbtrmwrmts1DGR67owDIPjeR7iOEbXdfuisiwh4zgOSb5wcZIkYo8qapoGMpZlkYALwzBElmWoqkrsUUVt20LG930EQUAHTvstVFHf95BJ05TmPVQR3dQLKCI2zzOuQNnbHu3t38gtvAF1L6rpAc8MDwAAAABJRU5ErkJggg==); + *background-image: url(../demo/play-mp3-links/image/icon_play.png); + _background-image:url(../demo/play-mp3-links/image/icon_play.gif); +} + +ul.graphic li a:hover, +ul.graphic li a.sm2_paused:hover, +ul.graphic li a.sm2_link:hover, +ul.graphic li a.sm2_playing, +ul.graphic li a.sm2_playing:hover { + background-color:#336699; + border-color:#336699; + color:#fff; +} + +ul.graphic li a.sm2_link { + /* Doesn't work on this page. */ + -webkit-transition-property: none; + -webkit-transition: none; +} + +.c2 ul.playlist li a { + margin:0px; + padding:0px; + letter-spacing: -0.02em; +} + +ul.inline-playlist { + min-height:49px; + min-width:512px; + margin-top:4em; +} + +ul.inline-playlist li { + float:left; + display:inline; + width:45%; + margin-right:0.25%; +} + +body.home .sm2-inline-list .ui360-vis { + margin-right:0px; +} + +body.home #special-demo-left .ui360 { + margin-right: 4px; + /* homepage-specific demo UI: a slight inner shadow + BG color + border */ + background-color: rgba(0,0,0,0.025); + box-shadow: inset 0px 0px 8px rgba(0,0,0,0.075); + /* a little radii, modern browsers only */ + border: 1px solid rgba(0,0,0,0.075); + border-radius: 32px; + -webkit-transition: all 0.2s ease-in-out; + -moz-transition: all 0.2s ease-in-out; + transition: all 0.2s ease-in-out; + /* specifics */ + -moz-transition-property: background, border, box-shadow; + -webkit-transition-property: background, border, box-shadow; + transition-property: background, border, box-shadow; +} + +body.home #special-demo-left .ui360:hover { + background-color: rgba(0,0,0,0.045); + border-color: rgba(0,0,0,0.15); + box-shadow: inset 0px 0px 5px rgba(0,0,0,0.15); +} + +body.home #special-demo-left .ui360:last-child { + margin-right: 0px; +} + +body.home .columnar .c2 p { + font-size: 1.1em; + line-height:1.6em; + color:#333; +} + +body.home .c2 ul.playlist li a { + _color:#000; /* stupid IE */ +} + +body.home .c2 ul.playlist li.sm2_paused a, +body.home .c2 ul.playlist li.sm2_playing a { + _color:#fff; /* argh */ +} + +body.home .c2 ul.standard { + _margin-left:1.5em; +} + +body.home .ie6sucks { + _background: transparent !important; + _display: none !important; +} + +body.home .ie7sucks { + *display: none !important; +} + +/* Flash positioning and flashblock / clicktoflash handling */ + +/* special-case for the SM2 homepage only */ + +body.home #sm2-container { + position: fixed; + bottom: 0px; + left: 0px; + width: 48px; + height: 48px; + /* IE 6 hax, unlikely to have flashblock anyway... */ + _margin:-8px 0px 0px 0px; +} + +@-moz-keyframes flashblock { + from { + border-color: #ff3333; + } + + to { + border-color: #fff; + } +} + +@-webkit-keyframes flashblock { + from { + border-color: #ff3333; + } + + to { + border-color: #fff; + } +} + +body.home #sm2-container.swf_timedout { + /* blocked state */ + border:1px solid #ff3333; + -moz-animation-duration: 1s; + -moz-animation-name: flashblock; + -moz-animation-iteration-count: 5; + -webkit-animation-duration: 1s; + -webkit-animation-name: flashblock; + -webkit-animation-iteration-count: 5; + width:48px; + height:48px; +} + +body.home #sm2-container.swf_unblocked { + /* unblocked state */ +} + +body.home #sm2-container.swf_unblocked, +body.home #sm2-container.swf_loaded { + top:auto; + left:0px; + bottom:0px; + margin:0px; + width: 6px; + height: 6px; +} + +#sm2-support-warning { + display:none; + border:1px solid #ff9999; + padding:0.5em; + margin-top:1.5em; + font-weight:bold; +} + +#sm2-support { + display:none; + font-size:0.9em !important; + margin-top: 1.5em; +} + +#sm2-support-warning, +#sm2-support { + background:#fff6f0; + border:1px solid #ff3333; +} + +body.home #about-sm2 #sm2-support h3 { + border-color:#ff9999; + margin-top:0.25em; +} + +body.home #special-demo-left { + min-height:70px; + position:relative; + float:left; + display:inline; + margin-right:14px; + padding-right:0.9em; + border-right:1px dotted #e0e0e0; + *border-right:none; + _width:210px; +} + +body.home #special-demo-right { + min-height:51px; + position:relative; + float:left; + display:inline; + margin-top:18px; + /* + padding-right:15px; + */ + *width: 90px; + _display: none; +} + +body.home #inline-playlist { + clear:both; + float:right; + display:inline; + width:256px; + min-height:49px; + margin-top:2em; + padding-bottom:0px; +} + +#demo-box { + position:relative; + float:right; + display:inline; + margin-top:-4px; + background:#fff; + padding-left:3em; + width:256px; + z-index: 1; +} + +hr { + visibility:hidden; + margin:0px; + padding:0px; +} + +.demo-block { + position:relative; + background:#f9f9f9; + border:1px solid #e6e6e6; + padding:4px; + padding-top:0.5em; + margin-top:-0.55em; + border-top:none; +} + +#demo-header { + color:#333; + background:#f9f9f9; + border:1px solid #e6e6e6; + border-bottom:0px; + margin-bottom:0px; + padding:0.5em; +} + +#demos h3 { + padding-bottom:0px; + text-indent:0.5em; + font-weight:normal; +} + +#demos h3 a { + font-weight:normal; +} + +#revision-list > li { + margin-top:3em; + margin-bottom:2em; +} + +#revision-list > li:first-child { + margin-top:2em; +} + +/* seasonal decorations */ + +body.home.has-lights { + /* prevent ugly scrollbars from explosion fragments */ + overflow-x: hidden; +} + +body.home #lights { + position:absolute; + border-top:1px solid #006600; + left:0px; + top:0px; + width:100%; + z-index:4; + display:none; +} + +.xlsf-light { + position:absolute; + margin-top:-1px; +} + +body.fast .xlsf-light { + opacity:0.9; +} + +.xlsf-light { + opacity:0.9; +} + +#explosion-box { + position: absolute; + left: 0px; + top: 0px; + width: 100%; + z-index: 10; +} + +.xlsf-fragment { + position:absolute; + background:transparent url(christmas-lights/image/bulbs-50x50-fragments.png) no-repeat 0px 0px; + width:50px; + height:50px; +} + +.xlsf-fragment-box { + position:absolute; + left:0px; + top:0px; + width:50px; + height:50px; + *width:100%; + *height:100%; + display:none; +} + +.figure { + display:inline; + display:inline-block; + border:1px solid #ddeeff; + padding:0.5em; + margin:0.5em 0px 0.5em 0px; +} + +.figure .code span { + padding:0.25em; + border:1px solid #f0f9ff; + background:#fff; +} + +.figure .code span.mid { + color:#666; +} + +#sm2-container.flash_debug { + /* flash movie, when soundManager.debugFlash = true */ + position:relative; + width:auto; + height:300px; + width:100%; + background:#f6f6f6; + border:1px solid #ccc; +} + +#sm2-container.flash_debug object, +#sm2-container.flash_debug embed { + width:100%; + height:100%; + left:auto; + top:auto; +} + +ul.file-structure ul { + padding-left:1.5em; +} + +ul.file-structure li { + list-style-type:square; + margin-top:0.25em; + margin-left:0px; +} + +ul.file-structure li span { + color:#999; +} + +#sm2-filesizes { + border:1px solid #ddd; + background:#fff; +} + +#sm2-filesizes tr:nth-child(2n+1) { + background:#f9f9f9; +} + +#sm2-filesizes th { + background:#eee; + font-weight:bold; + text-align:left; +} + +#sm2-filesizes th { + padding:4px 6px; +} + +#sm2-filesizes td { + padding:0px 6px; + border:1px solid #eee; +} + +#sm2-filesizes p { + margin-top:0.5em; + margin-bottom:0px; +} + +#sm2-filesizes pre { + border-left:none; + margin-top:0.5em; + margin-bottom:0.5em; +} + +#sm2-filesizes .nw { + white-space:nowrap; +} + +#sm2-filesizes .booyaa { + /* in the words of Paris Hilton, "that's hot." (in the nerdy sense, I suppose.) */ + background:#fff9f9; + color:#990000; +} + +#history li.in > p.compact { + font-weight:bold; +} + +#sm2-options { + /* -html5, -debug etc. */ + position: relative; + clear: both; + color: #666; + margin: 0.33em 0.75em 0px 0.75em; + border-top: 1px dotted #ddd; +} + +#sm2-options .options-divider { + font-size: 85%; + color: #ccc; +} + +#sm2-options p { + font-size: 85%; + padding-left: 0px; + padding-bottom: 0px; + margin-bottom: 0.75em; +} + +#sm2-options p:first-child { + margin-top: 0.75em; +} + +#sm2-options a { + color: #3399cc; + text-decoration: none; + padding: 1px; + margin-top: -2px 0px 0px -2px; +} + +#without-html5 { + display: none; +} + +body.home #about-sm2 #inline-demo-header { + margin-top: 1.5em; + border-bottom: 1px solid #eee; + padding-bottom: 0.5em; +} + +body.home #about-sm2 #inline-demo-header, +body.home #about-sm2 .home-shopping-network { + display: block; +} + +#about-sm2 a img { + border: none; +} + +/* alternate code + comment blocks */ + +ul.code-block { + list-style-type: none; + position: relative; + padding: 3px; + font-size: 85%; +} + +ul.code-block, +ul.code-block li { + position: relative; + margin: 0px; + padding: 0px; + line-height: 1.5em; +} + +ul.code-block li { + padding: 0.75em 0.5em; +} + +ul.code-block li:nth-child(2n+1) { + background-color: #fcfcfc; +} + +ul.code-block li:last-child { + padding-bottom: 0px; +} + +ul.code-block li div { + position: absolute; + left: 0.5em; + top: 0.75em; /* note: match LI padding */ + width: 22em; /* left gutter */ + z-index: 2; /* sit on top */ +} + +ul.code-block li span { + position: relative; + display: block; + padding-left: 22.5em; /* room for left gutter */ + text-indent: -2em; +} + +/* special min-width case */ +#soundmanager-properties ul.code-block { + min-width: 43em; +} + +/** +* November 2011 homepage redesign +*/ + +div.oneup, +div.twoup, +div.threeup { + position: relative; + clear: both; + padding: 2em 1em 2.5em 1em; + *zoom:1; /* god damn shite IE */ +} + +div.oneup, +div.twoup, +div.threeup, +#about-sm2 h2.special, +#about-sm2 p { + text-shadow: 0px 1px 0px #fff; /* eh, why not. */ +} + +div.oneup .column { + position: relative; + width: 100%; +} + +div.twoup .column, +div.threeup .column { + position: relative; + float: left; + display: inline; + width: 33.3%; + _width: 32%; /* IE 6 */ +} + +div.twoup .column { + width: 50%; + _width: 49%; /* IE 6 can die */ +} + +div.oneup .column, +div.twoup .column, +div.threeup .column { + padding-bottom: 0.5em; +} + +div.oneup .column-wrapper, +div.twoup .column-wrapper, +div.threeup .column-wrapper { +/* + border-top: 1px dotted #d0d0d0; +*/ + margin: 0px 2.5em; +} + +div.oneup .column-wrapper.spaced-out, +div.twoup .column-wrapper.spaced-out, +div.threeup .column-wrapper.spaced-out { + /* spacing for columns without an <h3> header */ + padding-top: 6.25em; +} + +div.threeup.first { + padding-top: 0.75em; +} + +div.threeup.first .column-wrapper { + border-top: none; +} + +body.home #main .oneup p, +body.home #main .twoup p, +body.home #main .threeup p { + font-size: 1.1em; + line-height: 1.5em; + margin-bottom: 1.5em; +} + +body.home #main p.sidenote { + /* disclaimer */ + font-size: 92%; + color: #666; +} + +body.home h2 { + margin-top: 0px; +} + +body.home div.c3 { + /* pop discussion/support on top of margin */ + position: relative; + float: right; + display: inline; + margin-left: 30px; /* a little extra spacing, so the <h2> doesn't overlap */ + margin-top: -6px; + z-index: 2; + margin-bottom: 2.5em; +} + +body.home #inline-playlist { + float: none; + display: block; + width: auto; +} + +body.home .sm2-inline-list .ui360-vis { + /* center */ + margin: 0px auto; +} + +body.home ul.playlist { + font-size: 85%; +} + +body.home ul.playlist li { + font-size: 1.75em; + letter-spacing: -0.02em; +} + +body.home ul.playlist .sidenote { + font-size: 85%; +} + +body.home .demo-more, +body.home .demo-more-abs { + font-size: 95%; +} + +body.home ul.graphic { + margin-top: 1em; +} + +body.home ul.graphic { + position: relative; +} + +body.home ul.graphic li { + float: left; + display: inline; + width: 50%; + margin-bottom: 0px; +} + +body.home ul.graphic li a, +body.home ul.graphic li a.sm2_link { + display: block; + width: auto; + min-width: 8em; + margin-right: 0.5em; + margin-bottom: 0.5em; +} + +body.home ul li a:hover, +body.home ul.graphic a.sm2_playing, +body.home #inline-playlist li.sm2_paused a, +body.home #inline-playlist li.sm2_playing a, +body.home ul.playlist li div.timing, +body.home .feature-hot, +body.home #html5-support-li span { + /* take out shadow on most demo links */ + text-shadow: none; +} + +body.home .feature-hot { + /* hack: font size fix */ + font-size: 13px; +} + +body.home ul.graphic li a, +ul.playlist li a { + /* "..." on titles */ + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + /* crap IE */ + *overflow: auto; + *white-space: wrap; +} + +body.home ul.playlist li a, +body.home ul.playlist li a:hover { + line-height: 1.2em; +} + +body.home .demo-more a span, +body.home .demo-more-abs a span { + font-size: 1.5em; + line-height: 1em; +} + +body.home #sm2-visualization { + clear: both; + margin-top: 2em; +} + +body.home #sm2-visualization .ui360 { + float: none; + display: block; +} + +body.home #sm2-visualization .ui360 .sm2-360ui { + border-color: rgba(0,0,0,0.05); + background-color: rgba(255,255,255,0.5); + box-shadow: inset 0px 0px 32px rgba(0,0,0,0.075); +} + +body.home #sm2-visualization .ui360 canvas, +body.home #sm2-visualization .ui360 .sm2-360ui, +body.home #sm2-visualization .ui360 a { + border-radius: 128px; +} + +body.home #sm2-visualization .ui360 a { + /* put title underneath button */ + line-height: 340px; + *line-height: 480px; /* not crap IE, though. */ + line-height: 480px\9; /* nor IE 8. */ + color: #666 !important; /* hax */ + text-shadow: 0px 1px 0px #fff; +} + +:root body.home #sm2-visualization .ui360 a { + /* IE 9 correction */ + line-height: 340px\0/IE9; +} + +body.home #sm2-visualization .ui360 a, +body.home #sm2-visualization .ui360 canvas { + -webkit-transition: all 0.2s ease-in-out; + -moz-transition: all 0.2s ease-in-out; + transition: all 0.2s ease-in-out; + -moz-transition-property: background-color, border, box-shadow; + -webkit-transition-property: background-color, border, box-shadow; + transition-property: background-color, border, box-shadow; +} + +body.home #sm2-visualization .ui360:hover { + background-color: rgba(0,0,0,0); +} + +body.home #sm2-visualization .ui360:hover a { + background-color: rgba(0,0,0,0.01); + border-color: rgba(0,0,0,0.1); + box-shadow: inset 0px 0px 32px rgba(0,0,0,0.05); +} + +body.home #sm2-visualization .ui360 .sm2_playing canvas, +body.home #sm2-visualization .ui360 .sm2_paused canvas { + /* hide song title while playing */ + background-color: #fafafa; + *background-color: transparent; /* not you, crap IE. */ + background-color: transparent\9; /* nor IE 8. */ +} + +body.home #sm2-visualization .ui360 .sm2_playing canvas, +body.home #sm2-visualization .ui360 .sm2_paused canvas { + background-color: #fafafa; + box-shadow: inset 0px 0px 32px rgba(0,0,0,0.066); +} + +body.home #sm2-visualization .ui360:hover .sm2_playing canvas, +body.home #sm2-visualization .ui360:hover .sm2_paused canvas { + background-color: #fafafa; + box-shadow: inset 0px 0px 32px rgba(0,0,0,0.1); +} + +body.home .gsfn_topic_list li { + /* by default, hide (and only show first X items.) */ + display: none; +} + +body.home .gsfn_topic_list .gsfn-item-1, +body.home .gsfn_topic_list .gsfn-item-2, +body.home .gsfn_topic_list .gsfn-item-3 { + /* show these items only. */ + display: block; +} + +div.clearfix { + font-size: 0px; + height: 0px; + overflow: hidden; +} + +div.icons ul { + list-style-type: none; +} + +div.icons ul, +div.icons ul li { + margin: 0px; + padding: 0px; +} + +div.icons ul li, +.icon { + position: relative; + display: inline-block; + vertical-align: middle; + *display: none; /* not you, crap IE. */ + background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAYAAAAAwCAYAAAAYeq1+AAAHLklEQVR42uydT4jcVBzHH6LbLV11wGIVL6OClFbL1P3zEtvDFCsIKqyn0tseFBFKXTwpIu7B017mLBSymwwevBSsiCdjdzOpW5DVg3izXsSbsf5Z3aWd+M1M3jTENpvJTEzS/X7hy0szL+l0d/r95P2SeU9QFEVRFEVRFEVRFEVRFEVRFEVRFEVRFEVRFEVRFEVRFEVRVAFqX5m91+rIMyKFLEf7QFAURVF3jwCAV3ft4849AgAcERRFUXlpenraj7rE77MG27A/pG24VioArOsHTEcum472vtXR/Nv4HLzcducOCIqqqk6fPl2Dbdgfk224Jqg9BwAV/hlti5JoZWN2H8J/E+F/sx/2euBu29W7wZ/R9iHgyC2zI9cERVVVKvzHbFtQuUCgIqCKuxXp01L7ywg2BPtjKOtcR+vDN8LA77Y7OloYreVqPRCYHW2730/+iHZSUEMFzxLs5+wlQSUqr5+9oAiAIS1KINORvyDkEe7yc9OVhwGDLSsI/ltG+MsADt9ZjjyM9mvYx3FfCKr44Im7gNJJpUopsb+zOaJ95ZKWupqhF+EluAXbob0yvXcEYhM24GvxoAz3GXAjVn/fhA0CIHP4XwhLPl0E/0Vs1+E/wqt/WJWC0MfRrqJE9Djay+jThYN9rwgqnTKETqYwqljpJG6bABheYcDHgj29Cw7++pC1dBtuwG9G9hlFAWCkYwvU6rp8AIH+s4Vw7wU6DCD80ysBYTsyAoiUgORfaPv9cdwqoLCycfIeVlBKBAC+/6oBoHg4Fxj+87AXu9Jvwc2YW7GRQdybBMDQtf9HEfh/9gIeRuhHr/r/ux1reyAIjnfmHmYFhQAgAKpVXrwW/XOB4e+H9uDFFMcsKmBE/AZcIwCGLv88CL+F8s7bWWx1YEeeN525/QQAAUAAlAcANrwUej7yXmt3Oqagso8XCf9G2pvAQd8oBNSxBECyrCDwO/I1BPcLpisncCU/ZblyBu1sFltB6+jTpqMH3yKexPnPAihn8HfsJwAIAAIgf2UP8+IBYMfDPxEAyRCwCYA0ANA+UV/qQkifRYhPY3sb5ZybWQ0IeOYV7X6c+yN1bmy/QwAQAAQAASASwtsPvZj1MdDg2Mh5mgRAsqLP92P7M9ORR9DuYJ+fxZYbhL3urX51YgLbv+MeQm8f2nVBEQAEAAFwh+Az1A3fUb8HEJyDTwGlBwDcDW/gfgoAHO0BAPszQ8DRvBVbm8B5foPVDeJcAJDnVT5HAAQAAZC/4qHdGgMAWgomBECyVGgrAKA92nbkjpUt/NV5PNPVJgCTPgBcAoAAIAAIgASlKdvgtZci/V5M6NdU/QiA4QFgAQAjhL8PeHjGBkpAjhYBgEYAEAAEAAEwEgD8qAmA8QNAlYCsEUtApv1caUYAYhcRAAQAAUAAEABqBKBuAmc0gt+7YE/HRwAEAAFAABAAIwHgVKTfKQJgXADQxgaAMPA9c+MkRwAEAAFQYgDEJ4dr8Cbw3gNA/xFNXT0FdAkeCQDh+TzD0SNPAWk4N28CF/JFBgKAALjDh7uZMFdQmR8DbQbmY6Bjewz0V8sdfFlrBe3T4ygBrXwpJ3GenxD86tyXqgAAtEZgAoAAqBIA1JX8ImzAF+OzJMb6LhT1mUlTtkkz/0/KL4I1CIBkmR3t9cE3gR35DK7WJba3RwUA/BDO83L/3DLY93wF8tOIbhMAnA66CgBQge6l+f1ju57Ut+xTQShxKojxadWdO77izh4MRwS6AoDl6t0hw78bziDqmR39UHiP4anVdf0J5icXhOGCMPm87/lhfv/hKMFPYa8Mk8FlCf+wrRMAmWYDPYEA37EGyz9qcHRaaOxXrZr6IVr/x/7eY6Dr8hBnA+WSkGMTAXB7qSmcd3OGz9tShaeDnueSkJknhwtmB/0Bo4C/UbrZAgRuIPzVQvBdbG9hewvbcAABuF9C2u69huNMR9tsX9GnCICc/7Fc0pIAGPbnp97fLjYEVMEFYTx4nmsCj6a2Iw8i0J9FkNfRfm91+iEflneOAQoN7JsZ7OuvDLbcduUxtMexqtgU82fvAMCA/ZxtEAAj/QdoxY5pJSwIMwjQCi4JWS/7ovCp+pRICPerquSDkcHgvZmXZ+4zw/CHgxHAeRETl4TMGwDU2FThkUsry4cX+xvwknKxwZ9c20+xKHxT9ScAxv6Y6FW1/KPpRgCwNhsCAFYAoHK7yeol3ayDa4L6vwCwELpoAMSvgrzYZ8KA64ISRT3NlNF2qQCgRgAhBNT+NgAwePKnQwBQ1QeAnQMAbEHtRQDUMkLAhmslGwF8M1gzAK3a//GaNmHduvoHBOQ5QVF5q0KPs9ocmVFVl+Vo70aWjPw2tp7w9f4KYHjNlWcFRVEUdfcIoT9lOvK86WjvwbXYa08CDB/i9QXAYJ+gKIqiqH/bgwMSAAAAAEH/X7cjUAEAAAAAAAAAAAAAAA4CNogIgRLqd00AAAAASUVORK5CYII=) no-repeat; + width: 32px; + height: 24px; + padding-right: 4px; + text-indent: -999em; + overflow: hidden; + cursor: help; + opacity: 0.75; +} + +div.icons ul li:hover, +.icon:hover { + opacity: 1; +} + +.icon { + display: inline-block; + *display: none; + width: 32px; + height: 30px; + margin-left: 16px; + margin-top: 5px; + opacity: 0.85; + cursor: default; +} + +div.icons ul li.desktop { + background-position: -11px -12px; + height: 24px; +} + +div.icons ul li.laptop { + background-position: -59px -13px; + height: 22px; +} + +div.icons ul li.ipad { + background-position: -109px -10px; + width: 28px; + height: 28px; +} + +div.icons ul li.iphone { + background-position: -256px -9px; + width: 22px; + height: 28px; +} + +div.icons ul li.android { + background-position: -299px -7px; + width: 28px; + height: 32px; +} + +.icon.performance, +div.icons ul li.performance { + background-position: -205px -9px; +} + +.icon.performance { + width: 18px; + height: 28px; + margin-top: -7px; +} + +.icon.music-note, +div.icons ul li.music-note { + background-position: -155px -13px; +} + +.icon.music-note { + width: 19px; + height: 23px; + margin-top: -4px; +} + +.icon.package, +div.icons ul li.package { + background-position: -347px -7px; + height: 28px; +} + +.icon.package { + width: 22px; + margin-top: -8px; +} + +.bonus-demos { + position: relative; + list-style-type: none; +} + +.bonus-demos, +.bonus-demos li { + margin: 0px; + padding: 0px; +} + +.bonus-demos li { + float: left; + display: inline; + width: 24%; + margin-right: 1%; + text-align: center; +} + +.bonus-demos li img { + border-radius: 4px; +} + +#client-requests ul.flat { + /* nested examples as in HTML5 vs. flash download behaviours */ + list-style-type: none; + padding-left: 0.5em; + margin-top: 0.5em; +} + +#client-requests ul.flat li { + margin-bottom: 0px; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index.html new file mode 100755 index 00000000..31133af0 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index.html @@ -0,0 +1,28 @@ + + + +MP3 player demo + + + + + + + + + + + + +
+ +

SoundManager 2 Demos

+ +

+ SoundManager 2 project page +

+ +
+ + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index.js new file mode 100755 index 00000000..e26c92bd --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/index.js @@ -0,0 +1,621 @@ +/* SoundManager 2 - project home utility JS */ + +var IS_CHRISTMAS = (document.domain.match(/schillmania.com/i) && new Date().getMonth() == 11) || window.location.toString().match(/christmas/i); + +function _id(sID) { + return document.getElementById(sID); +} + +getSoundByURL = function(sURL) { + return (typeof self.soundsByURL[sURL] != 'undefined'?self.soundsByURL[sURL]:null); +} + +function init() { + var o = document.getElementById('main'); + var el = o.getElementsByTagName('dt'); + for (var i=el.length; i--;) { + if ((i+1)%2==0) { + utils.addClass(el[i],'alt'); + } + } + var el = o.getElementsByTagName('dl'); + for (var i=el.length; i--;) { + if ((i+1)%2==0) { + utils.addClass(el[i],'alt'); + } + } + var newCSS; + if (IS_CHRISTMAS) { + // overflow-x: hidden hack for homepage during christmas light season (so explosion fragments don't cause horizontal scrollbars.) + var newCSS = document.body.className.split(' '); + newCSS.push('has-lights'); + document.body.className = newCSS.join(' '); + } +} + +function Utils() { + var self = this; + + this.hasClass = function(o,cStr) { + return (typeof(o.className)!='undefined'?new RegExp('(^|\\s)'+cStr+'(\\s|$)').test(o.className):false); + } + + this.addClass = function(o,cStr) { + if (!o || !cStr) return false; // safety net + if (self.hasClass(o,cStr)) return false; + o.className = (o.className?o.className+' ':'')+cStr; + } + + this.removeClass = function(o,cStr) { + if (!o || !cStr) return false; // safety net + if (!self.hasClass(o,cStr)) return false; + o.className = o.className.replace(new RegExp('( '+cStr+')|('+cStr+')','g'),''); + } + + this.toggleClass = function(o,cStr) { + var m = (self.hasClass(o,cStr)?self.removeClass:self.addClass); + m(o,cStr); + } + + this.getElementsByClassName = function(className,tagNames,oParent) { + var doc = (oParent||document); + var matches = []; + var i,j; + var nodes = []; + if (typeof(tagNames)!='undefined' && typeof(tagNames)!='string') { + for (i=tagNames.length; i--;) { + if (!nodes || !nodes[tagNames[i]]) { + nodes[tagNames[i]] = doc.getElementsByTagName(tagNames[i]); + } + } + } else if (tagNames) { + nodes = doc.getElementsByTagName(tagNames); + } else { + nodes = doc.all||doc.getElementsByTagName('*'); + } + if (typeof(tagNames)!='string') { + for (i=tagNames.length; i--;) { + for (j=nodes[tagNames[i]].length; j--;) { + if (self.hasClass(nodes[tagNames[i]][j],className)) { + matches[matches.length] = nodes[tagNames[i]][j]; + } + } + } + } else { + for (i=0; i'+o.innerHTML+''; + _id('search-results').style.display = 'block'; + _id('filter-box').style.display = 'block'; + if (isClear) { + _id('filter-box').style.paddingBottom = '0px'; + _id('filter-box').style.display = 'none'; + } else { + _id('filter-box').style.paddingBottom = '0px'; + if (!navigator.userAgent.match(/msie/i)) { + _id('filter-box').style.paddingBottom = Math.max(0,(document.documentElement.scrollTop || window.scrollY)-utils.getOffY(_id('filter-box'))-parseInt(_id('filter-box').offsetHeight)-20)+'px'; + } + _id('filter-box').style.display = 'block'; + // if ((!document.documentElement.scrollTop && !window.scrollY)) _id('filter-box').style.display = 'none'; + } + if (lastSelected) { + if (lastSelected == o) { + utils.toggleClass(lastSelected,'active'); + } else { + utils.removeClass(lastSelected,'active'); + utils.addClass(o,'active'); + } + } else { + utils.addClass(o,'active'); + } + lastSelected = o; + if (typeof e.preventDefault !== 'undefined') { + e.preventDefault(); + } + // cancel bubble, too? + return false; + } +} + +function getLiveData() { + getDynamicData(); + // reinvigorate.net is a handy (and free!) stats tracking service thingy. you should check it out. + var is_live = (document.domain && document.domain.match(/schillmania.com/i) && typeof re_ != 'undefined'); + loadScript('http://include.reinvigorate.net/re_.js'); + setTimeout(function(){ + if (typeof re_ != 'undefined') re_(is_live?'f6795-v062d0xv4u':'u8v2l-jvr8058c6n'); + },3000); +} + +function getDynamicData() { + // Attempt to fetch data from schillmania.com: "Get Satisfaction" topics, version updates etc. + loadScript('http://www.schillmania.com/services/soundmanager2/info/?version='+soundManager.versionNumber+'&rnd='+parseInt(Math.random()*1048576)); +} + +function loadScript(sURL,onLoad) { + var loadScriptHandler = function() { + var rs = this.readyState; + if (rs == 'loaded' || rs == 'complete') { + this.onreadystatechange = null; + this.onload = null; + window.setTimeout(onLoad,20); + } + } + function scriptOnload() { + this.onreadystatechange = null; + this.onload = null; + window.setTimeout(onLoad,20); + } + var oS = document.createElement('script'); + oS.type = 'text/javascript'; + if (onLoad) { + oS.onreadystatechange = loadScriptHandler; + oS.onload = scriptOnload; + } + oS.src = sURL; + document.getElementsByTagName('head')[0].appendChild(oS); +} + +function doAltShortcuts() { +/* + var o = _id('shortcuts-list'); + if (!o) { + return false; + } + var oParents = []; + var oLIs = o.getElementsByTagName('li'); + var isIgnore = null; + var offset = 0; + for (var i=0; i + usePeakData: true, // [Flash 9 only] whether or not to show peak data (left/right channel values) - nor noticable on CPU + useWaveformData: false,// [Flash 9 only] show raw waveform data - WARNING: LIKELY VERY CPU-HEAVY + useEQData: false, // [Flash 9 only] show EQ (frequency spectrum) data + useFavIcon: false // try to apply peakData to address bar (Firefox + Opera) - performance note: appears to make Firefox 3 do some temporary, heavy disk access/swapping/garbage collection at first(?) - may be too heavy on CPU + } + + threeSixtyPlayer.config = { + + playNext: false, + autoPlay: false, + allowMultiple: true, + loadRingColor: '#ccc', + playRingColor: '#000', + backgroundRingColor: '#eee', + circleDiameter: 256, + circleRadius: 128, + scaleArcWidth: 1, + animDuration: 500, + animTransition: Animator.tx.bouncy, + showHMSTime: true, + + useWaveformData: true, + waveformDataColor: '#0099ff', + waveformDataDownsample: 2, + waveformDataOutside: false, + waveformDataConstrain: false, + waveformDataLineRatio: 0.73, + + useEQData: true, + eqDataColor: '#339933', + eqDataDownsample: 2, + eqDataOutside: true, + eqDataLineRatio: 0.69, + + usePeakData: true, + peakDataColor: '#ff33ff', + peakDataOutside: true, + peakDataLineRatio: 0.5, + + useAmplifier: true + + } + + if (navigator.platform.match(/win32/i) && navigator.userAgent.match(/firefox/i)) { + // extra-special homepage case (you should never see this), prevent out-of-view SWF load failure WITH high performance AND flashblock AND SWF in a placed element + soundManager.useHighPerformance = false; + } + + function checkBadSafari() { + var _ua = navigator.userAgent; + if (!document.location.href.match(/sm2-usehtml5audio/i) && !window.location.toString().match(/sm2\-ignorebadua/i) && _ua.match(/safari/i) && !_ua.match(/chrome/i) && _ua.match(/OS X 10_6_([3-7])/i)) { // Safari 4 and 5 occasionally fail to load/play HTML5 audio on Snow Leopard due to bug(s) in QuickTime X and/or other underlying frameworks. :/ Known Apple "radar" bug. https://bugs.webkit.org/show_bug.cgi?id=32159 + var complaint = document.createElement('li'); + complaint.innerHTML = 'Note: Partial HTML5 in effect. Using Flash for MP3/MP4 formats (if available) for this browser/OS due to HTML5 audio load/play failures in Safari 4 + 5 on Snow Leopard 10.6.3 - 10.6.7 (purportedly fixed in OS X 10.6.8 and 10.7 "Lion.") Issue caused by bugs in QuickTime X and/or underlying frameworks. See bugs.webkit.org #32519. (Safari on iOS, Leopard and Windows OK, however.)

Try HTML5 anyway? (some MP3 playback may intermittently fail.)'; + _id('html5-audio-notes').appendChild(complaint); + } + } + + soundManager.onready(function() { + + _id('sm2-support').style.display = 'none'; + _id('sm2-support-warning').style.display = 'none'; + + if (soundManager.didFlashBlock) { + soundManager.createSound({ + id: 'success', + url: 'demo/_mp3/mouseover.mp3' + }).play(); + } + + doChristmasLights(); + + // hat tip: Flash Detect library (BSD, (C) 2007) by Carl "DocYes" S. Yestrau - http://featureblend.com/javascript-flash-detection-library.html / http://featureblend.com/license.txt + + var _hasFlash; + var hasPlugin = false, n = navigator, nP = n.plugins, obj, type, types, AX = window.ActiveXObject; + + if (nP && nP.length) { + + type = 'application/x-shockwave-flash'; + types = n.mimeTypes; + + if (types && types[type] && types[type].enabledPlugin && types[type].enabledPlugin.description) { + hasPlugin = true; + } + + } else if (typeof AX !== 'undefined') { + + try { + obj = new AX('ShockwaveFlash.ShockwaveFlash'); + } catch(e) { + // oh well + } + hasPlugin = (!!obj); + + } + + _hasFlash = hasPlugin; + + // if using HTML5, show some additional format support info + // written while watching The Big Lebowski for the Nth time. Donny, you're out of your element! + var s = soundManager; + + if (s.useHTML5Audio && s.hasHTML5) { + var liID = 'html5-support-li'; + var oldLI = document.getElementById(liID); + if (oldLI) { + oldLI.parentNode.removeChild(oldLI); + } + // what lies. not an

  • at all. ;) + var li = document.createElement('div'); + li.id = liID; + li.className = 'html5support'; + var items = []; + var needsFlash = false; + for (item in s.audioFormats) { + if (s.audioFormats.hasOwnProperty(item)) { + needsFlash = (soundManager.filePattern.test('.' + item)); + items.push('' + (s.html5[item] ? '<' : '') + item + (s.html5[item] ? '>' : '') + ''); + } + } + + li.innerHTML = [ + 'This browser\'s <HTML5> vs. Flash support:

    ', + items.join(''), + '
    ', + '', + (soundManager.html5.mp3 || soundManager.html5.mp4 ? (_hasFlash && soundManager.preferFlash ? 'Preferring flash for MP3/MP4; try preferFlash=false for HTML5-only mode.' : (soundManager.html5Only ? 'HTML5-only mode.' + (!soundManager.canPlayMIME('audio/aac') ? ' Try preferFlash=true for MP4 support as needed.' : '') : '  Some flash required; allowing HTML5 to play MP3/MP4, as supported.' + '

    ')) : 'Flash is required for this browser to play MP3/MP4.'), + '' + ].join(''); + _id('html5-audio-notes').appendChild(li); + _id('without-html5').style.display = 'inline'; + + } else { + + _id('without-html5').style.display = 'none'; + + } + + checkBadSafari(); + + // check inline player / HTML 5 bits + var items = utils.getElementsByClassName('button-exclude', 'a', _id('inline-playlist')).concat(utils.getElementsByClassName('exclude', 'a', _id('graphic-playlist'))); + for (var i = 0, j = items.length; i < j; i++) { + if (!soundManager.canPlayLink(items[i])) { + items[i].className += ' not-supported'; + items[i].title += '. \n\nNOTE: '+(soundManager.useHTML5Audio?'Format apparently not supported under this configuration or browser.':'SoundManager 2\'s HTML5 feature is not currently enabled. (Try turning it on, see +html5 link.)'); + } + } + + }); + + soundManager.ontimeout(function() { + + // failed to load + + if (navigator.userAgent.match(/msie 6/i)) { + // we don't care. + return false; + } + + var o = _id('sm2-support'); + var o2 = _id('sm2-support-warning'); + var smLoadFailWarning = '

    Oh snap!

    ' + (soundManager.hasHTML5 ? 'The flash portion of ' : '') + 'SoundManager 2 was unable to start. ' + (soundManager.useHTML5Audio ? (soundManager.hasHTML5 ? '

    Some HTML5 audio support is present, but flash is needed for MP3/MP4 support on this page.' : '

    No HTML5 support was found, so flash is required.') : '' ) + '

    All links to audio will degrade gracefully.

    If you have a flash blocker, try allowing the SWF to run - it may be visible below.

    ' + (soundManager.useAltURL ? 'Viewing offline? You may need to change a Flash security setting.' : 'Other possible causes: Missing .SWF, or no Flash?') + ' Not to worry, as guided help is provided.

    Troubleshooting

    '; + var hatesFlash = (navigator.userAgent.match(/(ipad|iphone|ipod)/i)); + + if (soundManager.html5.mp3 && soundManager.html5.mp4) { + // flash portion was blocked, but support exists. We'll "downgrade" to HTML5-only. + soundManager._wD('Special homepage case: Flash appears to blocked, HTML5 support for MP3/MP4 exists; trying HTML5-only mode...'); + soundManager.useHTML5Audio = true; + soundManager.preferFlash = false; + setTimeout(function() { + soundManager.reboot(); + soundManager.onready(function() { + // for when things start up in HTML5-only mode... + o.innerHTML = '

    Support note

    SoundManager 2 tried to start using HTML5 + Flash, but rebooted in HTML5-only mode as flash was blocked. Visualization demo features will not be shown in this mode. To enable flash, whitelist the blocked movie and reload this page.

    '+(soundManager.useAltURL?'

    Running offline? Flash may be blocked due to security restrictions; see troubleshooting for more.':'')+'

    '; + o.style.marginBottom = '1.5em'; + o.style.display = 'block'; + }); + }, 1); + return false; + } + + o.innerHTML = smLoadFailWarning; + o2.innerHTML = '

    SoundManager 2 could not start. See below for details.

    '; + if (hatesFlash || soundManager.getMoviePercent()) { + // movie loaded at least somewhat, so don't show flashblock things + _id('flashblocker').style.display = 'none'; + if (hatesFlash) { + // none of that here. + _id('flash-offline').style.display = 'none'; + } + } + o.style.marginBottom = '1.5em'; + o.style.display = 'block'; + o2.style.display = 'inline-block'; + }); + +} + +// side note: If it's not december but you want to smash things, try #christmas=1 in the homepage URL. + +// --------- /home JS ------------ + +function startStuff() { + if (navigator.userAgent.match(/safari/i)) { + document.getElementsByTagName('html')[0].className = 'isSafari'; + } + doVersion(); + ie6Sucks(); + fixLinks(); + getLiveData(); + doAltShortcuts(); +} + +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", startStuff, false); +} else { + window.onload = startStuff; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/basic.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/basic.html new file mode 100755 index 00000000..f2510a5b --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/basic.html @@ -0,0 +1,56 @@ + + + +SoundManager 2 Demo: Basic MP3 Play Button (Simple Demo) + + + + + + + + + + + +

    SoundManager 2 / Basic MP3 Play Button: Template

    + +

    View the source code of this page for detail. Don't forget to set debugMode: false to disable debug output.

    + +

    Walking Walking

    + +

    Armstrong Beat Armstrong Beat

    + +

    SoundManager 2 project home

    + + + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/css/mp3-player-button.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/css/mp3-player-button.css new file mode 100755 index 00000000..495b0614 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/css/mp3-player-button.css @@ -0,0 +1,117 @@ +/* + + SoundManager 2: Basic MP3 player CSS + ------------------------------------ + + Clicks on links to MP3s are intercepted via JS, calls are + made to SoundManager to load/play sounds. CSS classes are + appended to the link, which are used to highlight the + current play state and so on. + + Class names are applied in addition to "sm2_button" base. + + Default: + + sm2_button + + Additional states: + + sm2_playing + sm2_paused + + eg. + + + some.mp3 + + + some.mp3 + + + Note you don't require ul.graphic / ul.flat etc. for your use + if only using one style on a page. You can just use .sm2_button{} + and so on, but isolate the CSS you want. + + Side note: Would do multiple class definitions eg. + + a.sm2_default.sm2_playing{} + + .. except IE 6 has a parsing bug which may break behaviour, + applying sm2_playing {} even when the class is set to sm2_default. + + + If you want to make your own UI from scratch, here is the base: + + Default + hover state, "click to play": + + a.sm2_button {} + a.sm2_button:hover {} + + Playing + hover state, "click to pause": + + a.sm2_playing {} + a.sm2_playing:hover {} + + Paused + hover state, "click to resume": + + a.sm2_paused {} + a.sm2_paused:hover {} + +*/ + +a.sm2_button { + position:relative; + display:inline-block; /* If you worry about old browser bugs, Firefox 2 might not like this and may need -moz-inline-box instead. :D */ + width:18px; + height:18px; + text-indent:-9999px; /* don't show link text */ + overflow:hidden; /* don't draw inner link text */ + vertical-align:middle; + /* and, a bit of round-ness for the cool browsers. */ + border-radius:6px; + margin-top:-1px; /* vertical align tweak */ + /* safari 3.1+ fun (/W3 working draft extension, TBD.) */ + -webkit-transition-property: hover; + -webkit-transition: all 0.2s ease-in-out; + -moz-transition: all 0.2s ease-in-out 0s; /* firefox 4 (couldn't sort out -moz-transform vs. MozTransform, so, "all" for now) */ + -o-transition-property: background-color; /* opera 10.5 */ + -o-transition-duration: 0.15s; + /* weird IE 6/7 display fixes, and/or I'm doing it wrong */ + *text-indent:0px; + *line-height:99em; + *vertical-align: top; +} + +a.sm2_button:focus { + outline:none; /* maybe evil, but don't show the slight border outline on focus. */ +} + +a.sm2_button, +a.sm2_button.sm2_paused:hover { + background-color:#3399cc; + background-image:url(../image/arrow-right-white.png); + /* where possible, use data: and skip the HTTP request. Fancy-pants. Would use short-hand background: for above, but IE 8 doesn't override background-image. */ + background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAKCAYAAABmBXS+AAAAbklEQVQY02NgQAL//v1jZMAF/v//vwuIs9HEUBUBTbj4HwIeA3EGVsVAxtn/qOAVUGM8uknIiv4hsV8A5ZKxKfoLVvnvHwifAzLtMKwDSQLBVSBti27dJajkcSD2RJODO3wtkOOMz/tMSJJYAxMA5dmsL0IfubQAAAAASUVORK5CYII=); + *background-image:url(../image/arrow-right-white.gif); /* IE 6+7 don't do DATA: URIs */ + background-repeat:no-repeat; + background-position:5px 50%; + *background-position:5px 4px; /* IE 6 again */ +} + +a.sm2_button:hover, +a.sm2_button.sm2_playing, +a.sm2_button.sm2_playing:hover { + background-color:#cc3333; +} + +a.sm2_button.sm2_playing, +a.sm2_button.sm2_playing:hover { + -moz-transform:rotate(90deg); + -webkit-transform:rotate(90deg); + -ms-transform:rotate(90deg); +} + +a.sm2_button.sm2_paused, +a.sm2_button.sm2_paused:hover { + background-color:#666; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/image/arrow-right-black.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/image/arrow-right-black.gif new file mode 100755 index 00000000..6205273c Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/image/arrow-right-black.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/image/arrow-right-black.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/image/arrow-right-black.png new file mode 100755 index 00000000..08f73e4b Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/image/arrow-right-black.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/image/arrow-right-white.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/image/arrow-right-white.gif new file mode 100755 index 00000000..d9ccd365 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/image/arrow-right-white.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/image/arrow-right-white.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/image/arrow-right-white.png new file mode 100755 index 00000000..8c592228 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/image/arrow-right-white.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/index.html new file mode 100755 index 00000000..5c737141 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/index.html @@ -0,0 +1,195 @@ + + + +SoundManager 2 Demo: Basic MP3 Play Button + + + + + + + + + + + + + +
    + +

    SoundManager 2 / Inline MP3 Player Button

    + +

    Basic MP3 Play Button Examples

    (also see basic demo.) + +
    + +
    + +
    + +

    Inline text, with "play" button

    + +

    Example code (link with a sm2_button CSS class):

    +
    <p> <a href="/path/to/coins.mp3" title="Play &quot;coins&quot;" class="sm2_button">coins.mp3</a> Spare change</p>
    +

    Renders as:

    +
    +

    coins.mp3 Spare change

    +

    Note that the text inside the link is hidden and replaced with an image, but should be descriptive - or at least should say something generic, like "play".

    +
    +

    Basic MP3 play button, no text

    + +

    Code:

    + +
    <a href="../_mp3/office_lobby.mp3" title="Play &quot;Office Lobby&quot;" class="sm2_button">Office Lobby</a>
    + +

    Renders as:

    +

    + Office Lobby +

    +

    How It Works

    + +

    SoundManager 2 intercepts clicks to MP3 links and plays them inline. The script assigns additional CSS classes to the links to indicate their state (playing/paused, etc.)

    + +

    Static Examples

    + +

    CSS classes are dynamically applied as follows:

    + + + +

    Basic CSS

    + +

    If you want to make your own UI from scratch, here is the base:

    + +
    + Default + hover state, "click to play":
    +
    + a.sm2_button {}
    + a.sm2_button:hover {}
    +
    + Playing + hover state, "click to pause":
    +
    + a.sm2_button.sm2_playing {}
    + a.sm2_button.sm2_playing:hover {}
    +
    + Paused + hover state, "click to resume":
    +
    + a.sm2_button.sm2_paused {}
    + a.sm2_button.sm2_paused:hover {}
    +
    + +

    Other Options

    + +

    By default, one sound will be played at a time; you can easily change a "config" object value to turn on playlist-like behaviour (i.e., play the next MP3 when the current one finishes.)

    + +
    +
    +// (within mp3-player-button.js)
    +this.config = {
    + playNext: false // stop after one sound, or play through list until end
    +}
    +
    + +

    I'd like to use this.

    +

    See this basic demo for reference.

    + +

    + SoundManager 2 project page (not an MP3 link) +

    + +
    + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/script/mp3-player-button.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/script/mp3-player-button.js new file mode 100755 index 00000000..dc79ee52 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mp3-player-button/script/mp3-player-button.js @@ -0,0 +1,260 @@ +/** + * SoundManager 2 Demo: Play MP3 links via button + * ---------------------------------------------- + * + * http://schillmania.com/projects/soundmanager2/ + * + * A simple demo making MP3s playable "inline" + * and easily styled/customizable via CSS. + * + * A variation of the "play mp3 links" demo. + * + * Requires SoundManager 2 Javascript API. + */ + +/*jslint white: false, onevar: true, undef: true, nomen: false, eqeqeq: true, plusplus: false, bitwise: true, regexp: false, newcap: true, immed: true */ +/*global document, window, soundManager, navigator */ + +function BasicMP3Player() { + var self = this, + pl = this, + sm = soundManager, // soundManager instance + isTouchDevice = (navigator.userAgent.match(/ipad|iphone/i)), + isIE = (navigator.userAgent.match(/msie/i)); + this.excludeClass = 'button-exclude'; // CSS class for ignoring MP3 links + this.links = []; + this.sounds = []; + this.soundsByURL = {}; + this.indexByURL = {}; + this.lastSound = null; + this.soundCount = 0; + + this.config = { + // configuration options + playNext: false, // stop after one sound, or play through list until end + autoPlay: false // start playing the first sound right away + }; + + this.css = { + // CSS class names appended to link during various states + sDefault: 'sm2_button', // default state + sLoading: 'sm2_loading', + sPlaying: 'sm2_playing', + sPaused: 'sm2_paused' + }; + + // event + DOM utils + + this.includeClass = this.css.sDefault; + + this.addEventHandler = (typeof window.addEventListener !== 'undefined' ? function(o, evtName, evtHandler) { + return o.addEventListener(evtName,evtHandler,false); + } : function(o, evtName, evtHandler) { + o.attachEvent('on'+evtName,evtHandler); + }); + + this.removeEventHandler = (typeof window.removeEventListener !== 'undefined' ? function(o, evtName, evtHandler) { + return o.removeEventListener(evtName,evtHandler,false); + } : function(o, evtName, evtHandler) { + return o.detachEvent('on'+evtName,evtHandler); + }); + + this.classContains = function(o,cStr) { + return (typeof(o.className)!=='undefined'?o.className.match(new RegExp('(\\s|^)'+cStr+'(\\s|$)')):false); + }; + + this.addClass = function(o,cStr) { + if (!o || !cStr || self.classContains(o,cStr)) { + return false; + } + o.className = (o.className?o.className+' ':'')+cStr; + }; + + this.removeClass = function(o,cStr) { + if (!o || !cStr || !self.classContains(o,cStr)) { + return false; + } + o.className = o.className.replace(new RegExp('( '+cStr+')|('+cStr+')','g'),''); + }; + + this.getSoundByURL = function(sURL) { + return (typeof self.soundsByURL[sURL] !== 'undefined' ? self.soundsByURL[sURL] : null); + }; + + this.isChildOfNode = function(o,sNodeName) { + if (!o || !o.parentNode) { + return false; + } + sNodeName = sNodeName.toLowerCase(); + do { + o = o.parentNode; + } while (o && o.parentNode && o.nodeName.toLowerCase() !== sNodeName); + return (o.nodeName.toLowerCase() === sNodeName ? o : null); + }; + + this.events = { + + // handlers for sound events as they're started/stopped/played + + play: function() { + pl.removeClass(this._data.oLink,this._data.className); + this._data.className = pl.css.sPlaying; + pl.addClass(this._data.oLink,this._data.className); + }, + + stop: function() { + pl.removeClass(this._data.oLink,this._data.className); + this._data.className = ''; + }, + + pause: function() { + pl.removeClass(this._data.oLink,this._data.className); + this._data.className = pl.css.sPaused; + pl.addClass(this._data.oLink,this._data.className); + }, + + resume: function() { + pl.removeClass(this._data.oLink,this._data.className); + this._data.className = pl.css.sPlaying; + pl.addClass(this._data.oLink,this._data.className); + }, + + finish: function() { + pl.removeClass(this._data.oLink,this._data.className); + this._data.className = ''; + if (pl.config.playNext) { + var nextLink = (pl.indexByURL[this._data.oLink.href]+1); + if (nextLink1) { + // ignore right-click + return true; + } + var o = self.getTheDamnLink(e), + sURL, + soundURL, + thisSound; + if (o.nodeName.toLowerCase() !== 'a') { + o = self.isChildOfNode(o,'a'); + if (!o) { + return true; + } + } + sURL = o.getAttribute('href'); + if (!o.href || !soundManager.canPlayLink(o) || self.classContains(o,self.excludeClass)) { + return true; // pass-thru for non-MP3/non-links + } + if (!self.classContains(o,self.includeClass)) { + return true; + } + sm._writeDebug('handleClick()'); + soundURL = (o.href); + thisSound = self.getSoundByURL(soundURL); + if (thisSound) { + // already exists + if (thisSound === self.lastSound) { + // and was playing (or paused) + thisSound.togglePause(); + } else { + // different sound + thisSound.togglePause(); // start playing current + sm._writeDebug('sound different than last sound: '+self.lastSound.id); + if (self.lastSound) { + self.stopSound(self.lastSound); + } + } + } else { + // create sound + thisSound = sm.createSound({ + id:'basicMP3Sound'+(self.soundCount++), + url:soundURL, + onplay:self.events.play, + onstop:self.events.stop, + onpause:self.events.pause, + onresume:self.events.resume, + onfinish:self.events.finish, + type:(o.type||null) + }); + // tack on some custom data + thisSound._data = { + oLink: o, // DOM node for reference within SM2 object event handlers + className: self.css.sPlaying + }; + self.soundsByURL[soundURL] = thisSound; + self.sounds.push(thisSound); + if (self.lastSound) { + // stop last sound + self.stopSound(self.lastSound); + } + thisSound.play(); + } + self.lastSound = thisSound; // reference for next call + return self.stopEvent(e); + }; + + this.stopSound = function(oSound) { + soundManager.stop(oSound.id); + if (!isTouchDevice) { // iOS 4.2+ security blocks onfinish() -> playNext() if we set a .src in-between(?) + soundManager.unload(oSound.id); + } + }; + + this.init = function() { + sm._writeDebug('basicMP3Player.init()'); + var i, j, + foundItems = 0, + oLinks = document.getElementsByTagName('a'); + // grab all links, look for .mp3 + for (i=0, j=oLinks.length; i0) { + self.addEventHandler(document,'click',self.handleClick); + if (self.config.autoPlay) { + self.handleClick({target:self.links[0],preventDefault:function(){}}); + } + } + sm._writeDebug('basicMP3Player.init(): Found '+foundItems+' relevant items.'); + }; + + this.init(); + +} + +var basicMP3Player = null; + +soundManager.setup({ + preferFlash: false, + onready: function() { + basicMP3Player = new BasicMP3Player(); + } +}); \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/acoustic-drumkit.xml b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/acoustic-drumkit.xml new file mode 100755 index 00000000..3d6606ae --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/acoustic-drumkit.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_BD_1.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_BD_1.mp3 new file mode 100755 index 00000000..ac40028e Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_BD_1.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_FTM2.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_FTM2.mp3 new file mode 100755 index 00000000..a181e07a Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_FTM2.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_HHCL.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_HHCL.mp3 new file mode 100755 index 00000000..58331340 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_HHCL.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_HHOP.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_HHOP.mp3 new file mode 100755 index 00000000..679376c8 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_HHOP.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_HHPD.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_HHPD.mp3 new file mode 100755 index 00000000..79bf78c2 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_HHPD.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_HTM.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_HTM.mp3 new file mode 100755 index 00000000..990d8f1e Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_HTM.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_LTM2.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_LTM2.mp3 new file mode 100755 index 00000000..d9c371c1 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_LTM2.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_MTM.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_MTM.mp3 new file mode 100755 index 00000000..cadd93e6 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_MTM.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_RIM1.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_RIM1.mp3 new file mode 100755 index 00000000..354c35ab Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_RIM1.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_SN13.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_SN13.mp3 new file mode 100755 index 00000000..319348cd Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_SN13.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_SN_5.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_SN_5.mp3 new file mode 100755 index 00000000..baf7a879 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/AMB_SN_5.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/CHINA_1.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/CHINA_1.mp3 new file mode 100755 index 00000000..18a51426 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/CHINA_1.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/CRASH_1.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/CRASH_1.mp3 new file mode 100755 index 00000000..db773015 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/CRASH_1.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/CRASH_5.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/CRASH_5.mp3 new file mode 100755 index 00000000..4d999f26 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/CRASH_5.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/CRASH_6.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/CRASH_6.mp3 new file mode 100755 index 00000000..d20ec278 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/CRASH_6.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/RIDE_1.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/RIDE_1.mp3 new file mode 100755 index 00000000..1e5601c6 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/RIDE_1.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/RIDE_3.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/RIDE_3.mp3 new file mode 100755 index 00000000..701e150c Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/RIDE_3.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/SPLASH_1.mp3 b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/SPLASH_1.mp3 new file mode 100755 index 00000000..77cb0de5 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/audio/SPLASH_1.mp3 differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/css/mpc.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/css/mpc.css new file mode 100755 index 00000000..cddf9f0d --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/css/mpc.css @@ -0,0 +1,158 @@ +/* Demo/example CSS - not needed for general use */ + +body { + background:#000; + font:normal 75% "helvetica neue",helvetica,verdana,arial,tahoma,"times new roman","sans serif"; + color:#fff; + margin:0px; + padding:0px; +} + +#background { + position:absolute; + left:0px; + top:0px; + width:100%; + height:100%; + background:transparent url(http://farm1.static.flickr.com/45/191496680_97cdc5351b_b.jpg) no-repeat 50% 50%; +} + +#site { + position:relative; + z-index:2; + background:rgba(0,0,0,0.5); + padding:1em; +} + +#site h1 { + margin-top:0px; +} + +#site p { + margin:0.5em 0px 0.5em 0px; +} + +#site p:last-child { + margin:0px; +} + +.clear { + float:none; + clear:both; + font-size:1px; + line-height:1px; + height:1px; + overflow:hidden; +} + +#mpc { + position:absolute; + left:50%; + top:50%; + margin-left:-19em; + margin-top:-19em; + width:38em; + _width:37.3em; + border:3px solid #666; + border:3px solid rgba(255,255,255,0.25); + border-radius:12px; + z-index:2; +} + +#mpc #wrapper { + position:relative; + background:#333; + background:rgba(0,0,0,0.5); + padding:0.5em; + border-radius:12px; +} + +#mpc ul { + margin:0px; + padding:0px; + margin-left:2px; + *margin-left:1em; + _margin-left:2px; + padding:2px 0px 2px 0px; +} + +#mpc ul li { + position:relative; + float:left; + display:inline; + width:7em; + height:7em; + margin:0.5em; + background:#999; + border:1px solid rgba(0,0,0,0.75); + border-radius:2px; + font:normal 1em/1em "helvetica",verdana,arial,system; + padding:0.5em; + cursor:pointer; + cursor:hand; + color:#eee; + text-transform:uppercase; + font-weight:bold; +} + +#mpc ul li span { + text-transform:none; + font-weight:normal; + color:#ccc; +} + +#mpc ul li.active { + background:#666; +} + +#mpc ul li div { + /* progress indicator */ + position:absolute; + left:0px; + bottom:1em; + font-size:1em; + line-height:1em; + height:1em; + margin:0px 0px 0px 1em; + width:6em; + background:#888 url(../image/progress.png) no-repeat -256px 0px; + background-repeat:no-repeat; + border:1px solid #666; + visibility:hidden; +} + +#mpc ul li.active div, +#mpc ul li.loading div { + visibility:visible; +} + +#soundmanager-debug { + position:absolute; + right:20px; + bottom:20px; + height:12em; + width:50em; + overflow:auto; + margin-left:1em; +} + +#soundmanager-debug div { + font-size:11px; + font-family: "lucida console",system,verdana,arial; /* IE doesn't seem to obey short-hand font family here? */ + padding:0px 1em 0.5em 0px; +} + +#mpc-debug, +.note { + color:#999; +} + +#mpc-debug a, +.note a { + color:#6699cc; + text-decoration:none; +} + +#isHTML5 { + display:none; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/image/progress.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/image/progress.png new file mode 100755 index 00000000..cfd26fbe Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/image/progress.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/index.html new file mode 100755 index 00000000..7dc68f7f --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/index.html @@ -0,0 +1,72 @@ + + + +SoundManager 2: A Javascript Sound API - MPC Demo + + + + + + + + + + + + +
    + +
    + +

    SoundManager 2: Javascript Drum Machine Demo

    +

    Trigger the pads to play different sounds.

    +

    View with debug output

    +

    Photo: MPC 2500 by .schill on Flickr

    +

    (If supported): Your browser is cool and is using 100% HTML5 Audio. Look ma, no Flash!

    +
    + +
    + +
    + +
      +
    • 1
    • +
    • 2
    • +
    • 3
    • +
    • 4
    • +
    + +
      +
    • q
    • +
    • w
    • +
    • e
    • +
    • r
    • +
    + +
      +
    • a
    • +
    • s
    • +
    • d
    • +
    • f
    • +
    + +
      +
    • z
    • +
    • x
    • +
    • c
    • +
    • v
    • +
    + +
    + +
    + +
    + + + + + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/script/mpc.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/script/mpc.js new file mode 100755 index 00000000..c53912c0 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/mpc/script/mpc.js @@ -0,0 +1,134 @@ +/** + * SoundManager 2: MPC (Drum Machine) demo + */ + +var MPC = function() { + var self = this; + this.idPrefix = 'btn-'; // HTML ID prefix + this.statusWidth = 6; + this.progressWidth = 256; + this.keys = {'1':0,'2':1,'3':2,'4':3,'q':4,'w':5,'e':6,'r':7,'a':8,'s':9,'d':10,'f':11,'z':12,'x':13,'c':14,'v':15} + + // scope within these event handler methods: "this" = SMSound() object instance (see SMSound() in soundmanager.js for reference) + + this.showProgress = function() { + // sound is loading, update bytes received using this.bytesLoaded / this.bytesTotal + if (self._getButton(this.id).className != 'loading') self._getButton(this.id).className = 'loading'; // a bit inefficient here.. + self._showStatus(this.id,this.bytesLoaded,this.bytesTotal); + } + + this.onload = function() { + var sID = this.id; + self._getButton(this.id).className = ''; + self._getButton(this.id).title = ('Sound ID: '+this.id+' ('+this.url+')'); + } + + this.onfinish = function() { + self._getButton(this.id).className = ''; + self._reset(this.id); + } + + this.onplay = function() { + self._getButton(this.id).className = 'active'; + } + + this.whileplaying = function() { + self._showStatus(this.id,this.position,this.duration); + } + + this._keyHandler = function(e) { + var oEvt = e?e:event; + var sChar = String.fromCharCode(oEvt.keyCode).toLowerCase(); + if (typeof self.keys[sChar] != 'undefined') soundManager.play('s'+self.keys[sChar]); + } + + this._showStatus = function(sID,n1,n2) { + var o = self._getButton(sID).getElementsByTagName('div')[0]; + var offX = (n2>0?(-self.progressWidth+parseInt((n1/n2)*o.offsetWidth)):-self.progressWidth); + o.style.backgroundPosition = offX+'px 0px'; + } + + this._getButton = function(sID) { + return document.getElementById(self.idPrefix+sID); + } + + this._reset = function(sID) { + var id = sID; + self._showStatus(sID,1,1); + setTimeout(function(){self._showStatus(sID,0,0);},200); + } + + this.init = function() { + document.onkeydown = self._keyHandler; + } + +} + +var mpc = new MPC(); + +soundManager.flashVersion = (window.location.toString().match(/#flash8/i)?8:9); +if (soundManager.flashVersion != 8) { + soundManager.useHighPerformance = true; +} + +soundManager.setup({ + url: '../../swf/', // path to load SWF from (overriding default) + bgColor: '#333333', + wmode: 'transparent', + debugMode: false, + preferFlash: false, + html5PollingInterval: 50, + onready: function() { + + soundManager.setup({ + defaultOptions: { + autoLoad: true, + multiShot: true, + whileloading: mpc.showProgress, + onid3: mpc.onid3, + onload: mpc.onload, + onplay: mpc.onplay, + whileplaying: mpc.whileplaying, + onfinish: mpc.onfinish + } + }); + + // This is the "onload" equivalent which is called when SoundManager has been initialised (sounds can be created, etc.) + mpc.init(); + + if (!soundManager.html5.needsFlash) { + document.getElementById('isHTML5').style.display = 'inline'; + } + + var soundURLs = 'AMB_BD_1,AMB_FTM2,AMB_HHCL,AMB_HHOP,AMB_HHPD,AMB_HTM,AMB_LTM2,AMB_MTM,AMB_RIM1,AMB_SN13,AMB_SN_5,CHINA_1,CRASH_1,CRASH_5,CRASH_6,RIDE_1'.split(','); + for (var i=0; i + + +SoundManager 2 Demo: Play MP3 links on a page, "page as playlist" style + + + + + + + + + + + + +
    + +

    SoundManager 2 / page as a playlist, basic template (flash 8)

    + +
    + +
    + + + +

    For alternate themes, add the class to the playlist UL - eg. <ul class="playlist dark"> or <ul class="playlist bubblegum">; the base default is <ul class="playlist">.

    + +

    A reminder that if loading from the local filesystem, Flash will deny access to remote (network/internet) URLs by default unless whitelisted via the Flash Player Global Security Settings Page. Some URLs in this example are remote to demonstrate this.

    + +

    Note that by default, the Flash 8 version is used and therefore Flash 9-only features such as the VU meter, waveform etc. are not available. Refer to the main "page player" demo for configuration examples, or view the source of page-player.js for the configuration object (similar to that used in SoundManager 2 itself.)

    + +

    SoundManager 2 project

    + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/css/demo.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/css/demo.css new file mode 100755 index 00000000..89776425 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/css/demo.css @@ -0,0 +1,124 @@ +/* + ----------------------------------------------------------------- + In-page demo CSS for code, documentation etc. + See page-player.css for actual playlist-relevant stuff. + ----------------------------------------------------------------- + */ + +#soundmanager-debug { + /* SM2 debug container (optional, makes debug more useable) */ + position:absolute;position:fixed;*position:absolute;bottom:10px;right:10px;width:50em;height:18em;overflow:auto;background:#fff;margin:1em;padding:1em;border:1px solid #999;font-family:"lucida console",verdana,tahoma,"sans serif";font-size:x-small;line-height:1.5em;opacity:0.9;filter:alpha(opacity=90);z-index:99; +} + +body { + font:75% normal verdana,arial,tahoma,"sans serif"; +} + +h1, h2, h3 { + font:300 3em "Helvetica Neue",georgia,"times new roman","Arial Rounded MT Bold",helvetica,verdana,tahoma,arial,"sans serif"; + margin-bottom:0px; +} + +h1, h2 { + letter-spacing:-1px; /* zomg web x.0! ;) */ +} + +h1, h2, h3 { + float:left; + clear:both; + border-bottom:1px solid #999; + padding-bottom:1px; + margin-bottom:0.25em; +} + +h1 { + margin-top:0px; + margin-bottom:0px; + background-color:#666; + color:#ccc; + margin-left:-5px; + padding-left:5px; + padding-right:5px; +} + +h1, +h1 a { + color:#fff; + text-decoration:none; +} + +h1 a:hover { + text-decoration:underline; +} + +h2 { + font-size:2em; + margin-top:1em; + background-color:#aaa; + color:#fff; + padding:5px; + margin-left:-5px; + min-width:23em; +} + +h3 { + font-size:1.65em; + margin-top:0.5em; + margin-bottom:0.25em; + color:#333; + min-width:28em; +} + +h3 a { + font-size:small; +} + +h4 { + color:#444; +} + +ul.notes { + margin-left:0px; + padding-left:1.5em; +} + +.note { + margin-top:0px; + font-style:italic; + color:#999; +} + +pre { + font-size:1.2em; + _font-size:1em; +} + +code { + font-family:"lucida console",monaco,courier,system; + font-size:1em; + color:#003366; +} + +code span { + color:#666; +} + +ul, +p, +pre { + clear:left; + max-width:46em; +} + +ul.tight li { + max-width:44.5em; +} + +ul.playlist { + /* undo the above nonsense */ + max-width:none; +} + +ul.tight { + padding-left:1.5em; +} diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/css/optional-annotations.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/css/optional-annotations.css new file mode 100755 index 00000000..16b4964c --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/css/optional-annotations.css @@ -0,0 +1,162 @@ +/* + ------------------------------------------ + -- annotations (sub-tracks, notes etc.) -- + ------------------------------------------ +*/ + +ul.playlist li a.sm2_link .metadata { + display:none; /* hide by default */ +} + +ul.playlist li.sm2_paused a.sm2_link .metadata, +ul.playlist li.sm2_playing a.sm2_link .metadata { + display:inline; +} + +ul.playlist li ul { + list-style-type:none; + margin:0px; + padding:0px; + position:relative; + font-size:small; + display:none; +} + +ul.playlist li ul li { + position:relative; + margin:0px; + padding:2px 3px; + border:1px solid transparent; + border-radius:6px; + margin-right:1em; + font-family:helvetica,verdana,tahoma,arial,"sans serif"; + font-size:x-small; + font-weight:300; + letter-spacing:0px; + background-color:transparent; + opacity:0.66; +} + +ul.playlist li ul li:hover { + opacity:1; + background-color:#fff; + border-color:#ccc; + color:#666; +} + +ul.playlist li.sm2_playing ul li, +ul.playlist li.sm2_paused ul li { + color:#fff; +} + +ul.playlist li.sm2_playing ul li:hover { + background-color:#fff; + color:#5588bb; + border-color:#336699; + opacity:0.9; +} + +ul.playlist li.sm2_paused ul li:hover { + background-color:#888; +} + +/* metadata */ + +ul.playlist li .metadata .duration { + /* optional timing data */ + display:none; +} + +ul.playlist li .metadata ul li p { + margin:0px; + padding:0px; +} + +ul.playlist li .metadata ul li span { + display:none; +} + +ul.playlist li .controls .statusbar .annotation { + position:absolute; + background-color:transparent; + top:0px; + color:#666; + text-align:right; + margin-left:10px; + height:0.5em; +} + +ul.playlist li .controls .statusbar .annotation:hover { + z-index:12; /* sit on top of note */ +} + +ul.playlist li .controls .statusbar .annotation span.bubble { + /* using · */ + display:inline-block; + background-color:#fff; + border:1px solid #666; + border-radius:6px; +} + +ul.playlist li .controls .statusbar .annotation span { + display:block; + background:transparent url(../image/divot.png) no-repeat 50% 0px; + width:15px; + margin-left:-15px; + height:12px; + text-align:center; +} + +ul.playlist li .controls .statusbar .annotation.alt { + top:auto; + bottom:0px; +} + +ul.playlist li .controls .statusbar .annotation span:hover { + cursor:none; /* Fx3 rules. */ + margin-top:0.1em; +} + +ul.playlist li .controls .statusbar .annotation.alt span:hover { + margin-top:-0.1em; +} + +ul.playlist li .controls .statusbar .annotation.alt span { + background:transparent url(../image/divot-bottom.png) no-repeat 50% bottom; +} + +ul.playlist li .note { + position:absolute; + display:none; + left:0px; + top:0px; + z-index:10; + font-size:x-small; + padding:2px 4px 2px 4px; + width:auto; + color:#666; + background-color:#fff; + border:1px solid #ccc; + border-radius:6px; + font-style:normal; + font-weight:bold; + font-family:arial,tahoma,verdana,"sans serif"; + letter-spacing:0px; + margin-top:1.1em; +} + +ul.playlist li .note.alt { + margin-top:-1.32em; +} + +ul.playlist li .note:hover { + display:block !important; +} + +ul.playlist li .sm2_divider { + font-size:0.75em; +} + +ul.playlist li .sm2_metadata { + font-size:0.65em; +} diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/css/optional-themes.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/css/optional-themes.css new file mode 100755 index 00000000..0b85b44e --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/css/optional-themes.css @@ -0,0 +1,200 @@ +/* + --------------------------------- + -- alternate (optional) themes -- + --------------------------------- +*/ + +ul.playlist.dark li.sm2_playing a { + color:#fff; +} + +ul.playlist.dark li.sm2_playing .timing, +ul.playlist.use-peak.dark li.sm2_playing .peak { + color:#999; +} + +ul.playlist.use-spectrum.dark li.sm2_playing .spectrum-container { + background-color:#222; + border-color:#444; +} + +ul.playlist.use-spectrum.dark li.sm2_playing .spectrum-container .spectrum { + background-color:#999; +} + +ul.playlist.dark li.sm2_paused { + background-color:#333; +} + +ul.playlist.dark li.sm2_paused a { + color:#999; +} + +ul.playlist.dark li.sm2_playing, +ul.playlist.dark li.sm2_playing:hover { + background-color:#333; +} + +ul.playlist.dark li:hover .controls .statusbar { + background-color:#666; +} + +ul.playlist.dark li .controls { + background-color:#333; +} + +ul.playlist.dark li .controls .statusbar { + background-color:#666; + border-color:#444; +} + +ul.playlist.dark li .controls .statusbar .position { + background-color:#111; + border-right:3px solid #111; + border-radius:3px; +} + +ul.playlist.dark li .controls .statusbar .loading { + background-color:#444; +} + +ul.playlist.dark li .timing, +ul.playlist.use-peak.dark li .peak { + background-color:#222; + border-color:#444; +} + +ul.playlist.dark.use-peak li .peak .l, +ul.playlist.dark.use-peak li .peak .r { + border-color:#444; + background-color:#999; +} + + +/* gold theme */ + +ul.playlist.gold li.sm2_paused { + background-color:#996600; +} + +ul.playlist.gold li.sm2_playing, +ul.playlist.gold li.sm2_playing:hover { + background-color:#cc9900; +} + +ul.playlist.gold li .controls { + background-color:transparent; +} + +ul.playlist.gold li .controls .statusbar { + background-color:#fff; + border-color:#fff; +} + +ul.playlist.gold li .controls .statusbar .position { + background-color:#996600; + border-right:3px solid #996600; + border-radius:3px; +} + +ul.playlist.gold li .controls .statusbar .loading { + background-color:#ffeedd; +} + +ul.playlist.gold li .timing, +ul.playlist.use-peak.gold li .peak { + background-color:#CC9900; + border-color:#ffcc33; +} + +ul.playlist.use-spectrum.gold li.sm2_playing .spectrum-container { + background-color:#cc9900; + border-color:#ffcc33; +} + +ul.playlist.use-spectrum.gold li.sm2_playing .spectrum-container .spectrum { + background-color:#fff; +} + +ul.playlist.gold.use-peak li .peak .l, +ul.playlist.gold.use-peak li .peak .r { + border-color:#fff; + background-color:#fff; +} + + +/* ZOMG PONIES!!!ONEONEONE */ + +ul.playlist.bubblegum li a { + font-family:"comic sans ms",verdana,arial,tahoma,"sans serif"; /* heh */ +} + +ul.playlist.bubblegum li.sm2_paused, +ul.playlist.bubblegum li.sm2_paused:hover { + background-color:#ffccee; +} + +ul.playlist.bubblegum li.sm2_paused a, +ul.playlist.bubblegum li.sm2_paused:hover a, +ul.playlist.bubblegum li.sm2_paused .timing, +ul.playlist.use-peak.bubblegum li.sm2_paused .peak { + color:#ff6699; +} + +ul.playlist.bubblegum li:hover { + background-color:#ffddee; +} + +ul.playlist.bubblegum li.sm2_playing, +ul.playlist.bubblegum li.sm2_playing:hover { + background-color:#ff7799; +} + +ul.playlist.bubblegum li .controls { + background-color:transparent; +} + +ul.playlist.bubblegum li .controls .statusbar { + background-color:#fff; + border-color:#fff; +} + +ul.playlist.bubblegum li .controls .statusbar .position { + background-color:#ffaacc; + border-right:3px solid #ffaacc; + border-radius:3px; +} + +ul.playlist.bubblegum li .controls .statusbar .loading { + background-color:#ffeedd; +} + +ul.playlist.bubblegum li .timing, +ul.playlist.use-peak.bubblegum li .peak { + background-color:#ffaacc; + border-color:#ffccee; +} + +ul.playlist.use-spectrum.bubblegum li.sm2_playing .spectrum-container { + background-color:#ffaacc; + border-color:#ffccee; +} + +ul.playlist.use-spectrum.bubblegum li.sm2_playing .spectrum-container .spectrum { + background-color:#fff; +} + +ul.playlist.bubblegum.use-peak li .peak .l, +ul.playlist.bubblegum.use-peak li .peak .r { + border-color:#fff; + background-color:#fff; +} + + +ul.playlist.shiny li.sm2_paused, +ul.playlist.shiny li.sm2_playing { + background-image:url(../image/top-highlight.png); + background-repeat:repeat-x; + background-position:0px -1px; + _background-image:none; /* can't be bothered with IE 6. */ +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/css/page-player.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/css/page-player.css new file mode 100755 index 00000000..9c0098fa --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/css/page-player.css @@ -0,0 +1,307 @@ +/* + + SoundManager 2: "page as playlist" example + ------------------------------------------ + http://schillmania.com/projects/soundmanager2/ + +*/ + +.spectrum-container { + display:none; +} + +ul.use-spectrum li.sm2_playing .spectrum-container { + position:absolute; + left:0px; + top:0px; + margin-left:-266px; + margin-top:-1px; + display:block; + background-color:#5588bb; + border:1px solid #99ccff; + border-radius:4px; +} + +ul.use-spectrum .spectrum-box { + position:relative; + width:255px; + font-size:1em; + padding:2px 0px; + height:1.2em; + overflow:hidden; +} + +ul.use-spectrum .spectrum-box .spectrum { + position:absolute; + left:0px; + top:-2px; + margin-top:20px; + display:block; + font-size:1px; + width:1px; + height:1px; /* set to 50px for a thick line, 1px for a thin line, etc. */ + overflow:hidden; + background-color:#fff; +} + +ul.playlist { + list-style-type:none; + margin:0px; + padding:0px; + +} + +ul.playlist li { + /* assume all items will be sounds rather than wait for onload etc. in this example.. may differ for your uses. */ + position:relative; + display:block; + width:auto; + font-size:2em; + color:#666; + padding:0.25em 0.5em 0.25em 0.5em; + border:none; + letter-spacing:-1px; /* ZOMG WEB X.0. ;) */ + background-color:#f9f9f9; + -webkit-transition-property: hover; + -webkit-transition: background-color 0.15s ease-in-out; + -moz-transition: background-color 0.15s linear 0s; /* firefox 4 */ + -o-transition-property: background-color; /* opera 10.5 */ + -o-transition-duration: 0.15s; + +} + +ul.playlist li a { + display:block; + text-decoration:none; + font-weight:normal; + color:#000; + font-size:120%; + outline:none; + position:relative; + z-index:2; +} + +ul.playlist li.sm2_playing, +ul.playlist li.sm2_paused, +ul.playlist li.sm2_playing a { + color:#fff; + border-radius:3px; +} + +ul.playlist li:hover { + background-color:#eee; +} + +ul.playlist li:hover a { + color:#333; +} + +ul.playlist li.sm2_playing, +ul.playlist li.sm2_playing:hover { + background-color:#6699cc; +} + +ul.playlist li.sm2_paused { + background-color:#999; +} + +ul.playlist li.sm2_playing:hover a, +ul.playlist li.sm2_paused a { + color:#fff; +} + +ul.playlist li .controls { + display:none; +} + +ul.playlist li .peak, +ul.playlist.use-peak li .peak { + display:none; + position:absolute; + top:0.55em; + right:0.5em; +} + +ul.playlist li.sm2_playing .controls, +ul.playlist li.sm2_paused .controls { + position:relative; + display:block; +} + +ul.playlist.use-peak li.sm2_playing .peak, +ul.playlist.use-peak li.sm2_paused .peak { + display:inline; + display:inline-block; +} + +ul.playlist.use-peak li .peak { + display:none; /* IE 7 */ +} + +ul.playlist li.sm2_paused .controls { + background-color:#666; +} + +ul.playlist li:hover .controls .statusbar { + position:relative; + cursor:ew-resize; + cursor:-moz-grab; + cursor:grab; +} + +ul.playlist li.sm2_paused .controls .statusbar { + background-color:#ccc; +} + +ul.playlist li .controls { + position:relative; + margin-top:0.25em; + margin-bottom:0.25em; + background-color:#99ccff; +} + +ul.playlist li .controls .statusbar { + position:relative; + height:0.5em; + background-color:#ccddff; + border:2px solid #fff; + border-radius:2px; + overflow:hidden; + cursor:-moz-grab; + cursor:grab; +} + +ul.playlist li .controls.dragging .statusbar { + cursor:-moz-grabbing; + cursor:grabbing; +} + +ul.playlist li .controls .statusbar .position, +ul.playlist li .controls .statusbar .loading, +ul.playlist li .controls .statusbar .annotation { + position:absolute; + left:0px; + top:0px; + height:0.5em; +} + +ul.playlist li .controls .statusbar .position { + background-color:#336699; + border-right:3px solid #336699; + border-radius:3px; +} + +ul.playlist li.sm2_paused .controls .statusbar .position { + background-color:#666; + border-color:#666; +} + +ul.playlist li .controls .statusbar .loading { + background-color:#eee; +} + +ul.playlist li .controls .statusbar .position, +ul.playlist li .controls .statusbar .loading { + width:0px; +} + +ul.playlist li.sm2_playing a.sm2_link, +ul.playlist li.sm2_paused a.sm2_link { + margin-right:4.5em; /* room for timing stuff */ +} + +ul.playlist li .timing { + position:absolute; + display:none; + text-align:right; + right:1em; + top:1em; + width:auto; + height:1em; + padding:3px 5px; + background-color:#5588bb; + border:1px solid #99ccff; + border-radius:4px; + letter-spacing:0px; + font:44% monaco,"VT-100","lucida console",courier,system; + line-height:1em; + vertical-align:middle; +} + +ul.playlist.use-peak li .timing { + right:4.25em; +} + +ul.playlist li:hover .timing { + z-index:2; +} + +ul.playlist li .timing div.sm2_timing { + margin:0px; + padding:0px; + margin-top:-1em; +} + +ul.playlist li.sm2_playing .timing, +ul.playlist li.sm2_paused .timing { + display:block; +} + +ul.playlist li.sm2_paused .timing .sm2_position { + text-decoration:blink; /* hee hee. first actual appropriate use? :D */ +} + +ul.playlist li.sm2_paused .timing, +ul.playlist.use-peak li.sm2_paused .peak { + background-color:#888; + border-color:#ccc; +} + +/* peak data */ + +/* ul.playlist ... */ + +ul.playlist.use-peak li .peak { + display:none; + zoom:1; + border:1px solid #99ccff; + padding:2px; + height:0.55em; + border-radius:4px; + background-color:#5588bb; + width:0.8em; + height:0.55em; + margin-top:-3px; +} + +ul.playlist.use-peak li .peak-box { + position:relative; + width:100%; + height:0.55em; + overflow:hidden; +} + +ul.playlist li .peak .l, +ul.playlist li .peak .r { + position:absolute; + left:0px; + top:0px; + width:7px; + height:50px; + background:#fff; + border:1px solid #fff; + border-radius:1px; + margin-top:1em; +} + +ul.playlist li .peak .l { + margin-right:1px; +} + +ul.playlist li .peak .r { + left:10px; +} + +#control-template { + display:none; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/image/divot-bottom.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/image/divot-bottom.png new file mode 100755 index 00000000..929b42d3 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/image/divot-bottom.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/image/divot.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/image/divot.png new file mode 100755 index 00000000..76c5ee53 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/image/divot.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/image/top-highlight.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/image/top-highlight.png new file mode 100755 index 00000000..19bdfa58 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/image/top-highlight.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/index.html new file mode 100755 index 00000000..678d2e8f --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/index.html @@ -0,0 +1,379 @@ + + + +SoundManager 2 Demo: Play MP3 links on a page, "page as playlist" style + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    SoundManager 2 / "Page as a playlist"

    + +

    Muxtape.com-style UI, MP3/AAC Player Example

    + +

    This page uses Flash 9-based effects where supported. The default config uses Flash 8.

    + +

    You can also try enabling experimental visualization features.

    + +
    + +
    + + + +

    MPEG4 / H.264 + HE-AAC (Flash "MovieStar" 9.0r115+) format support - audio-only example

    +

    A subset of MPEG4 is supported including AAC, FLV, MP4, M4A, MOV, MP4V, 3GP and 3G2 files.

    + + + +

    Basics

    + +

    Don't want a Flash 9 requirement, EQ/waveform, perhaps less CPU? See Flash 8-based basic demo.

    + +

    Clicking a title will start loading + playing, or pause, a sound.

    +

    Once loading, click (or click and drag) on the loading/position bar to seek within the sound.

    +

    The document title reflects the currently-playing sound, and by default the list will play sequentially if left alone. (This is configurable.)

    + +

    Themes

    +

    Just for fun, a few color schemes (visible when playing/paused):

    + + +
    +
    + +
    +
    + + +

    Experimental (Alpha) Variant: MP3 "Metadata": Annotations / notes / sub-tracks

    +

    A potential approach to noting interesting moments in sounds, scene changes, new tracks in seamless DJ mixes etc. Keep in mind this is a single MP3 being loaded, but annotations are placed along the timeline as shown.

    +

    A "metadata" element contains a nested list of data (UL/LI combination) - in this case, a summary of each scene - and the time at which this item occurs/begins. In order to help with positioning, the total length of the sound is also specified up-front. View the source code of this page for the details.

    + +
      + +
    • + A Virtual Haircut (3 scenes) + +
    • + +
    • + Rubber Chicken Launch (Office) + +
    • + +
    + +

    How It Works

    + +

    This example uses SoundManager 2 to find links to MP3 files within an unordered list, and makes them playable "in-place" on a page. The script assigns CSS classes to links' parent LI nodes to indicate their state (playing/paused, etc.)

    + +

    Progressive Enhancement

    + +

    This provides a nice HTML base for all browsers and user agents, and enhances progressively for those with Javascript and Flash. Links pointing to MP3s are assigned an onclick handler which intercepts the click (preventing the browser from following the link and unloading the page. SM2 will then create sound objects as needed to play the MP3s. In the event there is an error at runtime or a lack of support (no JS/Flash etc.), the browser will simply load the MP3s directly as it normally would. This includes iPhones, etc.

    + +

    HTML Fragments (UI Element Templates)

    +

    Each item in the playlist has its own set of controls and progress indicators, etc. This content is defined once as a hidden template of HTML in the player JavaScript file, separate from the playlist markup, and is cloned for each item as needed. This can be easily styled with CSS as well, of course.

    + +

    I'd like to use this.

    +

    See this basic demo for reference.

    +

    The basic demo uses the default Flash 8 configuration, but you can easily change this to use Flash 9 features. The only difference in code is the configuration.

    + +

    A reminder that if loading from the local filesystem, Flash will deny access to remote (network/internet) URLs by default unless whitelisted via the Flash Player Global Security Settings Page. Some URLs in this example are remote to demonstrate this.

    + +

    Configuration + Options

    + +

    Default configuration

    + +

    Behaviours such as auto-start and UI elements like VU meters and spectrum graphs are easy configurable, using an object literal format as shown below.

    +

    The page player config (see related page-player.js file) as below.

    +

    The custom parameters used to make this demo page are highlighted in red.

    +
      // ( within page-player.js )
    +
    +  soundManager.setup({
    +    // If you need flash 9, include this line.
    +    flashVersion: 9
    +  });
    +
    +  this.config = {
    +    usePeakData: true,     // [Flash 9 only] show peak (VU-meter) data
    +    useFavIcon: true,      // try to show peakData in address bar (Firefox + Opera) - requires usePeakData = true too, of course.
    +    useWaveformData: true, // [Flash 9 only] true: show raw waveform data - WARNING: CPU-intensive
    +    useEQData: false,      // [Flash 9 only] show EQ (frequency spectrum) data - WARNING: CPU-intensive
    +    fillGraph: false,      // [Flash 9 only] draw full lines instead of only top (peak) spectrum points
    +    allowRightClick:true,  // let users right-click MP3 links ("save as...", etc.) or discourage (can't prevent.)
    +    useThrottling: false,  // try to rate-limit potentially-expensive calls (eg. dragging position around)
    +    autoStart: false,      // begin playing first sound when page loads
    +    playNext: true,        // stop after one sound, or play through list until end
    +    updatePageTitle: true, // change the page title while playing sounds
    +    emptyTime: '-:--'      // null/undefined timer values (before data is available)
    +  }
    +
    + +

    Per-page configuration override

    + +

    Alternately, you may override the defaults on a per-page basis by defining an "alternate configuration" object before the page-player.js file has been included in your source code:

    + +
      // ( before soundManager.onready() has fired )
    +
    +  soundManager.setup({
    +    // If you need flash 9, include this line.
    +    flashVersion: 9
    +  });
    +
    +  var PP_CONFIG = {
    +    usePeakData: true,     // [Flash 9 only] whether or not to show peak data (no notable CPU cost)
    +    useWaveformData: true  // [Flash 9 only] show raw waveform data. WARNING: Experimental, likely CPU-heavy
    +  }
    + +

    Any options specified in PP_CONFIG will override the defaults defined in page-player.js.

    + +

    Basic CSS

    + +
    + If you want to make your own UI from scratch, here is the base:
    +
    + ul.playlist {}
    +
    + Default + hover state, "click to play":
    +
    + li.sm2_link {}
    + li.sm2_link:hover {}
    +
    + Playing + hover state, "click to pause":
    +
    + li.sm2_playing {}
    + li.sm2_playing:hover {}
    +
    + Paused + hover state, "click to resume":
    +
    + li.sm2_paused {}
    + li.sm2_paused:hover {}
    +
    + +

    The positioning (load status / control bar) template is also applied after each MP3 link, from an element named "control-template"

    + +

    "loading" and "position" have background colors applied, and have their width adjusted dynamically by SM2 as the sound(s) load/play. "timing" is replaced with the current time / duration, eg. 1:23 / 4:20

    +

    The class names applied can be edited within the source JS also, for convenience.

    +

    The controls are shown and hidden via the same dynamic CSS updates. See the source CSS for the timing / status bar layout.

    + +

    Performance Considerations

    +

    Experimental Flash 9 features

    +
      +
    • +

      Dynamic "favicon" VU meter

      +

      The VU meter "favicon" option as shown in the address/location bar for Firefox and Opera can cause a lot of disk access in Firefox (2.x/3.0 at time of writing, from what has been reported.) It may be garbage collection-related.

      +

      The behaviour seems to be connected to the dynamic swapping of <link> elements with data: URIs containing the VU meter data, and looks to be noticeable with the first sound played - after which point things settle down. Perhaps the browser is attempting to cache the favicon data being assigned.

      +
    • +
    • +

      Waveform/spectrum visualization graph

      +

      Enabling the waveformData and/or eqData features will result in some heavy DOM calls (manipulation of 256 <div> elements with each "frame" drawn) which can eat up a good amount of CPU and may make really old computers cower in fear.

      +

      Ultimately, the UI refresh rate will simply be limited if a CPU ceiling is hit, and audio playback should not be affected.

      +
    • +
    + +

    More CSS comments

    + +
    +
    +
    + SoundManager 2: "page as playlist" example
    + ------------------------------------------
    +
    + Clicks on links to MP3s are intercepted via JS, calls are
    + made to SoundManager to load/play sounds. CSS classes are
    + appended to the LI parent, which are used to highlight the
    + current play state and so on.
    +
    + Class names are applied in addition to "sm2_link" base.
    +
    + Default:
    +
    + sm2_link
    +
    + Additional states:
    +
    + sm2_playing
    + sm2_paused
    +
    + eg.
    +
    + <!-- default -->
    + <li class="sm2_link"><a href="some.mp3">some.mp3</a></li>
    +
    + <!-- playing -->
    + <li class="sm2_link sm2_playing"><a href="some.mp3">some.mp3</a></li>
    +
    + The script also injects an HTML template containing control bar
    + and timing elements, which can also be targeted with CSS.
    +
    +
    + Note you don't necessarily require ul.playlist for your use
    + if only using one style on a page. You can just use .sm2_link
    + and so on, but isolate the CSS you want.
    +
    + Side note: Would do multiple class definitions eg.
    +
    + li.sm2_default.sm2_playing{}
    +
    + .. except IE 6 has a parsing bug which may break behaviour,
    + applying sm2_playing {} even when the class is set to sm2_default.
    +
    +
    + If you want to make your own UI from scratch, here is the base:
    +
    + Default + hover state, "click to play":
    +
    + li.sm2_link {}
    + li.sm2_link:hover {}
    +
    + Playing + hover state, "click to pause":
    +
    + li.sm2_playing {}
    + li.sm2_playing:hover {}
    +
    + Paused + hover state, "click to resume":
    +
    + li.sm2_paused {}
    + li.sm2_paused:hover {}
    +
    +
    + +

    SoundManager 2 project home

    + +
    + + + + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/script/optional-page-player-metadata.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/script/optional-page-player-metadata.js new file mode 100755 index 00000000..0faa0e35 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/script/optional-page-player-metadata.js @@ -0,0 +1,142 @@ +// SoundManager 2: Page Player demo, MetaData UI prototype + +/*jslint white: false, onevar: true, undef: true, nomen: false, eqeqeq: true, plusplus: false, bitwise: true, newcap: true, immed: true */ +/*global pagePlayer, document, window */ + +var Metadata = function(oSound) { + + var self = this, + pl = pagePlayer, + oLI = oSound._data.oLI, + o = oLI.getElementsByTagName('ul')[0], + oItems = o.getElementsByTagName('li'), + oTemplate = document.createElement('div'), + oTemplate2 = document.createElement('div'), + oTemplate3 = document.createElement('div'), + oDuration, i; + + oTemplate.innerHTML = ' '; + oTemplate.className = 'annotation'; + oTemplate2.innerHTML = ' '; + oTemplate2.className = 'annotation alt'; + oTemplate3.className = 'note'; + + this.totalTime = 0; + this.data = []; + this.data.givenDuration = null; + this.data.currentItem = null; + this.data.mainTitle = oSound._data.oLink.innerHTML; + + this.strToTime = function(sTime) { + var segments = sTime.split(':'), + seconds = 0, i; + for (i=segments.length; i--;) { + seconds += parseInt(segments[i],10)*Math.pow(60,segments.length-1-i); // hours, minutes + } + return seconds; + }; + + // make stuff + this.createElements = function() { + var oFrag = document.createDocumentFragment(), + oNode = null, + oNodeSpan = null, + oNode2 = null, i; + for (i=0; i= metadata[i].startTimeMS && now <= metadata[i].endTimeMS) { + index = i; + break; + } + } + if (index !== metadata.currentItem) { + // update + oSound._data.oLink.innerHTML = metadata.mainTitle+' '; + pl.setPageTitle(metadata[index].title+' | '+metadata.mainTitle); + metadata.currentItem = index; + } + }; + + this.refresh = function() { + var offset = 0, + relWidth = null, + duration = (self.data.givenDuration?self.data.givenDuration:oSound.durationEstimate), i; + for (i=0; i 3) { + args.pop(); // no capture + } + } else if (len === 3) { + args.push(false); + } + return args; + } + + function apply(args, sType) { + var element = args.shift(), + method = [evt[sType]]; + if (old) { + element[method](args[0], args[1]); + } else { + element[method].apply(element, args); + } + } + + function add() { + apply(getArgs(arguments), 'add'); + } + + function remove() { + apply(getArgs(arguments), 'remove'); + } + + return { + 'add': add, + 'remove': remove + }; + + }()); + + // event + DOM utilities + + this.hasClass = function(o, cStr) { + return (typeof(o.className)!=='undefined'?new RegExp('(^|\\s)'+cStr+'(\\s|$)').test(o.className):false); + }; + + this.addClass = function(o, cStr) { + if (!o || !cStr || self.hasClass(o,cStr)) { + return false; // safety net + } + o.className = (o.className?o.className+' ':'')+cStr; + }; + + this.removeClass = function(o, cStr) { + if (!o || !cStr || !self.hasClass(o,cStr)) { + return false; + } + o.className = o.className.replace(new RegExp('( '+cStr+')|('+cStr+')','g'),''); + }; + + this.select = function(className, oParent) { + var result = self.getByClassName(className, 'div', oParent||null); + return (result ? result[0] : null); + }; + + this.getByClassName = (document.querySelectorAll ? function(className, tagNames, oParent) { // tagNames: string or ['div', 'p'] etc. + + var pattern = ('.'+className), qs; + if (tagNames) { + tagNames = tagNames.split(' '); + } + qs = (tagNames.length > 1 ? tagNames.join(pattern+', ') : tagNames[0]+pattern); + return (oParent?oParent:document).querySelectorAll(qs); + + } : function(className, tagNames, oParent) { + + var node = (oParent?oParent:document), matches = [], i, j, nodes = []; + if (tagNames) { + tagNames = tagNames.split(' '); + } + if (tagNames instanceof Array) { + for (i=tagNames.length; i--;) { + if (!nodes || !nodes[tagNames[i]]) { + nodes[tagNames[i]] = node.getElementsByTagName(tagNames[i]); + } + } + for (i=tagNames.length; i--;) { + for (j=nodes[tagNames[i]].length; j--;) { + if (self.hasClass(nodes[tagNames[i]][j], className)) { + matches.push(nodes[tagNames[i]][j]); + } + } + } + } else { + nodes = node.all||node.getElementsByTagName('*'); + for (i=0, j=nodes.length; i playlist item, find previous
  • and then + if (o.previousElementSibling) { + o = o.previousElementSibling; + } else { + o = o.previousSibling; // move from original node.. + while (o && o.previousSibling && o.previousSibling.nodeType !== 1) { + o = o.previousSibling; + } + } + if (o.nodeName.toLowerCase() !== 'li') { + return null; + } else { + return o.getElementsByTagName('a')[0]; + } + }; + + this.playPrevious = function(oSound) { + if (!oSound) { + oSound = self.lastSound; + } + if (!oSound) { + return false; + } + var previousItem = self.getPreviousItem(oSound._data.oLI); + if (previousItem) { + pl.handleClick({target:previousItem}); // fake a click event - aren't we sneaky. ;) + } + return previousItem; + }; + + this.getNextItem = function(o) { + // given
  • playlist item, find next
  • and then + if (o.nextElementSibling) { + o = o.nextElementSibling; + } else { + o = o.nextSibling; // move from original node.. + while (o && o.nextSibling && o.nextSibling.nodeType !== 1) { + o = o.nextSibling; + } + } + if (o.nodeName.toLowerCase() !== 'li') { + return null; + } else { + return o.getElementsByTagName('a')[0]; + } + }; + + this.playNext = function(oSound) { + if (!oSound) { + oSound = self.lastSound; + } + if (!oSound) { + return false; + } + var nextItem = self.getNextItem(oSound._data.oLI); + if (nextItem) { + pl.handleClick({target:nextItem}); // fake a click event - aren't we sneaky. ;) + } + return nextItem; + }; + + this.setPageTitle = function(sTitle) { + if (!self.config.updatePageTitle) { + return false; + } + try { + document.title = (sTitle?sTitle+' - ':'')+self.pageTitle; + } catch(e) { + // oh well + self.setPageTitle = function() { + return false; + }; + } + }; + + this.events = { + + // handlers for sound events as they're started/stopped/played + + play: function() { + pl.removeClass(this._data.oLI,this._data.className); + this._data.className = pl.css.sPlaying; + pl.addClass(this._data.oLI,this._data.className); + self.setPageTitle(this._data.originalTitle); + }, + + stop: function() { + pl.removeClass(this._data.oLI,this._data.className); + this._data.className = ''; + this._data.oPosition.style.width = '0px'; + self.setPageTitle(); + self.resetPageIcon(); + }, + + pause: function() { + if (pl.dragActive) { + return false; + } + pl.removeClass(this._data.oLI,this._data.className); + this._data.className = pl.css.sPaused; + pl.addClass(this._data.oLI,this._data.className); + self.setPageTitle(); + self.resetPageIcon(); + }, + + resume: function() { + if (pl.dragActive) { + return false; + } + pl.removeClass(this._data.oLI,this._data.className); + this._data.className = pl.css.sPlaying; + pl.addClass(this._data.oLI,this._data.className); + }, + + finish: function() { + pl.removeClass(this._data.oLI,this._data.className); + this._data.className = ''; + this._data.oPosition.style.width = '0px'; + // play next if applicable + if (self.config.playNext) { + pl.playNext(this); + } else { + self.setPageTitle(); + self.resetPageIcon(); + } + }, + + whileloading: function() { + function doWork() { + this._data.oLoading.style.width = (((this.bytesLoaded/this.bytesTotal)*100)+'%'); // theoretically, this should work. + if (!this._data.didRefresh && this._data.metadata) { + this._data.didRefresh = true; + this._data.metadata.refresh(); + } + } + if (!pl.config.useThrottling) { + doWork.apply(this); + } else { + var d = new Date(); + if (d && d-self.lastWLExec > 50 || this.bytesLoaded === this.bytesTotal) { + doWork.apply(this); + self.lastWLExec = d; + } + } + + }, + + onload: function() { + if (!this.loaded) { + var oTemp = this._data.oLI.getElementsByTagName('a')[0], + oString = oTemp.innerHTML, + oThis = this; + oTemp.innerHTML = oString+' | Load failed, d\'oh! '+(sm.sandbox.noRemote?' Possible cause: Flash sandbox is denying remote URL access.':(sm.sandbox.noLocal?'Flash denying local filesystem access':'404?'))+''; + setTimeout(function(){ + oTemp.innerHTML = oString; + // pl.events.finish.apply(oThis); // load next + },5000); + } else { + if (this._data.metadata) { + this._data.metadata.refresh(); + } + } + }, + + whileplaying: function() { + var d = null; + if (pl.dragActive || !pl.config.useThrottling) { + self.updateTime.apply(this); + if (sm.flashVersion >= 9) { + if (pl.config.usePeakData && this.instanceOptions.usePeakData) { + self.updatePeaks.apply(this); + } + if (pl.config.useWaveformData && this.instanceOptions.useWaveformData || pl.config.useEQData && this.instanceOptions.useEQData) { + self.updateGraph.apply(this); + } + } + if (this._data.metadata) { + d = new Date(); + if (d && d-self.lastWPExec>500) { + this._data.metadata.refreshMetadata(this); + self.lastWPExec = d; + } + } + this._data.oPosition.style.width = (((this.position/self.getDurationEstimate(this))*100)+'%'); + } else { + d = new Date(); + if (d-self.lastWPExec>30) { + self.updateTime.apply(this); + if (sm.flashVersion >= 9) { + if (pl.config.usePeakData && this.instanceOptions.usePeakData) { + self.updatePeaks.apply(this); + } + if (pl.config.useWaveformData && this.instanceOptions.useWaveformData || pl.config.useEQData && this.instanceOptions.useEQData) { + self.updateGraph.apply(this); + } + } + if (this._data.metadata) { + this._data.metadata.refreshMetadata(this); + } + this._data.oPosition.style.width = (((this.position/self.getDurationEstimate(this))*100)+'%'); + self.lastWPExec = d; + } + } + } + + }; // events{} + + this.setPageIcon = function(sDataURL) { + if (!self.config.useFavIcon || !self.config.usePeakData || !sDataURL) { + return false; + } + var link = document.getElementById('sm2-favicon'); + if (link) { + _head.removeChild(link); + link = null; + } + if (!link) { + link = document.createElement('link'); + link.id = 'sm2-favicon'; + link.rel = 'shortcut icon'; + link.type = 'image/png'; + link.href = sDataURL; + document.getElementsByTagName('head')[0].appendChild(link); + } + }; + + this.resetPageIcon = function() { + if (!self.config.useFavIcon) { + return false; + } + var link = document.getElementById('favicon'); + if (link) { + link.href = '/favicon.ico'; + } + }; + + this.updatePeaks = function() { + var o = this._data.oPeak, + oSpan = o.getElementsByTagName('span'); + oSpan[0].style.marginTop = (13-(Math.floor(15*this.peakData.left))+'px'); + oSpan[1].style.marginTop = (13-(Math.floor(15*this.peakData.right))+'px'); + if (sm.flashVersion > 8 && self.config.useFavIcon && self.config.usePeakData) { + self.setPageIcon(self.vuMeterData[parseInt(16*this.peakData.left,10)][parseInt(16*this.peakData.right,10)]); + } + }; + + this.updateGraph = function() { + if (pl.config.flashVersion < 9 || (!pl.config.useWaveformData && !pl.config.useEQData)) { + return false; + } + var sbC = this._data.oGraph.getElementsByTagName('div'), + scale, i, offset; + if (pl.config.useWaveformData) { + // raw waveform + scale = 8; // Y axis (+/- this distance from 0) + for (i=255; i--;) { + sbC[255-i].style.marginTop = (1+scale+Math.ceil(this.waveformData.left[i]*-scale))+'px'; + } + } else { + // eq spectrum + offset = 9; + for (i=255; i--;) { + sbC[255-i].style.marginTop = ((offset*2)-1+Math.ceil(this.eqData[i]*-offset))+'px'; + } + } + }; + + this.resetGraph = function() { + if (!pl.config.useEQData || pl.config.flashVersion<9) { + return false; + } + var sbC = this._data.oGraph.getElementsByTagName('div'), + scale = (!pl.config.useEQData?'9px':'17px'), + nHeight = (!pl.config.fillGraph?'1px':'32px'), + i; + for (i=255; i--;) { + sbC[255-i].style.marginTop = scale; // EQ scale + sbC[255-i].style.height = nHeight; + } + }; + + this.updateTime = function() { + var str = self.strings.timing.replace('%s1',self.getTime(this.position,true)); + str = str.replace('%s2',self.getTime(self.getDurationEstimate(this),true)); + this._data.oTiming.innerHTML = str; + }; + + this.getTheDamnTarget = function(e) { + return (e.target||(window.event?window.event.srcElement:null)); + }; + + this.withinStatusBar = function(o) { + return (self.isChildOfClass(o,'playlist')) && (self.isChildOfClass(o,'controls')); + }; + + this.handleClick = function(e) { + + // a sound (or something) was clicked - determine what and handle appropriately + + if (e.button === 2) { + if (!pl.config.allowRightClick) { + pl.stopEvent(e); + } + return pl.config.allowRightClick; // ignore right-clicks + } + var o = self.getTheDamnTarget(e), + sURL, soundURL, thisSound, oControls, oLI, str; + if (!o) { + return true; + } + if (self.dragActive) { + self.stopDrag(); // to be safe + } + if (self.withinStatusBar(o)) { + // self.handleStatusClick(e); + return false; + } + if (o.nodeName.toLowerCase() !== 'a') { + o = self.getParentByNodeName(o,'a'); + } + if (!o) { + // not a link + return true; + } + + // OK, we're dealing with a link + + sURL = o.getAttribute('href'); + + if (!o.href || (!sm.canPlayLink(o) && !self.hasClass(o,'playable')) || self.hasClass(o,'exclude')) { + + // do nothing, don't return anything. + return true; + + } else { + + // we have something we're interested in. + + // find and init parent UL, if need be + self.initUL(self.getParentByNodeName(o, 'ul')); + + // and decorate the link too, if needed + self.initItem(o); + + soundURL = o.href; + thisSound = self.getSoundByObject(o); + + if (thisSound) { + + // sound already exists + self.setPageTitle(thisSound._data.originalTitle); + if (thisSound === self.lastSound) { + // ..and was playing (or paused) and isn't in an error state + if (thisSound.readyState !== 2) { + if (thisSound.playState !== 1) { + // not yet playing + thisSound.play(); + } else { + thisSound.togglePause(); + } + } else { + sm._writeDebug('Warning: sound failed to load (security restrictions, 404 or bad format)',2); + } + } else { + // ..different sound + if (self.lastSound) { + self.stopSound(self.lastSound); + } + if (spectrumContainer) { + thisSound._data.oTimingBox.appendChild(spectrumContainer); + } + thisSound.togglePause(); // start playing current + } + + } else { + + // create sound + thisSound = sm.createSound({ + id:o.id, + url:decodeURI(soundURL), + onplay:self.events.play, + onstop:self.events.stop, + onpause:self.events.pause, + onresume:self.events.resume, + onfinish:self.events.finish, + type:(o.type||null), + whileloading:self.events.whileloading, + whileplaying:self.events.whileplaying, + onmetadata:self.events.metadata, + onload:self.events.onload + }); + + // append control template + oControls = self.oControls.cloneNode(true); + oLI = o.parentNode; + oLI.appendChild(oControls); + if (spectrumContainer) { + oLI.appendChild(spectrumContainer); + } + self.soundsByObject[o.id] = thisSound; + + // tack on some custom data + thisSound._data = { + oLink: o, // DOM reference within SM2 object event handlers + oLI: oLI, + oControls: self.select('controls',oLI), + oStatus: self.select('statusbar',oLI), + oLoading: self.select('loading',oLI), + oPosition: self.select('position',oLI), + oTimingBox: self.select('timing',oLI), + oTiming: self.select('timing',oLI).getElementsByTagName('div')[0], + oPeak: self.select('peak',oLI), + oGraph: self.select('spectrum-box',oLI), + className: self.css.sPlaying, + originalTitle: o.innerHTML, + metadata: null + }; + + if (spectrumContainer) { + thisSound._data.oTimingBox.appendChild(spectrumContainer); + } + + // "Metadata" + if (thisSound._data.oLI.getElementsByTagName('ul').length) { + thisSound._data.metadata = new Metadata(thisSound); + } + + // set initial timer stuff (before loading) + str = self.strings.timing.replace('%s1',self.config.emptyTime); + str = str.replace('%s2',self.config.emptyTime); + thisSound._data.oTiming.innerHTML = str; + self.sounds.push(thisSound); + if (self.lastSound) { + self.stopSound(self.lastSound); + } + self.resetGraph.apply(thisSound); + thisSound.play(); + + } + + self.lastSound = thisSound; // reference for next call + return self.stopEvent(e); + + } + + }; + + this.handleMouseDown = function(e) { + // a sound link was clicked + if (isTouchDevice && e.touches) { + e = e.touches[0]; + } + if (e.button === 2) { + if (!pl.config.allowRightClick) { + pl.stopEvent(e); + } + return pl.config.allowRightClick; // ignore right-clicks + } + var o = self.getTheDamnTarget(e); + if (!o) { + return true; + } + if (!self.withinStatusBar(o)) { + return true; + } + self.dragActive = true; + self.lastSound.pause(); + self.setPosition(e); + if (!isTouchDevice) { + _event.add(document,'mousemove',self.handleMouseMove); + } else { + _event.add(document,'touchmove',self.handleMouseMove); + } + self.addClass(self.lastSound._data.oControls,'dragging'); + return self.stopEvent(e); + }; + + this.handleMouseMove = function(e) { + if (isTouchDevice && e.touches) { + e = e.touches[0]; + } + // set position accordingly + if (self.dragActive) { + if (self.config.useThrottling) { + // be nice to CPU/externalInterface + var d = new Date(); + if (d-self.dragExec>20) { + self.setPosition(e); + } else { + window.clearTimeout(self.dragTimer); + self.dragTimer = window.setTimeout(function(){self.setPosition(e);},20); + } + self.dragExec = d; + } else { + // oh the hell with it + self.setPosition(e); + } + } else { + self.stopDrag(); + } + e.stopPropagation = true; + return false; + }; + + this.stopDrag = function(e) { + if (self.dragActive) { + self.removeClass(self.lastSound._data.oControls,'dragging'); + if (!isTouchDevice) { + _event.remove(document,'mousemove',self.handleMouseMove); + } else { + _event.remove(document,'touchmove',self.handleMouseMove); + } + if (!pl.hasClass(self.lastSound._data.oLI,self.css.sPaused)) { + self.lastSound.resume(); + } + self.dragActive = false; + return self.stopEvent(e); + } + }; + + this.handleStatusClick = function(e) { + self.setPosition(e); + if (!pl.hasClass(self.lastSound._data.oLI,self.css.sPaused)) { + self.resume(); + } + return self.stopEvent(e); + }; + + this.stopEvent = function(e) { + if (typeof e !== 'undefined') { + if (typeof e.preventDefault !== 'undefined') { + e.preventDefault(); + } else { + e.stopPropagation = true; + e.returnValue = false; + } + } + return false; + }; + + this.setPosition = function(e) { + // called from slider control + var oThis = self.getTheDamnTarget(e), + x, oControl, oSound, nMsecOffset; + if (!oThis) { + return true; + } + oControl = oThis; + while (!self.hasClass(oControl,'controls') && oControl.parentNode) { + oControl = oControl.parentNode; + } + oSound = self.lastSound; + x = parseInt(e.clientX,10); + // play sound at this position + nMsecOffset = Math.floor((x-self.getOffX(oControl)-4)/(oControl.offsetWidth)*self.getDurationEstimate(oSound)); + if (!isNaN(nMsecOffset)) { + nMsecOffset = Math.min(nMsecOffset,oSound.duration); + } + if (!isNaN(nMsecOffset)) { + oSound.setPosition(nMsecOffset); + } + }; + + this.stopSound = function(oSound) { + sm._writeDebug('stopping sound: '+oSound.id); + sm.stop(oSound.id); + if (!isTouchDevice) { // iOS 4.2+ security blocks onfinish() -> playNext() if we set a .src in-between(?) + sm.unload(oSound.id); + } + }; + + this.getDurationEstimate = function(oSound) { + if (oSound.instanceOptions.isMovieStar) { + return (oSound.duration); + } else { + return (!oSound._data.metadata || !oSound._data.metadata.data.givenDuration ? (oSound.durationEstimate||0) : oSound._data.metadata.data.givenDuration); + } + }; + + this.createVUData = function() { + + var i=0, j=0, + canvas = vuDataCanvas.getContext('2d'), + vuGrad = canvas.createLinearGradient(0, 16, 0, 0), + bgGrad, outline; + + vuGrad.addColorStop(0,'rgb(0,192,0)'); + vuGrad.addColorStop(0.30,'rgb(0,255,0)'); + vuGrad.addColorStop(0.625,'rgb(255,255,0)'); + vuGrad.addColorStop(0.85,'rgb(255,0,0)'); + bgGrad = canvas.createLinearGradient(0, 16, 0, 0); + outline = 'rgba(0,0,0,0.2)'; + bgGrad.addColorStop(0,outline); + bgGrad.addColorStop(1,'rgba(0,0,0,0.5)'); + for (i=0; i<16; i++) { + self.vuMeterData[i] = []; + } + for (i=0; i<16; i++) { + for (j=0; j<16; j++) { + // reset/erase canvas + vuDataCanvas.setAttribute('width',16); + vuDataCanvas.setAttribute('height',16); + // draw new stuffs + canvas.fillStyle = bgGrad; + canvas.fillRect(0,0,7,15); + canvas.fillRect(8,0,7,15); + /* + // shadow + canvas.fillStyle = 'rgba(0,0,0,0.1)'; + canvas.fillRect(1,15-i,7,17-(17-i)); + canvas.fillRect(9,15-j,7,17-(17-j)); + */ + canvas.fillStyle = vuGrad; + canvas.fillRect(0,15-i,7,16-(16-i)); + canvas.fillRect(8,15-j,7,16-(16-j)); + // and now, clear out some bits. + canvas.clearRect(0,3,16,1); + canvas.clearRect(0,7,16,1); + canvas.clearRect(0,11,16,1); + self.vuMeterData[i][j] = vuDataCanvas.toDataURL('image/png'); + // for debugging VU images + /* + var o = document.createElement('img'); + o.style.marginRight = '5px'; + o.src = self.vuMeterData[i][j]; + document.documentElement.appendChild(o); + */ + } + } + + }; + + this.testCanvas = function() { + // canvas + toDataURL(); + var c = document.createElement('canvas'), + ctx = null, ok; + if (!c || typeof c.getContext === 'undefined') { + return null; + } + ctx = c.getContext('2d'); + if (!ctx || typeof c.toDataURL !== 'function') { + return null; + } + // just in case.. + try { + ok = c.toDataURL('image/png'); + } catch(e) { + // no canvas or no toDataURL() + return null; + } + // assume we're all good. + return c; + }; + + this.initItem = function(oNode) { + if (!oNode.id) { + oNode.id = 'pagePlayerMP3Sound'+(self.soundCount++); + } + self.addClass(oNode,self.css.sDefault); // add default CSS decoration + }; + + this.initUL = function(oULNode) { + // set up graph box stuffs + if (sm.flashVersion >= 9) { + self.addClass(oULNode,self.cssBase); + } + }; + + this.init = function(oConfig) { + + if (oConfig) { + // allow overriding via arguments object + sm._writeDebug('pagePlayer.init(): Using custom configuration'); + this.config = this._mergeObjects(oConfig,this.config); + } else { + sm._writeDebug('pagePlayer.init(): Using default configuration'); + } + + var i, spectrumBox, sbC, oF, oClone, oTiming; + + // apply externally-defined override, if applicable + this.cssBase = []; // optional features added to ul.playlist + + // apply some items to SM2 + sm.useFlashBlock = true; + + if (sm.flashVersion >= 9) { + + sm.defaultOptions.usePeakData = this.config.usePeakData; + sm.defaultOptions.useWaveformData = this.config.useWaveformData; + sm.defaultOptions.useEQData = this.config.useEQData; + + if (this.config.usePeakData) { + this.cssBase.push('use-peak'); + } + + if (this.config.useWaveformData || this.config.useEQData) { + this.cssBase.push('use-spectrum'); + } + + this.cssBase = this.cssBase.join(' '); + + if (this.config.useFavIcon) { + vuDataCanvas = self.testCanvas(); + if (vuDataCanvas && supportsFavicon) { + // these browsers support dynamically-updating the favicon + self.createVUData(); + } else { + // browser doesn't support doing this + this.config.useFavIcon = false; + } + } + + } else if (this.config.usePeakData || this.config.useWaveformData || this.config.useEQData) { + + sm._writeDebug('Page player: Note: soundManager.flashVersion = 9 is required for peak/waveform/EQ features.'); + + } + + controlTemplate = document.createElement('div'); + + controlTemplate.innerHTML = [ + + // control markup inserted dynamically after each page player link + // if you want to change the UI layout, this is the place to do it. + + '
    ', + '
    ', + '
    ', + '
    ', + '
    ', + '
    ', + + '
    ', + '
    ', + ' %s1 / %s2', + '
    ', + '
    ', + + '
    ', + '
    ', + '
    ', + + '
    ', + '
    ', + '
    ', + '
    ', + '
    ' + + ].join('\n'); + + if (sm.flashVersion >= 9) { + + // create the spectrum box ish + spectrumContainer = self.select('spectrum-container',controlTemplate); + + // take out of template, too + spectrumContainer = controlTemplate.removeChild(spectrumContainer); + + spectrumBox = self.select('spectrum-box',spectrumContainer); + + sbC = spectrumBox.getElementsByTagName('div')[0]; + oF = document.createDocumentFragment(); + oClone = null; + for (i=256; i--;) { + oClone = sbC.cloneNode(false); + oClone.style.left = (i)+'px'; + oF.appendChild(oClone); + } + spectrumBox.removeChild(sbC); + spectrumBox.appendChild(oF); + + } else { + + // flash 8-only, take out the spectrum container and peak elements + controlTemplate.removeChild(self.select('spectrum-container',controlTemplate)); + controlTemplate.removeChild(self.select('peak',controlTemplate)); + + } + + self.oControls = controlTemplate.cloneNode(true); + + oTiming = self.select('timing-data',controlTemplate); + self.strings.timing = oTiming.innerHTML; + oTiming.innerHTML = ''; + oTiming.id = ''; + + function doEvents(action) { // action: add / remove + + _event[action](document,'click',self.handleClick); + + if (!isTouchDevice) { + _event[action](document,'mousedown',self.handleMouseDown); + _event[action](document,'mouseup',self.stopDrag); + } else { + _event[action](document,'touchstart',self.handleMouseDown); + _event[action](document,'touchend',self.stopDrag); + } + + _event[action](window, 'unload', cleanup); + + } + + cleanup = function() { + doEvents('remove'); + }; + + doEvents('add'); + + sm._writeDebug('pagePlayer.init(): Ready',1); + + if (self.config.autoStart) { + // grab the first ul.playlist link + pl.handleClick({target:pl.getByClassName('playlist', 'ul')[0].getElementsByTagName('a')[0]}); + } + + }; + +} + +soundManager.useFlashBlock = true; + +soundManager.onready(function() { + pagePlayer = new PagePlayer(); + pagePlayer.init(typeof PP_CONFIG !== 'undefined' ? PP_CONFIG : null); +}); \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/xbm-test.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/xbm-test.html new file mode 100755 index 00000000..a9bcf6d2 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/page-player/xbm-test.html @@ -0,0 +1,23 @@ + + +XBM image test + + + + + +

    XBM (X-Bitmap) Support Test

    + +

    Firefox 3.6 dropped support for XBM images citing lack of use (and a security hole or two), so SoundManager 2 has moved to using canvas for rendering favicon images on-the-fly.

    + +

    +XBM with data URI (may be broken image, invalid etc.):
    + +

    + +

    See the SoundManager 2 demo with experimental favicon animation feature enabled, and the related screenshot showing the different states.

    + +

    XBM (X-Bitmap) is neat in that it's an ASCII, C-style declarative image format, and is quite old. See XBM on Wikipedia for more.

    + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/basic.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/basic.html new file mode 100755 index 00000000..e41a20bf --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/basic.html @@ -0,0 +1,61 @@ + + + +SoundManager 2 Demo: Play MP3 Links on a page + + + + + + + + + + +

    SoundManager 2 / page as a playlist, basic template

    + +

    Don't forget to set debugMode = false within inlineplayer.js to disable debug output.

    + +
    + +
    + + + +

    SoundManager 2 project home

    + + + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/css/inlineplayer.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/css/inlineplayer.css new file mode 100755 index 00000000..69e05341 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/css/inlineplayer.css @@ -0,0 +1,210 @@ +/* + + SoundManager 2: In-page MP3 player example + ------------------------------------------ + + Clicks on links to MP3s are intercepted via JS, calls are + made to SoundManager to load/play sounds. CSS classes are + appended to the link, which are used to highlight the + current play state and so on. + + Class names are applied in addition to "sm2_link" base. + + Default: + + sm2_link + + Additional states: + + sm2_playing + sm2_paused + + eg. + + + some.mp3 + + + some.mp3 + + + Note you don't require ul.graphic / ul.flat etc. for your use + if only using one style on a page. You can just use .sm2_link{} + and so on, but isolate the CSS you want. + + Side note: Would do multiple class definitions eg. + + a.sm2_default.sm2_playing{} + + .. except IE 6 has a parsing bug which may break behaviour, + applying sm2_playing {} even when the class is set to sm2_default. + + + If you want to make your own UI from scratch, here is the base: + + Default + hover state, "click to play": + + a.sm2_link {} + a.sm2_link:hover {} + + Playing + hover state, "click to pause": + + a.sm2_playing {} + a.sm2_playing:hover {} + + Paused + hover state, "click to resume": + + a.sm2_paused {} + a.sm2_paused:hover {} + + +*/ + +/* two different list types */ + +ul.flat { + list-style-type:none; + padding-left:0px; +} + +ul.flat li, +ul.graphic li { + padding-bottom:1px; +} + +ul.flat li a { + display:inline-block; + padding:2px 4px 2px 4px; +} + +ul.graphic { + list-style-type:none; + padding-left:0px; + margin-left:0px; +} + +/* background-image-based CSS3 example */ + +ul.graphic { + list-style-type:none; + margin:0px; + padding:0px; +} + +ul.graphic li { + margin-bottom:2px; +} + +ul.graphic li a, +ul.graphic li a.sm2_link { + /* assume all items will be sounds rather than wait for onload etc. in this example.. may differ for your uses. */ + display:inline-block; + padding-left:22px; + min-height:16px; + vertical-align: middle; + background-color:#336699; + border-radius:3px; + padding:3px 3px 3px 25px; + min-width:19em; + _width:19em; /* IE 6 */ + text-decoration:none; + font-weight:normal; + color:#f6f9ff; +} + +ul.graphic li a.sm2_link { + /* safari 3.1+ fun (or, proprietary crap. TBD.) */ + -webkit-transition-property: hover; + -webkit-transition: background-color 0.15s linear; + -moz-transition: background-color 0.15s linear 0s; /* firefox 4 */ + -o-transition-property: background-color; /* opera 10.5 */ + -o-transition-duration: 0.15s; +} + +ul.graphic li a, /* use a.sm2_link {} if you want play icons showing only if SM2 is supported */ +ul.graphic li a.sm2_paused:hover, +ul.graphic li a.sm2_link:hover { + background-image:url(../image/icon_play.png); + background-position:3px 50%; + background-repeat:no-repeat; + _background-image:url(../image/icon_play.gif); /* IE 6 */ +} + +ul.graphic li a.sm2_link:hover { + /* default hover color, if you'd like.. */ + background-color:#003366; + color:#fff; +} + +ul.graphic li a.sm2_paused { + background-color:#999; +} + +ul.graphic li a.sm2_paused:hover { + background:#003366 url(../image/icon_play.png) no-repeat 3px 50%; + _background-image:url(../image/icon_play.gif); +} + +ul.graphic li a.sm2_playing, +ul.graphic li a.sm2_playing:hover { + background:#003366 url(../image/icon_pause.png) no-repeat 3px 50%; + _background-image:url(../image/icon_pause.gif); + text-decoration:none; +} + +/* hide button while playing? +ul.graphic li a.sm2_playing { + background-image:none; +} +*/ + +body #sm2-container object, +body #sm2-container embed { + /* + flashblock handling: hide SWF off-screen by default (until blocked timeout case.) + include body prefix to ensure override of flashblock.css. + */ + + left:-9999em; + top:-9999em; +} + +/* flat CSS example */ + +ul.flat a.sm2_link { + /* default state: "a playable link" */ + border-left:6px solid #999; + padding-left:4px; + padding-right:4px; +} + +ul.flat a.sm2_link:hover { + /* default (inactive) hover state */ + border-left-color:#333; +} + + +ul.flat a.sm2_playing { + /* "now playing" */ + border-left-color:#6666ff; + background-color:#000; + color:#fff; + text-decoration:none; +} + +ul.flat a.sm2_playing:hover { + /* "clicking will now pause" */ + border-left-color:#cc3333; +} + +ul.flat a.sm2_paused { + /* "paused state" */ + background-color:#666; + color:#fff; + text-decoration:none; +} + +ul.flat a.sm2_paused:hover { + /* "clicking will resume" */ + border-left-color:#33cc33; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/icon_pause.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/icon_pause.gif new file mode 100755 index 00000000..7f3443d9 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/icon_pause.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/icon_pause.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/icon_pause.png new file mode 100755 index 00000000..846dd8ad Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/icon_pause.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/icon_play.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/icon_play.gif new file mode 100755 index 00000000..39543369 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/icon_play.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/icon_play.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/icon_play.png new file mode 100755 index 00000000..af265a7a Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/icon_play.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/test.gif b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/test.gif new file mode 100755 index 00000000..45d7f41e Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/image/test.gif differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/index.html new file mode 100755 index 00000000..3bd03460 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/index.html @@ -0,0 +1,227 @@ + + + +SoundManager 2 Demo: Play MP3 Links on a page + + + + + + + + + + +
    + +

    SoundManager 2 / Playable MP3 links

    + +

    Inline MP3 Player Example: Fancy* CSS 3 version

    +

    *CSS 3 border-radius supported only by Firefox 2.x+, Safari (2.x?) - sadly, not IE 8.

    + +
    + +
    + + + +

    How It Works

    + +
      +
    • Lightweight (single JS click event handler)
    • +
    • Uses existing SoundManager 2 API
    • +
    • CSS for UI, easy to modify to taste
    • +
    + +

    This example uses SoundManager 2 to find links to MP3 files, and makes them playable "in-place" on a page. The script assigns CSS classes to links to indicate their state (playing/paused, etc.)

    +

    Links pointing to MP3s are assigned an onclick handler which intercepts the click (preventing the browser from following the link and unloading the page. SM2 will then create sound objects as needed to play the MP3s.

    + +

    Static Examples

    +

    CSS classes are dynamically applied as follows:

    + +

    :hover effects are also active.

    + +

    Flat (CSS-only) style

    + + + +

    Static Examples

    + + + +

    Forcing play (or exclusion) of links

    + +

    If you have a link to a PHP file that serves MP3 files eg. /music.php?fileID=123, it won't be picked up by the script as containing a known, playable .mp3 extension. To tell the script it should be treated as playable, include a type="audio/mpeg" MIME type attribute, or CSS class="inline-playable" in the link. eg:

    + +

    + <a href="/music.php?fileID=123" type="audio/mpeg">A song</a> +

    + +

    Or via CSS class name:

    + <a href="/music.php?fileID=123" class="inline-playable">A song</a> +

    + +

    + To exclude an .MP3 or otherwise-playable link from being handled by SM2, use class="inline-exclude" and it will be ignored. +

    + +

    + SoundManager 2 project page (not an MP3 link) +

    + +

    Basic CSS

    + +
    + If you want to make your own UI from scratch, here is the base:
    +
    + Default + hover state, "click to play":
    +
    + a.sm2_link {}
    + a.sm2_link:hover {}
    +
    + Playing + hover state, "click to pause":
    +
    + a.sm2_playing {}
    + a.sm2_playing:hover {}
    +
    + Paused + hover state, "click to resume":
    +
    + a.sm2_paused {}
    + a.sm2_paused:hover {}
    +
    + +

    Other Options

    + +

    By default, one sound will be played at a time; you can easily change a "config" object value to turn on playlist-like behaviour (i.e., play the next MP3 when the current one finishes.)

    + +
    +// (within inlineplayer.js)
    +this.config = {
    + playNext: false // stop after one sound, or play through list until end
    +}
    +
    + +

    I'd like to use this.

    +

    See this basic demo for reference.

    + +
    + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/script/inlineplayer.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/script/inlineplayer.js new file mode 100755 index 00000000..0b1f977d --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/play-mp3-links/script/inlineplayer.js @@ -0,0 +1,256 @@ +/** + * + * SoundManager 2 Demo: Play MP3 links "in-place" + * ---------------------------------------------- + * + * http://schillmania.com/projects/soundmanager2/ + * + * A simple demo making MP3s playable "inline" + * and easily styled/customizable via CSS. + * + * Requires SoundManager 2 Javascript API. + * + */ + +function InlinePlayer() { + var self = this; + var pl = this; + var sm = soundManager; // soundManager instance + var isIE = (navigator.userAgent.match(/msie/i)); + this.playableClass = 'inline-playable'; // CSS class for forcing a link to be playable (eg. doesn't have .MP3 in it) + this.excludeClass = 'inline-exclude'; // CSS class for ignoring MP3 links + this.links = []; + this.sounds = []; + this.soundsByURL = []; + this.indexByURL = []; + this.lastSound = null; + this.soundCount = 0; + + this.config = { + playNext: false, // stop after one sound, or play through list until end + autoPlay: false // start playing the first sound right away + } + + this.css = { + // CSS class names appended to link during various states + sDefault: 'sm2_link', // default state + sLoading: 'sm2_loading', + sPlaying: 'sm2_playing', + sPaused: 'sm2_paused' + } + + this.addEventHandler = (typeof window.addEventListener !== 'undefined' ? function(o, evtName, evtHandler) { + return o.addEventListener(evtName,evtHandler,false); + } : function(o, evtName, evtHandler) { + o.attachEvent('on'+evtName,evtHandler); + }); + + this.removeEventHandler = (typeof window.removeEventListener !== 'undefined' ? function(o, evtName, evtHandler) { + return o.removeEventListener(evtName,evtHandler,false); + } : function(o, evtName, evtHandler) { + return o.detachEvent('on'+evtName,evtHandler); + }); + + this.classContains = function(o,cStr) { + return (typeof(o.className)!='undefined'?o.className.match(new RegExp('(\\s|^)'+cStr+'(\\s|$)')):false); + } + + this.addClass = function(o,cStr) { + if (!o || !cStr || self.classContains(o,cStr)) return false; + o.className = (o.className?o.className+' ':'')+cStr; + } + + this.removeClass = function(o,cStr) { + if (!o || !cStr || !self.classContains(o,cStr)) return false; + o.className = o.className.replace(new RegExp('( '+cStr+')|('+cStr+')','g'),''); + } + + this.getSoundByURL = function(sURL) { + return (typeof self.soundsByURL[sURL] != 'undefined'?self.soundsByURL[sURL]:null); + } + + this.isChildOfNode = function(o,sNodeName) { + if (!o || !o.parentNode) { + return false; + } + sNodeName = sNodeName.toLowerCase(); + do { + o = o.parentNode; + } while (o && o.parentNode && o.nodeName.toLowerCase() != sNodeName); + return (o.nodeName.toLowerCase() == sNodeName?o:null); + } + + this.events = { + + // handlers for sound events as they're started/stopped/played + + play: function() { + pl.removeClass(this._data.oLink,this._data.className); + this._data.className = pl.css.sPlaying; + pl.addClass(this._data.oLink,this._data.className); + }, + + stop: function() { + pl.removeClass(this._data.oLink,this._data.className); + this._data.className = ''; + }, + + pause: function() { + pl.removeClass(this._data.oLink,this._data.className); + this._data.className = pl.css.sPaused; + pl.addClass(this._data.oLink,this._data.className); + }, + + resume: function() { + pl.removeClass(this._data.oLink,this._data.className); + this._data.className = pl.css.sPlaying; + pl.addClass(this._data.oLink,this._data.className); + }, + + finish: function() { + pl.removeClass(this._data.oLink,this._data.className); + this._data.className = ''; + if (pl.config.playNext) { + var nextLink = (pl.indexByURL[this._data.oLink.href]+1); + if (nextLink1) { + // ignore right-click + return true; + } + var o = self.getTheDamnLink(e); + if (o.nodeName.toLowerCase() != 'a') { + o = self.isChildOfNode(o,'a'); + if (!o) return true; + } + var sURL = o.getAttribute('href'); + if (!o.href || (!sm.canPlayLink(o) && !self.classContains(o,self.playableClass)) || self.classContains(o,self.excludeClass)) { + return true; // pass-thru for non-MP3/non-links + } + var soundURL = (o.href); + var thisSound = self.getSoundByURL(soundURL); + if (thisSound) { + // already exists + if (thisSound == self.lastSound) { + // and was playing (or paused) + thisSound.togglePause(); + } else { + // different sound + sm._writeDebug('sound different than last sound: '+self.lastSound.id); + if (self.lastSound) { + self.stopSound(self.lastSound); + } + thisSound.togglePause(); // start playing current + } + } else { + // stop last sound + if (self.lastSound) { + self.stopSound(self.lastSound); + } + // create sound + thisSound = sm.createSound({ + id:'inlineMP3Sound'+(self.soundCount++), + url:soundURL, + onplay:self.events.play, + onstop:self.events.stop, + onpause:self.events.pause, + onresume:self.events.resume, + onfinish:self.events.finish, + type:(o.type||null) + }); + // tack on some custom data + thisSound._data = { + oLink: o, // DOM node for reference within SM2 object event handlers + className: self.css.sPlaying + }; + self.soundsByURL[soundURL] = thisSound; + self.sounds.push(thisSound); + thisSound.play(); + } + + self.lastSound = thisSound; // reference for next call + + if (typeof e != 'undefined' && typeof e.preventDefault != 'undefined') { + e.preventDefault(); + } else { + event.returnValue = false; + } + return false; + } + + this.stopSound = function(oSound) { + soundManager.stop(oSound.id); + soundManager.unload(oSound.id); + } + + this.init = function() { + sm._writeDebug('inlinePlayer.init()'); + var oLinks = document.getElementsByTagName('a'); + // grab all links, look for .mp3 + var foundItems = 0; + for (var i=0, j=oLinks.length; i0) { + self.addEventHandler(document,'click',self.handleClick); + if (self.config.autoPlay) { + self.handleClick({target:self.links[0],preventDefault:function(){}}); + } + } + sm._writeDebug('inlinePlayer.init(): Found '+foundItems+' relevant items.'); + } + + this.init(); + +} + +var inlinePlayer = null; + +soundManager.setup({ + // disable or enable debug output + debugMode: true, + // use HTML5 audio for MP3/MP4, if available + preferFlash: false, + useFlashBlock: true, + // path to directory containing SM2 SWF + url: '../../swf/', + // optional: enable MPEG-4/AAC support (requires flash 9) + flashVersion: 9 +}); + +// ---- + +soundManager.onready(function() { + // soundManager.createSound() etc. may now be called + inlinePlayer = new InlinePlayer(); +}); + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/deferred-example.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/deferred-example.html new file mode 100755 index 00000000..831a090e --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/deferred-example.html @@ -0,0 +1,243 @@ + + + +SoundManager 2: Deferred loading / Lazy-loading / Dynamic script loading Example + + + + + + + + + + + + +
    + +

    SoundManager 2: Lazy Loading Example

    +

    This is an example of dynamically loading SoundManager 2 using JS, after window.onload() has fired.

    + +

    How it works

    +

    This page waits until window.onload(), delays 1 second and loads soundmanager2.js, which should then start up.

    +

    Behaviour note: SM2 will not automatically start if it is loaded at or after the DOMContentLoaded event has fired, which may be common with most JS loaders.

    +

    However, SM2 will try to start once soundManager.setup() is called and a url attribute has been provided.

    +

    If you want to ensure that SM2 starts after setup, you can call soundManager.beginDelayedInit() - this should be safe to call after DOMContentLoaded has fired.

    + +

    Pseudo-code Example

    + +

    Once SM2 has been dymamically loaded, you can call its setup() method. Passing a url attribute will trigger the initialization process.

    + +
    loadJS('soundmanager2.js', function() {
    +  soundManager.setup({
    +    url: '/path/to/swfs/',
    +    onready: function() {
    +      // good to go!
    +      // soundManager.createSound(...), etc.
    +    }
    +  });
    +});
    + +

    Live Example

    + +

    SoundManager 2 status: Waiting for window.onload()...

    + +
    /**
    + * Dynamic script loading helper (example)
    + * Normalizes good browser onload() vs. IE readyState weirdness
    + */
    +
    +function loadScript(sURL, onLoad) {
    +
    +  function loadScriptHandler() {
    +    var rs = this.readyState;
    +    if (rs == 'loaded' || rs == 'complete') {
    +      this.onreadystatechange = null;
    +      this.onload = null;
    +      if (onLoad) {
    +        onLoad();
    +      }
    +    }
    +  }
    +
    +  function scriptOnload() {
    +    this.onreadystatechange = null;
    +    this.onload = null;
    +    window.setTimeout(onLoad,20);
    +  }
    +
    +  var oS = document.createElement('script');
    +  oS.type = 'text/javascript';
    +  if (onLoad) {
    +    oS.onreadystatechange = loadScriptHandler;
    +    oS.onload = scriptOnload;
    +  }
    +  oS.src = sURL;
    +  document.getElementsByTagName('head')[0].appendChild(oS);
    +
    +}
    +
    +// Wait for window load, then load soundmanager2.js, let it start and play a test sound
    +
    +window.onload = function() {
    +
    +  msg('Window loaded, waiting 1 second...');
    +
    +  setTimeout(function() {
    +
    +    msg('Loading soundmanager2.js...');
    +
    +    loadScript('../../script/soundmanager2.js', function() {
    +
    +      // SM2 script has loaded
    +
    +      window.setTimeout(function() {
    +        msg('soundmanager2.js loaded, delaying before setup()...');
    +      }, 500);
    +
    +      window.setTimeout(function() {
    +
    +        soundManager.setup({
    +          url: '../../swf/',
    +          onready: function() {
    +            soundManager.createSound({
    +              id: 'foo',
    +              url: '../_mp3/mouseover.mp3'
    +            }).play();
    +            msg('Started OK');
    +          },
    +          ontimeout: function() {
    +            msg('Loaded OK, but unable to start: unsupported/flash blocked, etc.');
    +          }
    +        });
    +
    +        // ensure start-up in case document.readyState and/or DOMContentLoaded are unavailable
    +        soundManager.beginDelayedInit();
    +
    +      }, 1000);
    +
    +    });
    +
    +  }, 1000);
    +
    +}
    +
    + +

    Handling flash blockers

    +

    It's good to let users see the flash component of SM2, so those with flash blockers can unblock it and allow SM2 to start. For more info on this, see the Flashblock example.

    + +

    Preventing auto-init using SM2_DEFER

    +

    If you want to completely defer the normal start-up of SM2 and call the SoundManager() constructor yourself, you can declare an SM2_DEFER global and set it to true. See the SM2_DEFER example for details.

    + +

    Disabling debug output

    +

    SoundManager 2 will write to a debug <div> element or a javascript console if available, by default. To disable it, simply set the relevant property to false:

    +soundManager.setup({ debugMode: false }); +

    To see related configuration code, refer to the source of this page which basically does all of the above "for real."

    +

    Troubleshooting

    +

    If SM2 is failing to start and throwing errors due to flash security, timeouts or other issues, check out the troubleshooting tool which can help you fix things.

    +

    No-debug, compressed version of soundmanager2.js

    +

    You can also use the "minified" (60% smaller) version of SM2, which has debug output and comments removed for you: soundmanager2-nodebug-jsmin.js. If you can, serve this with gzip compression for even greater bandwidth savings!

    + +
    + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/html5-dtd-test.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/html5-dtd-test.html new file mode 100755 index 00000000..d4357cd9 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/html5-dtd-test.html @@ -0,0 +1,87 @@ + + + +SoundManager 2: HTML 5 DTD test + + + + + + + + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/index.html new file mode 100755 index 00000000..c7a62d49 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/index.html @@ -0,0 +1,206 @@ + + + +SoundManager 2 Template + + + + + + + + + + + + + + + + + + + + + +
    + +

    SoundManager 2 Template Example

    +

    This page covers the basics of adding SoundManager 2 to your project.

    + +

    How it works

    +

    The minimal code needed to get SoundManager 2 going is below, with configurable parts highlighted. You can copy/paste it to get started. This page is also running the template code; If available, look at your JavaScript console for debug output from SM2.

    + +

    Dependencies

    + +

    You'll need to copy the files inside the script/ and swf/ subdirectories included with the SoundManager 2 package into your project.

    + +
      +
    • + soundmanager2/ +
        +
      • + script/ - API core, soundmanager2.js +
      • +
      • + swf/ - API core, SoundManager 2 .SWF files +
      • +
      +
    • +
    + + +

    At the bare minimum, you will need soundmanager2.js, soundmanager2.swf and soundmanager2_debug.swf for the default flash 8-based configuration. (Optionally, SM2 can use a Flash 9-based audio API which has MP4 support, data visualization and a few other features.)

    + +

    Template Code: Basic Version

    + +

    This is a compact version of the template you can copy/paste to get started. For new users, see the commented version.

    + +
    <script src="/path/to/soundmanager2.js"></script>
    +<script>
    +soundManager.setup({
    +  url: '/path/to/swf-files/',
    +  onready: function() {
    +    var mySound = soundManager.createSound({
    +      id: 'aSound',
    +      url: '/path/to/an.mp3'
    +    });
    +    mySound.play();
    +  },
    +  ontimeout: function() {
    +    // Hrmm, SM2 could not start. Missing SWF? Flash blocked? Show an error, etc.?
    +  }
    +});
    +</script>
    + + + +

    Template Code: Commented Version

    + +
    <!-- include SM2 library (see builds for optimized versions) -->
    +<script type="text/javascript" src="/path/to/soundmanager2.js"></script>
    +
    +<!-- configure SM2 for your use -->
    +<script type="text/javascript">
    +
    +soundManager.setup({
    +
    +  // location: path to SWF files, as needed (SWF file name is appended later.)
    +
    +  url: '/path/to/swf-files/',
    +
    +  // optional: version of SM2 flash audio API to use (8 or 9; default is 8 if omitted, OK for most use cases.)
    +  // flashVersion: 9,
    +
    +  // use soundmanager2-nodebug-jsmin.js, or disable debug mode (enabled by default) after development/testing
    +  // debugMode: false,
    +
    +  // good to go: the onready() callback
    +
    +  onready: function() {
    +
    +    // SM2 has started - now you can create and play sounds!
    +
    +    var mySound = soundManager.createSound({
    +      id: 'aSound', // optional: provide your own unique id
    +      url: '/path/to/an.mp3'
    +      // onload: function() { console.log('sound loaded!', this); }
    +      // other options here..
    +    });
    +
    +    mySound.play();
    +
    +  },
    +
    +  // optional: ontimeout() callback for handling start-up failure
    +
    +  ontimeout: function() {
    +
    +    // Hrmm, SM2 could not start. Missing SWF? Flash blocked? No HTML5 audio support? Show an error, etc.?
    +    // See the flashblock demo when you want to start getting fancy.
    +
    +  }
    +
    +});
    +
    +</script>
    + +

    HTML5 Support Notes

    +

    Read up on HTML5 audio support, if you're feeling adventurous. iPad/iPhone and devices without flash installed will always use 100% HTML5 mode. By default, SM2 will use 100% HTML5 mode where supported. If you want to override this, specify preferFlash: true and Flash will be used (if present) for playing MP3 and MP4 (AAC) formats.

    + +

    Handling flash blockers

    +

    It's good to let users see the flash component of SM2, so those with flash blockers can unblock it and allow SM2 to start. For more info, see the Flashblock example.

    + +

    Disabling debug output

    +

    SoundManager 2 will write debug output via console.log() if available, by default. To disable it, simply specify debugMode: false.

    +

    You can also write HTML-based debug output to the DOM via consoleOnly: false and/or useConsole: false.

    +

    To see related configuration code, refer to the source of this page which basically does all of the above "for real."

    + +

    Troubleshooting ("failed to start": Viewing offline, missing SWF, flash blockers etc.)

    +

    If SM2 is failing to start and throwing errors due to flash security, timeouts or other issues, check out the troubleshooting tool for tips.

    + +

    No-debug, compressed version of soundmanager2.js

    +

    Once development is finished, you can also use the "minified" (down to ~8% of original size with gzip!) version of SM2, which has debug output and comments removed for you: soundmanager2-nodebug-jsmin.js. Serve with gzip compression wherever possible for best bandwidth savings.

    + +
    + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/sm2_defer-example.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/sm2_defer-example.html new file mode 100755 index 00000000..526f43eb --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/sm2_defer-example.html @@ -0,0 +1,128 @@ + + + +SoundManager 2: SM2_DEFER Example + + + + + + + + + + + + + + + + + + +
    + +

    SoundManager 2: SM2_DEFER Example

    + +

    This is an example of manually starting SoundManager 2. If you want to pre-load the SM2 script up front and have its onready() events etc. fire much later without delay, this approach makes sense. Otherwise, it's better to lazy-load or simply load SM2 normally as an external script without deferring.

    + +

    How it works

    +

    By default, SM2 will call its own SoundManager() constructor inline and will try to initialize ASAP. This page defines a global boolean - window.SM2_DEFER = true; - before loading soundmanager2.js, preventing the constructor from being called.

    + +

    Some time later, you must call soundManager = new SoundManager(); manually and set things like soundManager.url etc. Finally, you may then call soundManager.beginDelayedInit() to kick off the initialization process. SM2 should then start as usual.

    + +

    Example code

    + +
    <script type="text/javascript">
    +
    +/*
    + * Firstly, define SM2_DEFER and set it to true *before* we load soundmanager2.js.
    + * This prevents the SoundManager() constructor from being called immediately.
    + * SM2_DEFER should be assigned within the global scope.
    +*/
    +
    +window.SM2_DEFER = true;
    +
    +</script>
    +
    +<!-- Now, load soundmanager2.js as we normally would. -->
    +<script type="text/javascript" src="../../script/soundmanager2.js"></script>
    +
    +<!-- "Some time later", window.onload() may have fired and you now want to start SM2, etc... -->
    +<script type="text/javascript">
    +
    +// for example purposes, we'll wait until window.onload before starting things.
    +window.onload = function() {
    +
    +  /*
    +   * Now that the SM2 constructor is defined, you can call the constructor,
    +   * set the options and "kick-start" SM2's init process, and it should work as normal.
    +   * WARNING: Do not call beginDelayedInit() before "DOM ready", or things will fail.
    +  */
    +
    +  // construct the instance (must be named soundManager, and scoped globally)
    +  window.soundManager = new SoundManager();
    +
    +  // assign flash url, flashVersion and other SM2 options as usual
    +  soundManager.setup({
    +    // path to directory containing SM2 SWF
    +    url: '/path/to/swfs/',
    +    flashVersion: 9
    +    // etc...
    +  });
    +
    +  // finally, kick-start the init process.
    +  // (old IE etc. may miss domloaded/ready/window.load if they've already fired.)
    +  soundManager.beginDelayedInit();
    +
    +}
    +
    +</script>
    + +
    + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/template.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/template.css new file mode 100755 index 00000000..59ff8a6a --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/template.css @@ -0,0 +1,162 @@ +/** + * + * SoundManager 2: TEMPLATE EXAMPLE / DEMO ONLY, just to make the demo page pretty. + * + * You don't need this stuff for SM2 to work. :) + * + */ + +body { + font-size:75%; + background: #fff url(../../demo/_image/noise.png); +} + +pre { + padding: 0.5em; + background: #f9f9f9; +} + +code, pre { + font-family:"lucida console",monaco,courier,system; + font-size:100%; + color:#2233cc; +} + +em em { + font-weight:normal; + font-style:normal; + color:#339933; +} + +h1, +h2.special { + letter-spacing: -0.005em; +} + +h1, h2, h3, h4 { + font-family:"helvetica neue",helvetica,verdana,arial,tahoma,"sans serif"; + font-size:1em; + margin:0px; + padding:0px; + vertical-align:middle; +} + +h1 { + font-size:2em; + border-bottom: 1px dotted #999; +} + +h2 { + font-family:"helvetica neue",helvetica,arial,verdana,tahoma,"sans serif"; + font-size:1.5em; + margin-top: 1.5em; + margin-bottom: 0px; +} + +h2 code { + font-size: 85%; +} + +h3 { + font-size:1.17em; + border-bottom:1px solid #ccc; + padding-bottom:0.25em; + margin-top:1.5em; +} + +h4 { + margin:1.5em 0px 0.5em 0px; + font-size:1.1em; +} + + +p, +li { + font:normal 1em verdana,tahoma,arial,"sans serif"; + line-height: 1.4em; +} + +code span, +pre span { + color:#666; +} + +ul.file-structure ul { + padding-left:1.5em; +} + +ul.file-structure li { + list-style-type:square; + margin-top:0.25em; + margin-left:0px; +} + +ul.file-structure li span { + color:#999; +} + +/* re-used bits from index.css */ + +pre code { + font-size:1em; +} + +pre { + white-space:-moz-pre-wrap; + white-space:pre-wrap; + word-wrap:break-word; /* IE */ +} + +ul.code-block em, +pre span, +code span, +dt span { + color:#339933; +} + +ul.code-block em { + font-style: normal; +} + +ul.code-block span, +pre span span, +code span span, +dt span span { + color:#667788; +} + +pre.block, +pre.block code, +div.block div.code, +ul.code-block { + position:relative; + display:table; + *display:block; + border:1px solid #ccc; + border-radius:3px; +} + +div.block, +pre.block { + background:#e9f3ff; + border-color:#eee; + padding:3px; +} + +pre.block code, +.block .code { + background:#fff; + border:1px solid #ccddee; + padding:0.5em; + font-size: 100%; + line-height:1.75em; + background-image: -webkit-linear-gradient(#fcfcfc 50%, #fff 50%); + background-image: -o-linear-gradient(#fcfcfc 50%, #fff 50%); + background-image: linear-gradient(#fcfcfc 50%, #fff 50%); + background-size: 100% 3.5em; + background-origin: content-box; +} + +pre.block code { + padding: 1em; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/xhtml-test.xhtml b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/xhtml-test.xhtml new file mode 100755 index 00000000..38bcbb13 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/demo/template/xhtml-test.xhtml @@ -0,0 +1,143 @@ + + + +SoundManager 2 Template + + + + + + + + + + + + + + + + + + +
    +

    SoundManager 2 Template Example

    +

    This is a basic template for adding SoundManager to your page.

    +

    How it works

    +

    This page includes the SM2 script, which starts up on its own as appropriate. By default it will try to start as soon as possible.

    +

    The minimal code needed to get SoundManager 2 going is below, with configurable parts:

    + +
    +<!-- include SM2 library -->
    +<script type="text/javascript" src="/path/to/soundmanager2.js"></script>
    +
    +<!-- configure it for your use -->
    +<script type="text/javascript">
    +
    +soundManager.setup({
    +  url: '/path/to/sm2-flash-files/', // directory where SM2 .SWFs live
    +
    +  /*
    +   * Note that SoundManager will determine and append the appropriate .SWF file to the URL,
    +   * eg. /path/to/sm2-flash-files/soundmanager2.swf automatically.
    +   * You should not put soundmanager2.swf in there yourself.
    +  */
    +
    +  // Beta-ish HTML5 audio support (force-enabled for iPad), flash-free sound for Safari + Chrome. Enable if you want to try it!
    +  // useHTML5Audio: true,
    +
    +  // do this to skip flash block handling for now. See the flashblock demo when you want to start getting fancy.
    +  useFlashBlock: false,
    +
    +  // disable debug mode after development/testing..
    +  // debugMode: false
    +
    +});
    +
    +// Option 1: Simple onready() + createSound() method
    +
    +soundManager.onready(function() {
    +  // SM2 has loaded - now you can create and play sounds!
    +  soundManager.createSound('helloWorld','/path/to/hello-world.mp3');
    +  soundManager.play('helloWorld');
    +});
    +
    +// Option 2 (better): More flexible onready() + createSound() method
    +
    +soundManager.onready(function() {
    +
    +  var mySound = soundManager.createSound({
    +    id: 'aSound',
    +    url: '/path/to/an.mp3'
    +    // onload: [ event handler function object ],
    +    // other options here..
    +  });
    +
    +  mySound.play();
    +
    +});
    +
    +// Option 3 (best): onready() + createSound() / ontimeout() methods for success/failure:
    +
    +soundManager.onready(function() {
    +
    +  // SM2 has loaded - now you can create and play sounds!
    +  var mySound = soundManager.createSound({
    +    id: 'aSound',
    +    url: '/path/to/an.mp3'
    +    // onload: [ event handler function object ],
    +    // other options here..
    +  });
    +  mySound.play();
    +
    +});
    +
    +soundManager.ontimeout(function() {
    +
    +  // (Optional) Hrmm, SM2 could not start. Show an error, etc.?
    +
    +});
    +
    +
    +</script>
    + +

    Handling flash blockers

    +

    It's good to let users see the flash component of SM2, so those with flash blockers can unblock it and allow SM2 to start. For more info on this, see the Flashblock example.

    + +

    Making SM2 wait for window.onload()

    +

    If you prefer to have the library wait for window.onload() before making onready() / ontimeout() callbacks, you can specify waitForWindowLoad: true.

    + +

    Disabling debug output

    +

    SoundManager 2 will write debug output via console.log() if available, by default. To disable it, simply specify debugMode: false.

    +

    You can also write HTML-based debug output to the DOM via consoleOnly: false and/or useConsole: false.

    +

    To see related configuration code, refer to the source of this page which basically does all of the above "for real."

    + +

    Troubleshooting ("failed to start": Viewing offline, missing SWF, flash blockers etc.)

    +

    If SM2 is failing to start and throwing errors due to flash security, timeouts or other issues, check out the troubleshooting tool for tips.

    + +

    No-debug, compressed version of soundmanager2.js

    +

    Once development is finished, you can also use the "minified" (down to ~8% of original size with gzip!) version of SM2, which has debug output and comments removed for you: soundmanager2-nodebug-jsmin.js. Serve with gzip compression wherever possible for best bandwidth savings.

    + +
    + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/download/archive.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/download/archive.html new file mode 100755 index 00000000..9c666c0c --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/download/archive.html @@ -0,0 +1,2041 @@ + + + +SoundManager 2: Revision History (Archived) + + + + + + + + + + + + + + + + +
    + + + +
    + +
    + + +
    + +
    +
    +
    + +
    +
    +
    + +
    + + +
    + +
    + +

    Revision History

    +

    Archived versions of SM2 releases

    + +
    + +
    + +
    + +

    Revision History (Archives)

    + +

    A changelog of sorts.

    + +
      + + + +
    • + +

      V2.97a.20111220 - HTML5 src/onload()/onstop() fixes, new HTML5 polling, onPosition() updates, "audio sprites" (from/to) and multiple URL support. (Also: New homepage design!) (Download archived version)

      + +

      Fixes for HTML5 audio including redundant src assignment, onload and onstop. New html5PollingInterval property, onPosition() and clearOnPosition() methods, "audio sprites" support via from and to parameters. Updated onposition() sound method, added new onposition sound parameter, and multiple URLs / URL formats now allowed for a sound. Also: Version checking between JS and SWF, brand-new optimized homepage design and demo UI tweaks + optimizations.

      + +
        + +
      • + +

        Bug fixes

        + +
          + +
        • +

          + HTML5: Fixed Audio() src attribute re-assignment bug seen in createSound()->play() use case. +

          +
        • + +
        • +

          + HTML5: mySound.load({onload:function(){}}) callback fixed so it works. +

          +
        • + +
        • +

          + HTML5 + Flash: onload() now called immediately when load({onload:function(){}}) is used on a sound with the same URL which has already loaded. +

          +
        • + +
        • +

          + onstop() now mimics onfinish() in terms of sequence. HTML5 sets position to 0, but retains pre-stop() position property value (like Flash does.) +

          +
        • + +
        • +

          + Amazon Kindle Fire UA looks like Safari on OS X 10.6.3, but does not have broken HTML5 audio (i.e., intermittent playback failure) like the "isBadSafari" case. +

          +
        • + +
        • +

          + MovieStar/NetStream (non-RTMP) edge case: Correct onfinish() after play() and a seek so that it always fires. Remove metadata() after first call (as it was) for non-RTMP. Reduce buffer-near-end logic to 3 seconds from 5. +

          +
        • + +
        • +

          + Flash 9 MovieStar/RTMP: Only fire onconnect() for RTMP (was firing for flash 9/NetStream, too, breaking MovieStar createSound({autoLoad:true,onload:function(){this.play()}}) case.) +

          +
        • + +
        • +

          + RTMP: Exclude RTMP from 30-second resume() reposition hack (streaming does not have this issue.) May have been breaking buffer due to seek on resume. +

          +
        • + +
        • +

          + Fix edge case where soundManager.waitForWindowLoad = true (non-async startup case), but _initComplete() may fire after window.onload() and thus onready() never fired. +

          +
        • + +
        + +
      • + +
      • + +

        API updates

        + +
          + +
        • +

          + Added soundManager.html5PollingInterval property, for increased whileplaying() callback frequency (higher UI framerates) similar to flashPollingInterval. (By default, null/off.) Also excludes mobile (eg., iOS) by default. +

          +
        • + +
        • +

          + soundManager.onPosition(): Queues a callback that will be fired each time a sound reaches a given position during playback. Applies for the life of the sound object. +

          +
        • + +
        • +

          + soundManager.clearOnPosition(): Removes onPosition() callback(s) from a sound, by position and/or callback. (If no position or callback are specified, then all callbacks are cleared for the given sound.) +

          +

          + Optionally, an onstop: function(){} handler can be passed to capture the moment when "to" is reached. When using Flash, sound is preloaded 100% in order to guarantee playback can start at the "from" position. +

          +
        • + +
        • +

          + Added support for "audio sprites." New sound options, from and to allow segments, samples or slices of sound to be played. eg., mySound.play({ from: 5000, to: 10000}); +

          +
        • + +
        • +

          + New sound option, onposition, defines times and related callbacks for positions of interest within a sound. Applies on a per-play basis. eg. onposition: {500: function(p) { console.log('position ' + p + ' was reached.') } } +

          +
        • + +
        • +

          + Experimental: Multiple formats/encodings support in the sound url parameter; now accepts an array as an alternate to a single string. eg. soundManager.createSound({id:'foo', url:['bar.ogg','bar.mp3']}); - SM2 will use the first playable URL it finds and the URL property will then reflect the one URL after that point. Note that this means the original array data will be lost. +

          +

          + Also accepts type attributes, eg. url:[{type:'audio/mp3',url:'/path/to/play.php?song=123'},...] - useful for URLs without obvious filetype extensions. +

          +
        • + +
        • +

          + Flash 9 + MovieStar (NetStream) / RTMP: onmetadata (sound parameter) callback, allows capturing of metadata events from flash (eg., streaming song / title updates) similar to onid3(). Can now fire multiple times, eg., when RTMP streaming and new song / artist info is provided. +

          +
        • + +
        • +

          + Added JS version + Flash SWF build/version check to SM2 during start-up. (Finally! :D) ... Will now throw new Error() if soundmanager.js version reports V2.97a.20111030 and SWF version is V2.97a.20110918, for example. (Happens when upgrading/replacing old versions of SM2, you may forget to update one of the SWFs etc.) +

          +
        • + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + +
        • +

          + Homepage: Brand-new, shinier design, improved three-column layout; looks better even in IE 6. Small UI tweaks on inline demos. Combined demo JS + CSS files for performance; cut HTTP requests by over 50% (now down to 14 HTTP requests in most cases) via concatenation and data: URIs for some background images and sprites. +

          +
        • + +
        • +

          + 360 player demos: Updated UI with more circles and a few gradients, border-radius etc. Small 50x50 UI is now clickable over entire area, rather than small circular button. +

          +
        • + +
        • +

          + Demos: Some data: URIs added to inline player and 360 player for performance (reduced HTTP requests.) Christmas lights demo now uses YUI 3 seed + animation. +

          +
        • + +
        • +

          + soundManager.useConsoleOnly = true by default, was previously false. New "true" default means no HTML debug output if console.log() is available. +

          +
        • + +
        • +

          + soundmanager2.js: Micro-optimizations, further -nodebug-jsmin optimizations and minor comment formatting. Eliminated last Google Closure Compiler warning (caused by an empty "if" block.) +

          +
        • + +
        • +

          + Debug output no longer shows "loops: 1" (redundant), only interesting values eg. 2+ are reported. +

          +
        • + +
        • +

          + Documentation: Small theme tweaks, textured background and re-organization of properties (left menu) for easier navigation. Fixed "onsuspend" event labeling, clarify SMSound events as properties and not methods. Re-sorted property lists, tidied up code formatting. Added missing soundManager.onPosition() documentation (side note: previously named onposition(), old lower-case method name maintained for backward compatibility.) +

          +
        • + +
        • +

          + Page player / Muxtape demos: Removed useMovieStar sound option - no longer exists, redundant. +

          +
        • + +
        + +
      • + +
      + +
    • + + + +
    • + +

      V2.97a.20111030 - HTML5 unload() improvements, Android 2.3 fix and new onsuspend() event (Download archived version)

      + +

      Fixes for HTML5 unload() on Webkit (connection was not closing), playback on Android 2.3, and IE 9 "not implemented" / unsupported HTML5 case. Addition of onsuspend() HTML5 event, possibly applicable to iOS where stalled events suggest that user action is needed to play or resume audio playback.

      + +
        + +
      • + +

        Bug fixes

        + +
          + +
        • + +

          HTML5 unload(): Correctly apply about:blank (_emptyURL default) to everyone except Firefox, which allegedly likes ''. Webkit was not actually closing the connection of loading streams, in this case.

          + +
        • + +
        • + +

          HTML5 audio playback fix for Android 2.3 (Honeycomb), which doesn't seem to like new Audio('foo.mp3') followed by load() -> play(); first request/attempt stalls and eventually fires ended event. Rather odd. (Related discussion.)

          + +
        • + +
        • + +

          Added try...catch for dumb IE 9 Audio() "not implemented" error in Windows server case without "desktop experience" installed, means no HTML5 audio/video support. Hat tip: Modernizr issue 224

          + +
        • + +
        + +
      • + +
      • + +

        API updates

        + +
          + +
        • + +

          Added soundManager.noSWFCache (boolean) for easy cache busting - good for dev/testing. SWFs tend to be aggressively cached by browsers, especially in offline cases.

          + +
        • + +
        • +

          HTML5 suspend events are now listened for and fired via SMSound option onsuspend(). This event may be the best way to detect when mobile Safari (eg. iOS) is blocking autoplay-style behaviour, and user interaction is required to start or resume playback.

          +
        • + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + +
        • + +

          Fix "playable MP3 links" demo for iOS, playing 2nd+ sound now works. Due to single sound object reuse, "old" sound must be paused before new one is created. Previously, playing sound 1 -> sound 2 -> sound 1 would fail.

          + +
        • + +
        • + +

          Tweaked 360player behaviour to support being initialized multiple times (for dynamic content, "decorating" new MP3 links etc.)

          + +
        • + +
        • + +

          Modified soundManager core property documentation to be multi-line, allowing longer comments

          + +
        • + +
        + +
      • + +
      + +
    • + +
    • + +

      V2.97a.20110918 - Code clean-up, improved comments and formatting, generated documentation, polling and onbefore- removal, HTML5 stop()/unload() fixes (Download archived version)

      + +

      Added block comments above major SM2 methods (and Docco-generated documentation), more line breaks for consistent vertical spacing and readability, removal of onbefore-related SMSound options, allowPolling + useFastPolling features. Improved build task optimizing of -nodebug JS build, removing comments, extra line breaks and debug code blocks which were previously only commented out.

      + +
        + +
      • + +

        Bug fixes

        + +
          + +
        • HTML5 unload: Gecko can use url = '' to cancel request etc., others seem to need about:blank or similar empty URL (matching Flash 8.)
        • + +
        • HTML5 stop(): Don't call unload() here (file under "durrr." This fixes a few state-related bugs.)
        • + +
        • Fire the onposition callback after setting item.fired, instead of before. This allows looping in the form of mySound.onposition(200, function(){ mySound.setposition(100); });
        • + +
        • Fix movieStar (MPEG-4) handling for URLs without MIME hints (eg. a URL ending in .php) if type: 'audio/mp4' is passed, for example. (Possible regression introduced with V2.97a.20110801, one report was received.)
        • + +
        • Fire onposition() after increasing the internal "onPositionFired" counter.
        • + +
        + +
      • + +
      • + +

        API updates

        + +
          + +
        • + +

          Clean-up time! The following soundManager properties have been removed as they're ineffective and/or have modern replacements:

          + +

          + soundManager.nullURL = 'about:blank'; (internalized; search for 'about:blank' in the source if you want to customize it.) +

          + +

          + soundManager.allowPolling = true; (ignored, always true now. whileloading() / whileplaying() calls rely on it.) +

          + +

          + soundManager.useFastPolling = false; (redundant, now determined by flashPollingInterval now being specified as a number eg., 20, instead of the default of null.) +

          + +

          + The following SMSound (sound options) have been removed, in favour of modern replacements (and also didn't work with HTML5 sounds.) +

          + +
          soundManager.defaultOptions.onbeforefinish = null;
          +soundManager.defaultOptions.onbeforefinishtime = 5000;
          +soundManager.defaultOptions.onbeforefinishcomplete = null;
          +soundManager.defaultOptions.onjustbeforefinish = null;
          +soundManager.defaultOptions.onjustbeforefinishtime: 200;
          + +

          + As a replacement, use the SMSound.onposition() method to assign an event callback handler to fire at the relevant time. +

          + +
          mySound.onposition(10000, function() {
          +  console.log('the sound ' + this.id + ' is now at position ' + this.position);
          +});
          + +

          + If you need to fire an event relative to the true end of the sound, reference its duration once the sound has fully-loaded - ie., at or after the onload() event - as the duration will not be completely accurate until that time. durationEstimate may be referenced before onload(), but it should not be relied on when "precise" timings of say, < 1 second are desired. +

          + +
          mySound.load({
          +  onload: function() {
          +    this.onposition(this.duration - 5000, function() {
          +      console.log('the sound ' + this.id + ' is now at position ' + this.position);
          +    }
          +  }
          +});
          + +

          + Again, note that due to the interval / polling-based methods of both HTML5 and flash audio, sound status updates and thus precision can vary between 20 msec to perhaps 0.5 seconds and the sound's position property will reflect this delta when the onposition() callback fires. +

          + +
        • + +
        • + +

          Added soundManager.onposition() (forgot to mirror the SMSound method)

          + +
        • + +
        • + +

          + Privatize soundManager.netStreamMimeTypes, etc. soundManager.mimePattern, the resulting one applied to canPlayMIME() etc., is still exposed. +

          + +
        • + +
        • + +

          + Simplify getMovie() to use _id(smID) || _doc[smID] || _win[smID] rather than IE / Safari special checks. Sometimes (old?) IE and Safari would return null on getElementById(), but window[id] or document[id] would work. Presumably related to Flash + ExternalInterface wackiness. +

          + +
        • + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + +
        • Reviewed soundmanager2.js code for readability and comments. Added linebreaks, spacing and block-style comments around main functions.
        • + +
        • Added generated documentation via "Rocco" (ruby port of Docco.)
        • + +
        • Added build.xml notes re: Closure compiler, MTASC and where to find working builds
        • + +
        • Modified soundmanager-nodebug.js build so comments and debug blocks are removed entirely from the code. Double-spaced linebreaks are also removed.
        • + +
        • Removed executable permissions from almost all files
        • + +
        • parseInt() on soundManager.flashVersion, invalidate strings like "9"
        • + +
        • Use 10 / 50 msec polling interval for high performance mode vs. regular mode
        • + +
        • Page cache/unload/restore (back button case): Only apply window unload event if using flash, since plugin is more likely to break (ie., state won't be recalled correctly.)
        • + +
        + +
      • + +
      + +
    • + +
    • + +

      V2.97a.20110801 - "100% HTML5 mode" desktop browser (+no flash) fix, useHTML5Audio enabled by default, flash 9 end-of-sound correction, ClickToFlash improvements (Download archived version)

      + +

      Last release introduced a regression with HTML5-only mode on desktops when flash was not installed/present, now fixed; HTM5 audio support is enabled by default, although flash is still preferred for MP3/MP4 by default. probably|maybe is now the default when testing HTML5 format support. Flash 9 now does not reset sound position to 0 at onfinish(), matching flash 8 and HTML5 behaviour. Better ClickToPlugin / ClickToFlash compatibility (CSS tweaks for display of blocked SWF.) Minor internal flash polling loop improvements. soundManager onload, onerror and oninitmovie events have been deprecated in favour of onready() and ontimeout(), but remain functional.

      + +
        + +
      • + +

        Bug fixes

        + +
          + +
        • A regression was introduced in V2.97.20110706 where SM2 would fail to start in HTML5-only mode on supported desktop browsers when flash was disabled or not installed, eg., Safari on new Macs or IE 9 without flash. (iOS was not affected.) This has been fixed with the 2.97.20110801 release.
        • + +
        + +
      • + +
      • + +

        API Updates

        + +
          + +
        • +

          soundManager.useHTML5Audio is now true by default; however, soundManager.preferFlash is also true and HTML5 browsers will still attempt to use flash for playing MP3/MP4 by default, if those formats are marked as "required".

          +

          If you wish to have 100% HTML5 mode in more cases, set soundManager.preferFlash = false. Presently, the MP3 links and MP3 button SM2 demos are more HTML5-friendly and will serve as a test for exposing bugs that may be in the wild.

          +
        • + +
        • +

          soundManager.html5Test has been relaxed to use (probably|maybe) for Audio's canPlayType() test (previously, was only "probably") - so formats will be more likely to work on HTML5-only devices that conservatively report "maybe" for MIME types like audio/mpeg; codecs="mp3" at this point.

          +
        • + +
        • +

          Certain mobile and tablet-like devices are special-cased as preferring HTML5, and will ignore checking for flash altogether; this presently includes the iPad, iPhone and iPod, Palm Pre and Motorola Xoom.

          +
        • + +
        • +

          The HTML5 audio "loadeddata" event triggers an SMSound onload() event, which now fires whileplaying() and tries to pass identical bytesLoaded, bytesTotal parameters so that UIs will correctly show the sound as fully-"loaded" - even if in truth, not all bytes have actually been fetched (depending on the browser and server, etc.) because of the ability to do arbitrary seeking.

          +
        • + +
        • +

          Updated Flash 9 onfinish() / end-of-sound behaviour: Sound objects' position property no longer resets to 0 when a sound ends (and when onfinish() fires.) This now matches both HTML5 and flash 8's existing behaviour; therefore, a sound's position will equal its duration at onfinish() in all cases now. In the event play() is called from the end of a sound at or after onfinish(), the sound's position will be set to 0 before playback begins if using flash 9.

          +

          Edge case covered: if at internal SOUND_COMPLETE the SMSound.position is < its duration, flash will match position to duration and fire whileplaying() one last time so "100%" is always reached before onfinish() is called.

          +

          multiShot + multiShotEvent case has been verified as working (eg. onfinish() fires 5x if play() called 5x.)

          +
        • + +
        • +

          soundManager.onload, soundManager.onerror and soundManager.oninitmovie have been deprecated in favour of soundManager.onready() and soundManager.ontimeout(). The deprecated methods are still present and work with this release, but you should migrate to their modern replacements.

          +
        • + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + +
        • +

          Flash 8 + 9 internal whileplaying() + whileloading() polling improvements: Internal check previously looped through all sounds from onLoad(), registerOnComplete(), _load() and _setPosition(). Now only the relevant sound is checked.

          +
        • + +
        • +

          Improved HTML5 support debug ouput/messaging, now right up top. Better messaging and error handling when Flash isn't present, yet required case (Flash plugin either not installed or disabled, but needed in some cases) - eg., Firefox and audioFormats.mp3.required = true; ... Also, only one _detectFlash() call now made.

          +
        • + +
        • +

          Playable MP3 links and MP3 button demos use soundManager.preferFlash = false, so they should be able to run in 100% HTML5 mode. Some HTML5 bugs are anticipated, and these may help to reveal issues via a smaller audience.

          +
        • + +
        • +

          Initialization code reorganized, minor edits and clean-up, removal of some unused objects and ternary optimizations per jslint

          +
        • + +
        • +

          Cleaned up IE <object> code, added highPriority flash param (affects flash 10.1+, if at all.)

          +
        • + +
        • +

          Improved flashblock handling / compatibility (CSS layout tweaks) with newer ClickToPlugin/ClickToFlash Safari (5.0.6 / 5.1+) extensions.

          +
        • + +
        • +

          SM2 homepage demos try HTML5 + Flash if available, with "safe" reboot + fallback to HTML5-only mode (if supported - eg., Safari with flashBlock/ClickToFlash.)

          +
        • + +
        • +

          Basic MP3 player demo: Fix event JS error when manually calling things like basicMP3Player.handleClick({target:document.getElementById('foo')});

          +
        • + +
        • +

          Flash SWFs, debug versions: Mention right-click -> security panel options when troubleshooting security errors

          +
        • + +
        + +
      • + +
      + +
    • + + + +
    • + +

      V2.97a.20110706 - improved HTML5/flash "mixed mode" via preferFlash, Safari + Snow Leopard HTML5 audio bug update, better ClickToFlash compatibility, minor demo tweaks (Download archived version)

      + +

      Special note: This was V2.97a.20110705, but the latest Flex SDK (4.5.1.21328) was downloaded and used for this build, and it compiled a Flash 9 SWF that wouldn't fully-start on some Windows machines running Firefox and IE 7, possibly others - thus, SM2 would fail to start up. The Flash 9 SWFs are now compiled with an older, working SDK version 4.1.0.16076, used in previous working releases. See discussion for more details.

      + +

      Improved "mixed mode" HTML5/flash handling via new (experimental) preferFlash option, enabled by default. (If present, MP3/MP4 get flash for stability; HTML5 is used for other formats.) OS X 10.6.8 (finally?) fixes HTML5 audio in Safari. SoundManager 2 SWF adjusted to fall under ClickToFlash's "invisible" rules, may lower chance of blocking.

      + +
        + +
      • + +

        Bug fixes

        + +
          + +
        • ClickToFlash (Safari/Mac flashblock-style extension) compatibility improvement: Use width/height: auto on SWF instead of 100%. The latter is not recognized as being within ClickToFlash's <= 8x8px "invisible flash" rules, almost guaranteed to be blocked. (When considered "invisible", SWF is allowed to load normally if user has the invisibles option enabled.)
        • + +
        • Flash blocking/handling improvements: Default #sm2-container size now always 8x8px to fall under "invisible" flash rules, better chance of load being allowed. If blocked and using flashblock.css, #sm2-container reverts to 48x48px at ontimeout() for visibility (so user can see, and unblock the flash bit.)
        • + +
        • OS X 10.6.8 "pre-Lion release" update finally appears to have fixed the broken Safari HTML5 audio issue. Thus, audio was broken from OS X 10.6.3 to 10.6.7 and SM2 will use Flash for these known cases. Related: Testcase and Webkit bug #32159.
        • + +
        • HTML5 audio: Playback now does not start after a setPosition() call (if the sound was not already playing), or if it was paused - matching the existing Flash API behaviour.
        • + +
        • Fix ontimeout() queue incorrectly processing after onload() and successful startup.
        • + +
        • Debug output: extraneous "%s" fixes for onready() / ontimeout()
        • + +
        + +
      • + +
      • + +

        API Updates

        + +
          + +
        • +

          Added experimental soundManager.preferFlash (default:true) for a more consistent MP3/MP4 playback option in certain HTML5 cases. If using soundManager.useHTML5Audio + preferFlash and flash is available, flash will be used for MP3/MP4.

          +

          HTML5 is still new and relatively unstable, and bugs are yet to be found and fixed across a growing number of browsers/platforms etc. (consider that it was broken on Safari between OS X 10.6.3 and 10.6.7.) If flash is not installed or preferFlash = false, 100% HTML5 mode can still apply. In any event, HTML5 will still be used (if enabled) for all other formats.

          +
        • + +
        • Moved internal html5Only to (experimental) soundManager.html5Only, for detecting "HTML5-only mode" - eg., iOS, Safari without preferFlash or other environments where SM2 is operating without the flash portion of SM2.
        • + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + +
        • Improved "can play" detection (canPlayURL() + canPlayMIME()) for HTML5 + flash cases. Increased "getting impatient, waiting for flash" message to 1 second.
        • + +
        • 360°, inline, MP3 button players: Event add/remove: use addEventListener based on typeof attachEvent === null (old IE behaviour)
        • + +
        • MP3 player button demo: Fix IE 6/7 display issue on button (d'oh!)
        • + +
        • Muxtape-style demo: Added pagePlayer.playPrevious(), to match pagePlayer.playNext() (call when a sound is currently playing.)
        • + +
        • Fixed 360° player basic visualization demo (missing class in HTML), clarified canvas support (no eq/spectrum) re: IE <9.
        • + +
        • 360° UI: Old "empty element doesn't catch mouse events" bug apparently still applies to IE 9. Fix with invisible background image.
        • + +
        • Minor homepage stylistic updates, source code order change for API docs (CTRL-F search now hits left column first)
        • +
        • Small debug output clean-up in SM2, object/embed, init etc.
        • + +
        + +
      • + +
      + +
    • + +
    • + +

      V2.97a.20110424 - Minor HTML5 tweaks, option inheritance fixes, improved build.xml file (Download archived version)

      + +

      HTML5 bulletproofing, Audio(null) argument fix for iOS + Opera, load() vs. createSound() and setVolume()/setPan() options/inheritance correction

      + +
        + +
      • + +

        Bug fixes

        + +
          +
        • HTML5: new Audio(null) fix for differences between iOS (which would try to load null) and Opera 9.64, which would throw a WRONG_ARGUMENTS_ERR if null was not passed.
        • +
        • HTML5: Restrict internal volume value range to 0..1, avoid DOM exceptions.
        • +
        • HTML5: load{url:x}) improvements for desktop, better old vs. new URL comparison.
        • +
        • HTML5, iOS 4.2/4.3+, SM2 Muxtape/inline/link demos: onfinish()->unload()->playNext() was breaking on newer iOS versions, "play through" affected. Removing unload() for iOS fixed issue.
        • +
        • Flash object/embed pluginspage/codebase attribute now uses http:// when being used from file:// (offline), and http/https-agnostic //macromedia.com syntax to avoid SSL mixed-content warnings.
        • +
        • Fix setVolume() / setPan() to properly update SMSound.options (when not "instance-only"), so settings are retained for future play() calls. Bug was that original volume/pan were incorrectly restored after the first instance completed.
        • +
        +
      • + +
      • + +

        Miscellaneous

        + +
          +
        • +

          New and improved (nearly platform-independent) build.xml file, thanks to github user "dolmen". A .build.properties file is now needed, defining "mxmlc", "mtasc", and "closure-compiler.jar" paths. e.g.:

          +
          <!-- .build.properties file in SM2 root -->
          +mxmlc=/Applications/flexsdk/bin/mxmlc
          +mtasc=/Applications/mtasc/mtasc
          +closure-compiler.jar=${user.home}/compiler.jar
          + +

          Running ant from the SM2 root will build the no-debug and minified versions of the script, as well as the SWF files.

          + +
        • + +
        +
      • + +
      +
    • + + + + +
    • +

      V2.97a.20110306 - HTML5 audio updates, Flash/HTML5 mode detection, IE flash init tweaks, reuse and instance options fixes (Download archived version)

      + +

      Bug fixes and improvements for HTML5 audio (object reuse on iOS), improved URL comparison. onfinish() -> this.play() instance option fix. IE flash wmode initialization tweak. Flash/NetStream (MP4) unpause()/resume() hack now applies to everyone. If no flash found (eg., new Mac desktops), HTML5 audio will now be tried. Make hasPriority actually work (d'oh!)

      + +
        + +
      • +

        Bug fixes

        +
          +
        • HTML5: _resetProperties() when setting Audio().src, fix sound1.play() -> sound2.play() -> sound1.play() case on iOS 4.1 not correctly re-assigning original sound URL (related to global audio object.)
        • +
        • HTML5 audio: If no flash, try forcing useHTML5Audio = true (eg. desktop safari on new Macs which don't come with Flash.) Related: flash detection code tweak.
        • +
        • Improved _iO vs. old _iO URL comparison, rather than .src which gets translated from local paths to file:// etc.
        • +
        • Correctly trash instanceOptions (and _iO) before calling onfinish(), but maintain local copy of onfinish() so it still works. Fix play({onfinish:this.play}) bug where _iO was being incorrectly remembered.
        • +
        • Flash 9/movieStar: setPosition() unpause hack for everyone, not just Webkit (via 8tracks dudes, reported now in Firefox? Should not cause regressions.)
        • +
        • Special wmode tweak for reports of SM2 start-up failures, may be admin/non-admin account related, IE 8-only on Windows 7 (possibly Vista, too?) as of late January, 2011.
        • +
        • Apply hasPriority to object/embed, not its style. D'oh. :P
        • +
        • HTML5: use new Audio(null) vs new Audio(), Opera 9.64 expects URL argument; throws WRONG_ARGUMENTS_ERR otherwise. Doesn't implement canPlayType() either, but both are fixed in future releases.
        • +
        +
      • + +
      • +

        Miscellaneous

        +
          +
        • Don't actually apply new value in setPosition() if a sound has not yet loaded (and if so, hasn't errored out.)
        • +
        • isNaN() check for HTML5 loading (saw one under Safari, in testing).
        • +
        • Added CLSID and codebase attributes for IE <object> (same as used in SWFObject), just to be safe.
        • +
        • Removed some HTML5 debug bits, unused _HTML5_states/codes block.
        • +
        • Flashblock CSS: Correctly hide the SWF via left/top:-9999em when it hits .swf_loaded {}, ie., never blocked in the first place. Minor flashblock regression fixes after .swf_loaded / .swf_unblocked changes with last release.
        • +
        • Ant build script parameter change, now uses .build.properties file (related pull request)
        • +
        +
      • + +
      +
    • + +
    • +

      V2.97a.20110123 - HTML5 audio improvements for desktop + mobile (iOS), 360° UI demo tweaks (Download archived version)

      + +

      Tweaks to HTML5 features, "mixed-mode" HTML5 + flash cases, desktop and iOS tweaks. Improved sound re-use and "play-through" on iOS (believed previously working, may have regressed with iOS 4.2.1.) Code clean-up and shuffling of homepage, 360° demo (jslinted and improved functionality), load({options}) fix, better handling of broken Safari/Snow Leopard audio case.

      + +
        + +
      • +

        Bug fixes

        +
          +
        • Fix for soundManager.load({options}) / SMSound.load({options})-specific case (regular load() sans-parameters was fine), where load({onload:...}) would fail if a URL parameter was not specified. load({url:...,onload:...}) was OK. If unspecified, load now takes URL from SMSound.url.
        • +
        • Fixed unload/replay case on iOS: play sound #1, interrupt it by starting sound #2, then play sound #1 again - previously, #1 would fail on replay due to interrupted state since iOS only allows one sound at a time. Should now restart OK. (This applies to the new soundManager.useGlobalHTML5Audio stuff.) Playlist auto-advance looks to be OK as well.
        • +
        +
      • + +
      • +

        API Updates

        +
          +
        • New (experimental) soundManager.useGlobalHTML5Audio property - if true (default for iOS/mobile), reuses a single Audio() object for loading sound. Helps make playlist / onfinish()->play() work on iOS without user interaction.
        • +
        • New (experimental) soundManager.requireFlash property (default: false.) If true, prevents HTML5-only mode on devices with both HTML5 and Flash. May be useful when HTML5 is enabled (and can play MP3), but Flash is desired to play RTMP content etc. As of this version, will only use Flash for RTMP.
        • +
        • HTML5: Fix for type:'audio/mp3' returning false on canPlay(). Timer update-while-paused tweak.
        • +
        • HTML5: More event listeners, ignore events on destroyed sounds, improved event clean-up, "seek before load" fix
        • +
        +
      • + +
      • +

        Miscellaneous

        +
          +
        • Improved broken Safari/Snow Leopard HTML5 audio situation: HTML5 mode is no longer disabled - and if available, Flash is used to play MP3/MP4 content to work around known playback issues with native HTML5 audio.
        • +
        • (Finally) report "true" position of MovieStar (MPEG4/AAC) content while scrubbing a playing/paused sound. Previously did not fire updates while scrubbing. Imperfect on resume due to buffer, but should be negligible and an improvement vs. old behaviour.
        • +
        • 360° player refresh, works with multiple types (eg. small 48x48 square vs. large 256x256 square w/spectrum + EQ visualizations) on the same page now. Can play and seek simultaneously, as well. More configurable. Removed old empty.gif + imageRoot junk. Core JS now appeases the jslint gods.
        • +
        • Code clean-up, removed undocumented/experimental playOnSeek and related methods from a prior fork.
        • +
        • Fresh homepage demo design/layout, should be nicer for new users.
        • +
        +
      • + +
      +
    • + +
    • +

      V2.97a.20110101 - Simplified onready() behaviour (see potential onready() regression note), new ontimeout() handler, Webkit + MovieStar 30-second-pause fix (Download archived version)

      +

      onready() is now called only for SM2 init success (makes default case easier, no need for "supported" check) - new ontimeout() is called only for failure case, ie., flash blocked/missing. Special Webkit/MovieStar won't-resume-after-30-seconds-paused fix. soundManager.supported() renamed to soundManager.ok() (old method aliased for the time being.)

      + +
        + +
      • +

        Bug fixes

        +
          +
        • Special bad case, Webkit/Flash+MovieStar (AAC/MPEG4/RTMP-only, not MP3): sounds don't resume after being paused for 30+ seconds(?), but setPosition() with current position gets things going again after a resume() attempt. Reported via 8tracks dudes.
        • +
        +
      • + +
      • +

        API Updates

        +
          +
        • +

          In previous releases, the soundManager.onready() queue would be processed for both OK and failure cases. The onready() queue is now processed only if successful initialisation occurs, making old "supported" checks within the onready() handlers redundant.

          +

          Potential regression note: Old error case handling within onready() will never execute as a result of this change. Update your code to use the new explicit soundManager.ontimeout() handler instead.

          + +
          +

          Old onready() method

          +
          soundManager.onready(function(){
          +  if (soundManager.supported()) {
          +    // OK, play sound etc.
          +  } else {
          +    // SM2 could not start; message user?
          +  }
          +});
          +
          + +
          +

          New onready() / ontimeout() method

          +
          soundManager.onready(function(){
          +  // OK, play sound etc.
          +});
          +
          +soundManager.ontimeout(function(){
          +  // SM2 could not start; message user?
          +});
          +
          + +
        • +
        • New soundManager.ontimeout(myFunction) method, for asynchronous queueing of init failure handlers. Fired only when SoundManager 2 is unable to initialise (usually due to blocked/missing flash, or flash security error.) Queue behaviour is the same style as onready().
        • +
        +
      • + +
      • +

        Miscellaneous

        +
          +
        • Code cleanup: Took the unsupported "jsAMP" demo (2007 prototype) out back and shot it.
        • +
        • 360° UI demo: New "allowMultiple" config option, let 2+ sounds play at once etc. (Default: false, one at a time.)
        • +
        • 360° UI, canvas visualization demo: Minor layout, UI, code tweaks
        • +
        • API/docs/demos reference and use updated onready()/ontimeout() methods.
        • +
        +
      • + +
      +
    • + +
    • +

      V2.97a.20101221 - HTML5 loading/progress and RTMP tweaks, onready() double-firing fix, hasPriority for mobile flash, Muxtape-style player now AJAX-friendly (Download archived version)

      +

      Improved HTML5 whileloading() / whileplaying(), unload and event handling. hasPriority for off-screen SWF loading on mobile, replaces old mobileFlash positioning tricks. Effectively re-wrote page player (Muxtape-style) demo to use event delegation + read live DOM, so should not break in AJAX cases. RTMP onplay() / play() / buffering fixes, setPosition() regression fix.

      + +
        + +
      • +

        Bug fixes

        +
          +
        • Double onready()-firing bug (HTML5 and non-flashblock case) fixed.
        • +
        • HTML5: Don't request null/about:blank URL with unload(), may hang/JS error in Chrome and IE 9 preview 7.
        • +
        • RTMP: Ensure onplay() is called for auto-loading streams when resumed. Don't call play() until connected. play() sets flash pauseOnBufferFull = false (fix for reported "RTMP not playing audio" issue.)
        • +
        • overHTTP was likely returning incorrect values previously - now fixed.
        • +
        • unload() tweak: Ensure position is reset to 0 if unload() fails
        • +
        • Flash audio: Log metaDataHandler info if debug enabled, possible duration metaData fix
        • +
        • No HTML5 audio for any Safari on OS X Snow Leopard 10.6.[3|4|5] due to underlying bugs causing intermittent audio playback failure; ongoing Apple issue, on their radar. Amusingly, Safari on Windows appears to be fine.
        • +
        +
      • + +
      • +

        API Updates

        +
          +
        • Revised HTML5 Audio() events, improved whileloading() / whileplaying() / onload() for Webkit and Firefox 4. Progress/onload are still a bit quirky as HTML5 audio is more about "non-linear" loading including range and partial requests, where supported. See related discussion.
        • +
        • New soundManager.ok() method, nicer alias for soundManager.supported().
        • +
        • Took soundmanager.loadFromXML() (SM1 legacy method) out back and shot it. Last tweak was in 2008, nobody uses it.
        • +
        +
      • + +
      • +

        Miscellaneous

        +
          +
        • Flash <object> / <embed>: hasPriority attribute, enables off-screen SWF loading with Flash 10.1+. Removed mobileFlash positioning/repositioning tricks in lieu of this.
        • +
        • Effectively re-wrote page-player (Muxtape-style) demo, now traverses live DOM for next item(s). Should be more AJAX-friendly. Event delegation now handles any links added at any time. Externalised experimental features, too.
        • +
        • HTML5: If URL lacks type attribute and extension such as .mp3 (worst-case scenario, you shouldn't be doing this anyway) just try dumbly loading it - imitating Flash behaviour.
        • +
        • Improved dataerror (wave/spectrum) exception handling, should result in lowered CPU use if playback continues with access exceptions (eg. YouTube video going in another tab.)
        • +
        • Start-up debug output/messaging clean-up (no movieStar in flash 8, minimal output in HTML5-only mode, etc.)
        • +
        • Add window unload handler if Flash being used, so back button will cause a page refresh (vs. the browser showing "previous state") to reinstate Flash in good browsers. Previously, the "previous state" was be shown but Flash audio would be broken.
        • +
        • ipod (ipod touch) gets HTML5 now, too.
        • +
        • Microsoft have added Audio() to Internet Explorer 9 as of "Platform Preview 7" - previous pre-releases of IE 9 only implemented <audio>, which SM2 does not use.
        • +
        +
      • + +
      +
    • + +
    • +

      V2.97a.20101010 - Code cleanup, HTML5 audio tweaks, RTMP features, removal of experimental video, optional usePolicyFile crossdomain.xml feature (Download archived version)

      +

      Shuffling of SoundManager 2 core, approximately 5% shaved off full debug-enabled file size after bug fixes, additional comments, new features and so on. Internal event handling code cleaned up. .SWF builds optimized, Flash 9 non-debug version now under 10 KB. Debug version now flash debugger-enabled. RTMP improvements for Red5 + Flash Media Server streaming cases - buffering, event and state handling. Experimental video feature is toast, createVideo() no longer implemented. iPhone + iPad touch events on page player + 360° player UI demos; tap and drag to seek, etc.

      + +
        + +
      • +

        Bug fixes

        +
          +
        • No HTML5 audio for *any* Safari on OS X Snow Leopard 10.6.[3|4] due to underlying bugs causing intermittent audio playback failure; ongoing Apple issue, on their radar. (See related GitHub commit)
        • +
        • Don't unload() at onfinish() for HTML5 audio (was originally done to be conservative, but results in additional HTTP requests despite caching expectations?)
        • +
        • onload() for HTML5 now using proper boolean values
        • +
        • Fix NetStream-specific autoLoad/autoPlay/volume createSound() call, specific null flash sound object error scenario. (Related changes on GitHub.)
        • +
        • Fix for "onbufferchange(1) followed immediately by onbufferchange(0)" case when audio was actually still buffering.
        • +
        • Removed setPosition() within unload(), cleaner exit when destroying a sound
        • +
        +
      • + +
      • +

        API Updates

        +
          +
        • Removed experimental video feature (originally added late 2008, never developed further.) createVideo(), allowFullScreen and related video methods are now gone. Other dedicated HTML5/flash video player projects have since solved this problem.
        • +
        • New SMSound option: usePolicyFile - (boolean, default: false) - enables Flash to request /crossdomain.xml file for content on third-party domains, if access to ID3/metadata such as wave/peak/spectrum is needed. Will automagically enable if onid3() or peak/wave/spectrum features are being used.
        • +
        • console.warn()-style messaging (instead of throwing exceptions) if createSound() etc. are called before SM2 init has fired. Now calls similar warning and exits if called after a failed, unsuccessful startup (ie., timeout or not-supported case.)
        • +
        +
      • + +
      • +

        Miscellaneous

        +
          +
        • SoundManager 2 core code cleanup, ~5% shaved off soundmanager2.js code size after new features, bug fixes and comments etc. Internal event handling (DOM-related events for init, IE 6 vs. everybody else) improved.
        • +
        • Flash builds optimized; Flash 9 SWF build now under 10 KB. Debug-enabled Flash 9 SWF now hooks into Flash debug player/IDE debugging tools (compiled with -debug=true)
        • +
        • Attempt to detect RTL documents, position Flash accordingly if so to avoid long horizontal scrollbar issue (related discussion)
        • +
        • iPhone + iPad touchmove() and related events added to page player + 360° player UI demos; tap and drag to seek should now work.
        • +
        +
      • + +
      + +
    • + +
    • +

      V2.96a.20100822 - HTML5 audio support no longer alpha, Safari 5.0.1/SL HTML5 audio issues continue, iPad/iPhone "play through", Flash tweak for Android (Download archived version)

      +

      useHTML5Audio feature now considered beta-worthy, though disabled by default to be safe (with the exception of iPhone + iPad.) iPhone/iPad will now play a sequence of sounds, user interaction only required to start first one. Flash on-screen positioning tweak for Android devices that run Flash. Safari 5.0.1 on Snow Leopard exhibits same buggy HTML5 audio issue, disabled by default; Apple have been notified. IE 9 "Platform Preview 4" has <audio> but no Audio() support (yet?) See bug #586311 (may require connect.microsoft.com / Windows Live ID, login first etc.)

      + +
        + +
      • +

        Bug fixes

        +
          +
        • HTML5 Audio() still broken in Safari 5.0.1 on Snow Leopard (10.6.3, 10.6.4), where sounds intermittently fail to load and play. Apple are aware of the regression. Related bug: #32519. Include sm2-ignorebadua in URL on SM2 pages to ignore this check and verify broken behaviour, etc.
        • +
        • Tweaks for experimental RTMP feature re: handling of paused state, tracking of position and onfinish() firing early.
        • +
        • Bumped SWF z-index to 5000 for Safari 5, SoundCloud-reported bug-and-fix for Safari 5-specific bad redraw issues, and occasional crash case referencing WebCore::RenderLayer::paintLayer
        • +
        +
      • +
      • +

        API Updates

        +
          +
        • iPhone/iOS 4 and iPad can now play a sequence of sounds (once the user starts sound initially), provided onfinish() is used to create/play the next sound. Example: Muxtape-style UI on homepage will play through list without further interaction once a user plays something in the list.
        • +
        +
      • +
      • +

        Miscellaneous

        +
          +
        • Special case for getting SM2 working more reliably on HTC Android + Flash 10.1, where flash does not load until on-screen (ie., in view.) If off-screen, Flash is repositioned at left/top 0px in order to load (including scroll/resize if needed), then events released and movie is repositioned off-screen. If movie is in the DOM already eg. as in useFlashBlock cases, flashLoadTimeout is set to 0 to allow infinite wait (eg., SM2 will not timeout with an error, and will simply load when the flash is scrolled into view.)
        • +
        • Documentation: Clarified createSound() behaviour if an existing sound ID is given (returns sound object "as-is", ignores any options passed.)
        • +
        • Page-player demo updated to use canPlayLink() instead of canPlayURL, more flexible link/type handling.
        • +
        • Homepage and documentation UI/layout and language tweaks, a few new "as seen on the internets" icons etc.
        • +
        +
      • + +
      + +
    • + +
    • +

      V2.96a.20100624 - Safari 5/Snow Leopard 10.6.3/10.6.4 HTML5 Audio() issue, X-domain SWF build fixes (Download archived version)

      + +

      Disabling HTML5 Audio for Safari 5 on Snow Leopard 10.6.3 + 10.6.4 (current release) only, as it is broken similar to Safari 4.x (also on Snow Leopard only.) Related bug: #32519. Also, version info in SWFs and fixed X-domain SWF build.

      + +
        + +
      • +

        Bug fixes

        +
          +
        • HTML5 Audio() still broken in Safari 5 on Snow Leopard (10.6.3, 10.6.4) - disabling for now, falling back to Flash as with Safari 4.x on Snow Leopard. Include sm2-ignorebadua in URL to ignore this check and verify broken behaviour, etc.
        • +
        • Fixed X-domain SWF builds to actually work cross-domain.
        • +
        +
      • +
      • +

        Miscellaneous

        +
          +
        • Added version info string to SWFs in Flash right-click / context menu, helpful when troubleshooting SWFs.
        • +
        +
      • + +
      + +
    • + +
    • +

      V2.96a.20100606 - RTMP (Flash Media Server) Support, HTML5 Updates (Download archived version)

      + +

      HTML5 update, new RTMP feature: Experimental Flash Media Server support, onposition() event listener, SMSound type option and code cleanup.

      + +
        + +
      • +

        API Updates

        +
          +
        • New experimental RTMP support while maintaining existing NetStream-based behaviour for non-RTMP MPEG4 audio, etc. Uses new serverURL parameter for FMS (I used Red5 for dev/testing,) eg. soundManager.createSound({id:'rtmpTest',serverURL:'rtmp://localhost/oflaDemo',url:'oh-alberta.mp3'}).play();
        • +
        • New SMSound option for createSound(), load(), play(): 'type', for specifying MIME type alongside URL to help with detecting playability. eg. +soundManager.createSound({id:'foo', url:'/player.php?stream=1', type:'audio/mp3'}).play(); and so on. Hat tip: sylvinus.org
        • +
        • New SMSound event: onposition(), for attaching listeners to specific times within a sound.
        • +
        +
      • +
      • +

        Bug fixes

        +
          +
        • Flash sound unload/destroy ActionScript "could not close stream" exception/warning (finally?) fixed.
        • +
        • Sound looping updated for Flash 8, working (albeit with a quirk - requires preloading.)
        • +
        +
      • +
      • +

        Miscellaneous

        +
          +
        • Removed Base64 HTML5 Audio() tests, redundant as numerous MIME (audio/mpeg, audio/mp3 etc.) checks seem to cover it.
        • +
        • Updated MPC (drum machine) demo from 2006-era design, modernizing the CSS a bit.
        • +
        • nullURL = 'about:blank' tweak for unloading (flash 8.) May have finally fixed that dumb stream closing error on unload/destroy.
        • +
        • set soundManager.didFlashBlock *before* firing onready()/onerror() listeners
        • +
        +
      • + +
      + +
    • + +
    • +

      V2.96a.20100520 - HTML5 Edition (Download archived version)

      + +

      Experimental HTML5 support, lots of code shuffling and performance tweaks.

      + +
        + +
      • +

        API Updates

        +
          +
        • New soundManager.useHTML5Audio (disabled by default except for iPad, Palm Pre) - adds experimental HTML5 Audio support, with Flash fallback for MP3/MP4 formats as needed.
        • +
        • Sound looping now works in Flash! eg. mySound.play({loops:3}); - for an example + discussion of how to get near-seamless looping, see Seamless Looping MP3s in Flash (demo video) on Flickr.
        • +
        +
      • +
      • +

        Bug fixes

        +
          +
        • beginDelayedInit() is always used in lazy loading case (eg. via dynamic script tag/XHR etc.,) as some cases where SM2 won't auto-start eg. document.readyState empty for Firefox 3.5.5 (seen on Win32) with an HTML5 DOCTYPE.
        • +
        • SWF is now 8x8 pixels by default, vs. 6x6 pixels (odd fix for HTML5 Doctype on Firefox 3.6/win32)
        • +
        • Fixed dumb IE undefined ID bug
        • +
        +
      • +
      • +

        Miscellaneous

        +
          +
        • soundmanager2.swf and soundmanager2_flash9.swf are now "non-debug" versions; with debugMode enabled, soundmanager2_debug.swf and soundmanager2_flash9_debug.swf are loaded instead.
        • +
        • New build script for JS + SWFs, see file size table. JS compression now done via Google Closure compiler; new soundmanager-jsmin.js build, debug-enabled but compressed, in addition to build-script-optimized, no-debug, compressed JS (~9 KB with gzip vs. ~90 KB for raw, commented, debug-enabled version.)
        • +
        • Null check fix for unavailable eq/waveform data
        • +
        • Experimental video (flash 9-only) change: Use stage width/height instead of 0/0 when lacking metadata
        • +
        • Page player whileloading() calls now being throttled
        • +
        • Better page player click handling for IE 7
        • +
        +
      • + +
      + +
    • + +
    • +

      V2.95b.20100323 (Download archived version)

      +

      useFlashBlock, better handling of time-out/errors (CSS-based SWF repositioning options for unblocking on time-out), "play MP3 button" demo, canPlayLink(), canPlayMIME(), eqData + waveformData for AAC/H.264 (movieStar) content, missing documentation and miscellaneous bug fixes.

      + +
        + +
      • +

        API Updates

        +
          +
        • New soundManager.useFlashBlock (disabled by default) - enables CSS classes assigned to SWF container indicate start-up state (ok/error/blocked), allowing positioning/display of SWF for unblock cases and successful recovery from unblocking. Built into homepage + (most) demos. Updated flashblock demo as well.
        • +
        • playableClass attribute eg. <a href="foo.php" class="inline-playable">, allowing URLs without .mp3 to be picked up
        • +
        • New soundManager.canPlayLink() + canPlayMIME(), ability to check <a href="foo.php" type="audio/mp3"> for example
        • +
        +
      • +
      • +

        Bug fixes

        +
          +
        • soundManager.play() type check fix, instanceof Object vs. typeof x === 'Object' (typo)
        • +
        • computeSpectrum() can access waveform and eq (spectrum) data for movieStar (AAC/MP4, netstream-based) objects, too.
        • +
        +
      • +
      • +

        Miscellaneous

        +
          +
        • Moved old demo code using $() to _id(), _$ in soundManager2 to _id() to avoid potential jQuery (and other $-based library) collisions
        • +
        • Make new SoundManager('/path/to/swfs/'); actually work.
        • +
        • Flash time-out (flash blockers) vs. security failure detection/other error cases is smarter on the SM2 homepage now
        • +
        • New "MP3 player button" demo
        • +
        • Removed old IE onclick handler fix in several demos for non-MP3 links
        • +
        • eqeqeq = true for jslint, why not.
        • +
        +
      • + +
      +
    • + + +
    • +

      V2.95b.20100101 (Download archived version)

      +

      New features: Flash movie debugging in SWF via debugFlash (default:false), SMSound.eqData = { left:[], right:[] }, code tidying and debug output clean-up

      + +
        + +
      • +

        API Updates

        +
          +
        • New soundManager.debugFlash property, enables debug messages from within flash (output to flash movie). Useful for troubleshooting start-up, security issues etc. Flash debug output example
        • +
        • SMSound.eqData now has left and right channels - e.g. eqData = { left: [], right: [] } - was previously a single array: eqData = []; Backwards-compatibility is maintained for now as eqData[i] still works with the new structure.
        • +
        +

        Bug fixes

        +
          +
        • stream = true is no longer automatically set when SMSound.play() is called and readyState == 0, as it was breaking the stream:false case where playback should not start until the sound has fully-loaded.
        • +
        • soundManager.reboot() forces recreation of object/embed rather than old method of node remove/re-append (in case other options changed, eg. debugFlash was false, but assigned to true after an error during start-up.)
        • +
        +

        Miscellaneous

        +
          +
        • Review of all SM2 debug output, more concise and informative messaging - especially around start-up troubleshooting/error debugging, security sandbox errors, SWF 404 case etc.
        • +
        • Code formatting clean-up (via jsbeautifier.org) + soundmanager2.js tested and passes JSLint, Edition 2009-11-22 + options: /*jslint undef: true, bitwise: true, newcap: true, immed: true */
        • +
        • Better organization/use of strings for debug output
        • +
        • New canvas-based favicon VU meter demo for home page, 360 player and muxtape-style player demos where supported (Firefox and Opera, currently.) Firefox 3.6 is disappearing support for XBM images, which were previously used.
        • +
        +
      • + +
      +
    • + +
    • +

      V2.95a.20090717 (Download archived version)

      +

      New features: onready(), fast polling, flash blocking demos etc.

      + +
        + +
      • +

        API Updates

        +
          +
        • New soundManager.onready(myFunction[,scope]) method, for asynchronous queueing of onload()-style handlers. Fires when SM2 has finished initialising. Accepts an optional scope parameter to apply to handler; if none given, window object is used. A "status" object is passed to your handler (can be ignored) which includes a success boolean indicating whether SM2 loaded OK or not. Handlers added via onready() after successful initialisation will fire immediately.
        • +
        • New soundManager.oninitmovie() event callback, single assignment similar to onload(). Fires when the flash movie has first been written to (or read from) the DOM. Used internally for a flashblock-handler-related example, custom timeout condition.
        • +
        • New soundManager.useFastPolling property (false by default), enables 1 msec Flash 9+ timer for highest-possible whileplaying() and related JS callback frequency (default is 20 msec.) Use with soundManager.useHighPerformance = true for best performance, frame rates while updating the UI via whileplaying() etc.
        • +
        • New sound option (soundManager.defaultOptions): multiShotEvents (default:false) - enable support for multiShot-style events (currently onfinish() only). Eg. When mySound.play() is called three times, onfinish() will subsequently fire three times.
        • +
        +
      • + +
      • +

        Bug fixes

        +
          +
        • createSound now writes a warning to debug output if the sound ID is a number, or is a string starting with a numeric character. Because SMSound objects are stored in soundManager.sounds[], while not syntactically invalid, numeric IDs will be treated as array indices and are likely to break things.
        • +
        +
      • + +
      • +

        Miscellaneous

        +
          +
        • New flashblock / "click to flash" demo, example of handling blocked conditions and graceful recovery when flash is initially blocked until user chooses to allow it.
        • +
        • Cross-domain-scripting enabled SWF (using allowDomain("*")) included in swf/ directory (in its own .zip file.) Use when you must have domain A loading SM2 .SWF from domain B, or for testing etc and can't compile your own custom x-domain SWF from source.
        • +
        • Documentation, layout and menu tweaks
        • +
        +
      • + +
      +
    • + +
    • +

      V2.95a.20090501 (Download archived version)

      +

      Lots of updates.

      + +
        + +
      • +

        API Updates

        +
          +
        • Added soundManager.allowFullVideo for full-screen video playback, triggered by double-clicking. Also, related soundManager.onfullscreenchange event handler.
        • +
        • Updated waveformData to include stereo channels. Now an object literal instead of a single array. New format: SMSound.waveformData = { left: [], right: [] }
        • +
        • New SMSound.ondataerror() (flash 9+) handler for cases where waveform/eq data is inaccessible due to other flash movies in the current browser which have loaded sound. (Flash must have security permissions to "read" all data currently being output, long story short. Having a YouTube tab open can cause this, for example.)
        • +
        • New isBuffering property for MovieStar (MP4 audio/video) content, related onbufferchange() event handler (sound object)
        • +
        • New bufferTime property for MovieStream content. Defines seconds of data to buffer before playback begins (null = flash default of 0.1 seconds; if AAC playback is gappy, try up to 3 seconds.)
        • +
        +
      • + +
      • +

        Bug fixes

        +
          +
        • Off-screen flash with wmode set to non-default value (transparent/opaque) will break SM2 for non-IE on Windows, time-out error style. SM2 will now revert wmode to default for this case (losing transparency/layering of movie) - or set soundManager.flashLoadTimeout to 0 and SM2 will retain wmode, but must now wait potentially infinitely for flash to load (until user scrolls it into view.) soundManager.specialWmodeCase reflects if this fix has been applied after init time.
        • +
        • Calling soundObject.load() after directly assigning a value to soundObject.url should now work as expected.
        • +
        +
      • + +
      • +

        Miscellaneous

        +
          +
        • Shiny new "360° UI" canvas + visualization demos (Warning: Beta-ish code.)
        • +
        • Experimental SM2 exception/error handling + stack trace reporting added, an attempt to make custom errors thrown from SM2 more meaningful (ideally showing the user's call to SM2 where things went wrong in the stack.)
        • +
        • Calling soundObject.load() after directly assigning a value to soundObject.url should now work as expected.
        • +
        • soundManager.useHighPerformance update: Now false/disabled by default. Strange bug with JS/flash communication breaking with wmode=opaque on flash, specific (?) to Firefox on windows. SM2 does not normally set wmode. When useHighPerformance = true, wmode=transparent will be used on the flash movie by default.
        • +
        • Tweaks related to position, whileplaying(), playState, buffering and state resetting when sound has finished playing (fixes for a few edge cases if replaying or reusing the same sound or video.)
        • +
        • Better code/feature separation and clean-up on inline player, Muxtape-style demos
        • +
        +
      • + +
      +
    • + +
    • +

      V2.94a.20090206 (Download archived version)

      + +
        + +
      • +

        API Updates

        +
          +
        • New isBuffering property, related onbufferchange() event handler (sound object)
        • +
        • New soundManager.reboot() method (experimental): Shut down and re-initialise SoundManager, remove and recreate flash movie (possibly handy for cases where you want to restart after flashblock-type whitelisting, etc.)
        • +
        • New soundManager.flashLoadTimeout property, milliseconds SM2 will wait for flash movie callback before failing and calling soundManager.onerror() during start-up/init. If set to 0, SM2 will wait indefinitely for flash (good for reboot/flashblock-type scenarios.)
        • +
        +
      • + +
      • +

        Bug fixes

        +
          +
        • Reverted Firebug 1.3 console.log().apply() hack, was breaking console.log() under IE 8 RC1 (as used with debug mode.) Firebug 1.3 seems to have a bug, occasional "console undefined" error.
        • +
        • Fixed a dumb flash 9/AS3 bug with setVolume() passing an extra parameter to flash.
        • +
        • soundManager.useHighPerformance update: Now false/disabled by default. Strange bug with JS/flash communication breaking with wmode=opaque on flash, specific (?) to Firefox on windows. SM2 does not normally set wmode. When useHighPerformance = true, wmode=transparent will be used on the flash movie by default.
        • +
        +
      • + +
      • +

        Miscellaneous

        +
          +
        • Tweaked project page / documentation UI, nicer code/debug formatting
        • +
        • Misc. API documentation fixes, improvements
        • +
        +
      • + +
      + +
    • + + +
    • +

      V2.93a.20090117 (Download archived version)

      + +
        + +
      • +

        General Updates

        +
          +
        • New SoundManager 2 start-up debugger / troubleshooting tool, built into project home (see troubleshooting, and a standalone version - see "troubleshoot/" directory of download package)
        • +
        • New soundManager.getMemoryUse() method (flash 9+.) Returns RAM use for flash plugin (appears to be browser-wide, possibly system-wide by design.) Video demo includes an example RAM use monitor.
        • +
        • highPerformance disabled by default for Firefox on Windows due to reports of bugs preventing SM2 start-up in some cases. To override the disabling safety check, set soundManager.useHighPerformance = 'always';
        • +
        • Updated API demo testcases (API Demo page)
        • +
        +
      • + +
      • +

        Bug fixes

        +
          +
        • Fixed Flash 8 bug with autoLoad/autoPlay and playState not being correctly set.
        • +
        • Fixed a bug with onfinish() not firing when autoPlay is used.
        • +
        • Fixed a bug with pan and volume defaults not being correctly inherited and handled
        • +
        • console[method]() now uses apply(), preventing possible Firebug 1.3-related scope issue where this != console
        • +
        • IE now appends (vs. destructive .innerHTML write) SWF movie to target element, appends DIV with className "sm2-object-box"
        • +
        +
      • + +
      + +
    • + + +
    • +

      V2.92a.20081224 (Download archived version)

      + +
        + +
      • +

        General Updates

        +
          +
        • Note: Flash (SWF) assets moved to swf/ subdirectory, starting with this version.
        • +
        • Updated design on API demo page, new looping example
        • +
        +
      • + +
      • +

        Bug fixes

        +
          +
        • Improved regular-expression-based URL detection for canPlayURL(), flash 8/9 and MovieStar (video) formats
        • +
        • Improved soundManager.url-related normalizeURL() handling. If GET parameters are in the URL including the SWF, it will be left alone.
        • +
        • Fixed out-of-bounds issue with setPosition().
        • +
        • Fixed a setPosition(0) and before onfinish()-related issue, so it is possible to nicely loop sounds from within onfinish() - see looping a sound (API demo)
        • +
        • Fixed an error condition where destroying a loading sound would not terminate the HTTP request, relating to error cases involving netStream.close().
        • +
        +
      • + +
      + +
    • + + +
    • +

      V2.91a.20081205 (Download archived version)

      + +
        + +
      • +

        General Updates

        +
          +
        • Completely-redesigned project page, multiple pages/sections, more-legible grid-based documentation layout
        • +
        • Code verified with jslint. 0 errors reported with default settings, Edition 2008-11-26
        • +
        +
      • + +
      • +

        Bug fixes

        +
          +
        • True XHTML DOM compatibility. Rewrote createMovie() to use standard DOM createElement() methods, vs. previous writing to .innerHTML method which caused exceptions with XHTML documents.
        • +
        • Special-cased useHighPerformance for Firefox 2 only, disabling it as it seems to be problematic. Further research pending.
        • +
        • Removed try .. catch error handling within soundManager.onload(), catching exceptions when calling user-defined onload handler. Errors should now fall through as normally expected.
        • +
        • Fixed several setPosition()-related bugs (NaN/undefined error, seeking to invalid position, position inconsistencies with pause/resume)
        • +
        +
      • +
      + +
    • + +
    • +

      V2.90a.20081028 (Old documentation theme) - Download archived version

      + +
        +
      • +

        API: Bug fixes

        +
          +
        • Fixed numerous Flash AS3 exceptions for Flash 10 plugin users of SM2 with Flash 9 .SWF
        • +
        • Fixed a setPosition() bug where position > duration would stop sounds playing in other tabs
        • +
        • Fixed createSound(); play(); destruct(); sequence to correctly stop sound under Flash 9
        • +
        • Changed Flash 9 onload() to properly pass boolean "false" on load failure, same as Flash 8
        • +
        • Fixed autoLoad=true bug with Flash 9 movieStar (MPEG4) content, now pauses after creating
        • +
        +
      • + +
      • +

        API: New shiny!

        +
          +
        • soundManager.useHighPerformance: Minimize JS/Flash lag, ~3x whileplaying() frequency! (Most noticeable on Mac OS X, and Safari on Windows? Investigating IE cases.)
        • +
        • soundManager.pauseAll() / soundManager.resumeAll(): Global pause/resume
        • +
        • soundManager.muteAll() / soundManager.unmuteAll(): Global mute/unmute
        • +
        +
      • + +
      • +

        MovieStar MPEG4 video support! (experimental)

        +
          +
        • soundManager.createVideo() / soundManager.destroyVideo() for MovieStar MPEG4 formats!
        • +
        • Uses same SMSound instance object and API methods/options as regular sounds, with a few extra parameters
        • +
        • soundManager.useVideo will show video when applicable (false/disabled by default)
        • +
        • SMSound.onmetadata: Meta data handler for MPEG4 video files - provides dimensions (w/h)
        • +
        +
      • + +
      • +

        Miscellaneous

        +
          +
        • Removed experimental flashBlock support. Considering eliminating SM2 timeout-based onerror() behaviour in favour of asynchronous loading (eg. user may initially block, notice flash movie and take action to unblock many seconds after loading - thus, flash movie eventually loads and can eventually trigger successful SM2 init.)
        • +
        • Modified pause() and resume() to only affect playing sounds (eg. playState != 0).
        • +
        +
      • + +
      + +
    • + + + +
    • +

      V2.80a.20081005

      + +
        +
      • +

        API: Bug fixes

        +
          +
        • Changed Flash 8 onload() boolean "loaded" to be based on sound duration being >0, better test of load success.
        • +
        • Modified Flash 9 onload() to include boolean result for success/fail, parity with Flash 8
        • +
        +
      • + +
      • +

        API: New shiny!

        +
          +
        • +

          Added experimental Flash 9.0r115+ (flash codename "MovieStar", Flash 9 Update 3) MPEG4 / HE-AAC support (audio only.) A subset of MPEG4 should be supported including FLV, MP4, M4A, MOV, MP4V, 3GP and 3G2 files. Feature is disabled by default.

          +
            +
          • New soundManager useMovieStar property, controls feature availability (currently disabled by default.)
          • +
          • New SMSound option, isMovieStar, configures feature behaviour on a per-sound basis. Default (null) is to auto-detect .mp4, .mov etc. in URL and enable if found, but can also be forced on or off (true / false).
          • +
          • Video-based formats use the Flash 9 NetStream and NetConnection objects, whose API differs slightly from the Sound object. Seeking is limited to video key frames and is not as smooth as an MP3.
          • +
          • Audio playback has been seen to pause during certain events (window scrolling, etc.) while playing MovieStar formats. It doesn't appear to be from CPU overload. More investigation is needed.
          • +
          • Basic load, progress, onload, whileplaying API support is provided (page player demo includes MP4 and FLV formats). Not all methods (eg. setVolume) have been tested.
          • +
          • .AVI is not included by default, but may work if the format is actually MPEG4-based.
          • +
          • Format limitation note: EQ, peak and spectrumData are not available with MovieStar content. This may be a Flash 9/AS3 limitation.
          • +
          +
        • +
        +
      • + +
      • +
          +
        • +

          Miscellaneous

          +
            +
          • Added CSS checks to page player: "exclude" and "playable" to override default URL matching behaviour.
          • +
          +
        • +
        +
      • + +
      + +
    • + +
    • +

      V2.78a.20080920

      + +
        +
      • +

        API: Bug fixes

        +
          +
        • Added SoundLoaderContext parameter to load(), Flash should now check policy-related (crossdomain.xml) files when loading resources from remote domains. Should fix previous security exception warnings when trying to access ID3 and/or waveform/EQ data. See related SoundLoaderContext documentation (ActionScript 3)
        • +
        • Fixed a bug with load(), was improperly expecting an options object - now works properly.
        • +
        +
      • +
      • +

        API: New shiny!

        +
          +
        • Added soundManager.altURL property (and useAltURL conditional) for convenient offline and other URL switching cases (dev vs. production environments, etc.)
        • +
        +
      • +
      • +

        Miscellaneous

        +
          +
        • Renamed internal soundManager and SMSound self closure references to _s and _t, respectively, to avoid potential conflicts with others' code
        • +
        • Moved self-destruct to use window.onunload instead of onbeforeunload, given the latter event can be caught and canceled if desired by the user
        • +
        • Inline player demo: Added autoPlay option
        • +
        • "Basic" demo directory (demo/basic/) moved to demo/api/, added load()-related testcase
        • +
        +
      • +
      + +
    • + +
    • +

      V2.78a.20080920

      + +
        +
      • +

        API: Bug fixes

        +
          +
        • Added SoundLoaderContext parameter to load(), Flash should now check policy-related (crossdomain.xml) files when loading resources from remote domains. Should fix previous security exception warnings when trying to access ID3 and/or waveform/EQ data. See related SoundLoaderContext documentation (ActionScript 3)
        • +
        • Fixed a bug with load(), was improperly expecting an options object - now works properly.
        • +
        +
      • +
      • +

        API: New shiny!

        +
          +
        • Added soundManager.altURL property (and useAltURL conditional) for convenient offline and other URL switching cases (dev vs. production environments, etc.)
        • +
        +
      • +
      • +

        Miscellaneous

        +
          +
        • Renamed internal soundManager and SMSound self closure references to _s and _t, respectively, to avoid potential conflicts with others' code
        • +
        • Moved self-destruct to use window.onunload instead of onbeforeunload, given the latter event can be caught and canceled if desired by the user
        • +
        • Inline player demo: Added autoPlay option
        • +
        • "Basic" demo directory (demo/basic/) moved to demo/api/, added load()-related testcase
        • +
        +
      • +
      + +
    • + +
    • +

      V2.77a.20080901

      + +
        + +
      • +

        API: Bug fixes

        +
          +
        • Fixed some mute() / unmute()-related bugs, global muting should now work properly. Added some related demo page examples.
        • +
        • Removed comment on flash9Options merging code, was previously new and didn't actually work as it was commented out. Oops. :D
        • +
        • Added experimental Flashblock exception handling (mozilla/firefox extension), "notification bar"-style UI which can message and assist users in unblocking SM2 .swf. Configured via soundManager.flashBlockHelper object, currently disabled by default.
        • +
        • Modified soundManager.destroySound() and sound.destruct(), fixed a bug with these methods and flash's unloading of sounds which was breaking things. Hopefully fixes destroying sounds within whileplaying() and related event handlers, too.
        • +
        • Modified flash 9 "peak data" code to only set the data if the feature is actually enabled.
        • +
        • Modified soundManager._debug() to list all sound object details, instead of just ID/URL.
        • +
        +
      • + +
      + +
    • + +
    • +

      V2.76a.20080808

      + +
        + +
      • +

        API: Bug fixes

        +
          +
        • Fixed some memory "leaks" / garbage collection issues. RAM allocated to load sounds previously wasn't freed until page unload; now memory should be garbage collected some time after sound.unload() and/or soundManager.destroySound()/sound.destruct() methods are called. In certain cases, Flash sound objects may be destroyed and re-created (transparent to the JS-side) to release memory. Note that garbage collection is not instantaneous, and is affected by CPU/system load and other variables.
        • +
        • Fixed an issue with play() not working on sounds created with autoPlay.
        • +
        • Fixed SM2 to work under proper XHTML (served as application/xhtml+xml MIME type). Rewrote object/embed code again, now version-agnostic for IE (no CLSID parameters.)
        • +
        • Corrected reported loadFromXML() bug, multiple loadFromXML() calls should work.
        • +
        +
      • + +
      • +

        API: New shiny!

        +
          +
        • New useWaveformData and useEQData sound options, providing access to raw waveform and sound frequency/EQ spectrum data via sound.waveformData and sound.eqData.
        • +
        • Renamed useSpectrumData to useWaveformData - if using waveform stuff currently, make sure you update your code!
        • +
        • Added soundManager.features object, which reflects the "support" state for peakData, waveformData and eqData. Handy for current and future version/support branching.
        • +
        +
      • + +
      • +

        API: Miscellaneous

        +
          +
        • New flash9Options configuration object for logical separation. When Flash 9+ is used, these options are merged into the defaultOptions object.
        • +
        • Added allowDomain() stubs and documentation to .as source for allowing .swf on external domains to work (recompile of .swf required)
        • +
        +
      • + +
      • +

        "Page As Playlist" demo: Updates

        +
          +
        • Added "favicon" VU meter display option (Flash 9+ only, experimental, currently Firefox/Opera only)
        • +
        • More-efficient RAM use via unload() and destruct() sound methods, discarding inactive sounds and freeing RAM as appropriate.
        • +
        • Added useEQData, showing sound spectrum (frequency range) instead of raw waveform
        • +
        • Added fillGraph config option, allowing solid waveform graphs instead of only peak points
        • +
        • Fixed playNext bug where same track couldn't be played twice in a row.
        • +
        • Fixed duplicate URL bug; items with identical MP3 URLs will now work. (Previously, URL was the ID for items and thus had to be unique. Lookup is now done by object.)
        • +
        • Modified MP3 URL search to include URL parameters, characters after ".mp3"
        • +
        +
      • + +
      • +

        Other updates

        +
          +
        • Demo code clean-up, externalised CSS, prettier demo layout and code color highlighting
        • +
        +
      • + +
      +
    • + +
    • +

      V2.75a.20080707

      +
        +
      • Flash 9 support! (soundmanager2_flash9.swf) - multiShot now actually works (layering/"chorus" effects on sounds), new spectrumData and peakData API features. All existing API features should have parity.
      • +
      • Added soundManager.flashVersion property. Flash 8 is the supplied default.
      • +
      • Modified soundManager.url to require only a path, eg. /path/to/soundmanager-swfs/ to allow loading of varying .SWF versions.
      • +
      • Basic (API) demo: Updated multiShot/Flash 9 behaviour documentation
      • +
      • Page player demo: Added optional spectrum and VU (spectrumData/peakData) features
      • +
      • MPC + animation demos: Modified to use Flash 9 (demo improved multiShot feature)
      • +
      • Flash 9 behaviour differences: +
          +
        • multiShot properly allows play() to be called multiple times on a sound object, creating desired "chorus" effect. Will call onfinish() multiple times, but whileplaying() etc. are called only for the first "play instance" to avoid complications.
        • +
        • New soundSpectrum and peakData sound features (spectrum graph / "VU" meter-style data) available
        • +
        • Sounds can be actually unloaded ("null" MP3 no longer needed to cancel loading of an MP3), but URL cannot be changed without destroying and recreating the related Flash sound object. The Flash 9 version does this to maintain API consistency.
        • +
        +
      • +
      • New + improved documentation/project page, updated 2-column layout with content filters, "Get Satisfaction" integration and self-update checks (and a light-switch-related easter egg.)
      • +
      +
    • + +
    • +

      V2.5b.20080525

      +
        +
      • Added waitForWindowLoad for delayed init
      • +
      • Added onpause() and onresume() event handlers
      • +
      • Added mute() and unmute()
      • +
      • Updated demos, revised documentation
      • +
      +
    • + +
    • +

      V2.5b.20080505

      +
        +
      • To improve startup time, soundManager.go() (createMovie() alias) now fires at onDOMContentLoaded() by default if supported. (Otherwise, falls back to window.onload().)
      • +
      • Improved initialisation routine - soundManager.onerror() is called when the Flash init "times out." Specifically, onerror() is called when Flash fails to make an ExternalInterface (Flash-> JS) call to SM2 within 1 second of window.onload() firing.
      • +
      • Added logic to handle special Safari delayed init case (Flash not loading when in a new, unfocused tab until focused) as a exception to the above.
      • +
      • Added better exception handling + debug messaging for initialisation failure cases (Flash security restrictions due to loading from local file system, no flash support, no ExternalInterface support etc.)
      • +
      • Updated .swf appendChild() target to use best-to-worst options: (document.body || document.documentElement || document.getElementsByTagName('div')[0])
      • +
      • Safari console[log|warn|error]-style messages are now properly formatted.
      • +
      • Added tons of semicolons to closing braces, eg. };
      • +
      • "No-debug", minified version of SM2 included: soundmanager2-nodebug-jsmin.js (17.4 KB, down from full size of 35 KB.) With Gzip compression, file size is ~6 KB. (Commented, debug-enabled version compresses to 10 KB with Gzip.)
      • +
      +
    • + +
    • + +

      V2.5b.20080501

      +

      Warning: A little experimental too, read details below.

      +

      Changelog:

      +
        +
      • Rewrote SoundManager initialisation: "Way faster." Communication now initiated from Flash, verification callback then performed by JS; far faster, hopefully more-reliable (TBD.) Init time drastically reduced from seconds to milliseconds in most cases, dependent primarily on Flash movie load rather than window.onload().
      • +
      • Above change also fixes Safari "loading SM2 in background tab" issue, where Safari does not init Flash until background tab comes into focus (when a link is opened in a new, non-focused tab.)
      • +
      • Current drawback: Difficult to determine, save for falling back to window.onload() plus focus methods due to above issue, whether SM2 is actually available or not (ie., soundManager.onerror() will not likely be called as in past.) However, the supported() method will correctly reflect if SM2 has successfully initialised, for example.
      • +
      • Added sandbox/security model code; SM2 can now tell if it is restricted to either local or internet access only, for example. Helpful in potential debugging errors, plus viewing demos off the local filesystem should no longer throw init errors requiring whitelisting (seemingly due to the new initialisation method.) Win!
      • +
      • Opera 9.27 has been noted to have some bugs relating to ExternalInterface, seems to be unable to make calls from ActionScript-level methods using setTimeout() or setInterval(). As a reulst, SoundManager 2 events like onfinish(), whileplaying() and onfinish() can be sporadically called or missed altogether. No known workaround at this time, but Opera 9.5 (beta 2) does not have this issue. Popular MP3 "mix tape" site muxtape.com uses similar techniques for JS-Flash communication and appears to suffer from the same problem.
      • +
      • Warning: Random crash issue noticed when using IE 6 + 7 and this demo page, calling createSound() when soundManager.defaultOptions.autoLoad = true; from within soundManager.onload(), for creating + preloading the tab/theme switch sounds. Removing autoLoad=true (leaving the default of false) fixed the crash. Exact reason not determined, perhaps recursive calls or pre-onload issue (?), seems to be isolated to the home page. MPC demo uses autoLoad also, but did not crash. Mentioning just in case.
      • +
      • Updated Muxtape-style demo: More themes, load/security debugging info etc.
      • +
      +
    • + +
    • + +

      V2.2.20080420

      +

      Changelog:

      +
        +
      • More demos! "Page as a playlist" (muxtape.com-style) example, "Make MP3 links playable inline" demo
      • +
      • Corrected onStop() handler inheritance/overriding behaviour (was incorrectly checking defaultOptions)
      • +
      • Added debug output of options object for createSound() calls. Full options (result of merging global default + sound-instance-specific options) displayed, helpful in troubleshooting. Event handler function code is intelligently (hopefully) displayed, truncated at 64 characters of first block or end of line, whichever comes first.
      • +
      • Removed most HTML markup from non-HTML (eg. console) _writeDebug() calls
      • +
      • soundManager.destruct() writes to console, to be consistent
      • +
      + +
    • + +
    • + +

      V2.1.20080331

      +

      Changelog:

      +
        +
      • Modified createSound() to return a sound object if successful (more logical)
      • +
      • Updated setPosition() method and added position option parameter, documentation + demo (bugfix)
      • +
      • Corrected createSound() and play() sound option inheritance/overriding behaviour (eg. position) to work as expected (most to least important: Method call options -> sound object instance options -> SM2 global options)
      • +
      • Updated deleteSound() so Array.splice() is used instead of delete, the latter doesn't cause Array.length to update (bugfix)
      • +
      • Modified debug=alert to only work when debug mode is enabled (potential annoyance aversion)
      • +
      • Modified togglePause() to use position option parameter rather than undocumented offset (oops :D)
      • +
      • Added supported() convenience method (indicates pass/fail after SM2 has initialised.)
      • +
      • Added disabling debug calls from Flash (performance)
      • +
      • Added URL hash updating/bookmarking and page title updating to jsAMP demo app
      • +
      • Updated project page layout
      • +
      + +
    • + +
    • + +

      V2.0b.20070415

      +

      Changelog:

      +
        +
      • Added destroySound() method
      • +
      • Made debug output slightly less-verbose (commented out)
      • +
      • Safety tweak for position-related Flash bug when loading new sounds
      • +
      • Highly-expanded documentation (SMSound events + properties, examples, caveats, FAQs etc.)
      • +
      • Added time-sensitive light/dark theme for documentation
      • +
      + +
    • + +
    • + +

      V2.0b.20070201

      +

      Second beta?

      +

      Changelog:

      +
        +
      • Fixed stopAll() bug (previously broken)
      • +
      • Added nullURL parameter
      • +
      • Updated documentation
      • +
      +

      V2.0b.20070123

      +

      V2.0b.20070118

      +

      V2.0b.20070115

      +
    • + +
    • +

      V2.0b.20070107

      +

      First beta

      +
    • + +
    • +

      V2.0a.20060904

      +

      Prerelease alpha

      +
    • + +
    + + + + +
    + +
    HTML5 Audio: Support updates, technical notes, quirks, bugs and annoyances
    + +

    Note: This section is archived content and has been rolled into Revision History.

    + +

    As of the V2.97.20111220 release of SM2:

    + +
      + +
    • +

      Multiple URLs (and/or multiple MIME types) can be specified when creating a sound, thus allowing for better native HTML5 support between OGG, MP3 and others. See SMSound.url for details.

      +
    • + +
    • +

      Support for "audio sprites" has been added in the form of from and to sound options. See the audio sprite demo for a live example.

      +
    • + +
    • +

      Added soundManager.html5PollingInterval, for increased whileplaying() callback frequency (higher framerates.) Excludes mobile (eg., iOS) by default.

      +
    • + +
    • +

      Fixed Audio() object src property re-assignment bug seen in createSound()->play().

      +
    • + +
    • +

      mySound.load({onload:function(){}}) callback fixed so it works.

      +
    • + +
    • +

      onload() now called immediately when load({onload:function(){}}) is used on a sound with the same URL which has already loaded.

      +
    • + +
    • +

      onstop() now mimics onfinish() in terms of sequence. HTML5 sets position to 0, but retains pre-stop() position property value (like Flash does.)

      +
    • + +
    • +

      Amazon Kindle Fire UA looks like Safari on OS X 10.6.3, but does not have broken HTML5 audio (i.e., intermittent playback failure) like the "isBadSafari" case.

      +
    • + +
    • +

      Side note: iOS ignores volume, always returns value of "1" (at least, on iOS 4 and present iOS 5 releases.) See related notes.

      +
    • + +
    + +

    As of the V2.97.20111030 release of SM2:

    + +
      + +
    • +

      Fixes for HTML5 unload() on Webkit (connection was not closing) due to src being set to '' (OK only in Firefox, presently?) vs. an "empty" URL.

      +
    • + +
    • +

      HTML5 suspend events are now listened for and fired via SMSound option onsuspend(). This event may be the best way to detect when mobile Safari (eg. iOS) is blocking autoplay-style behaviour, and user interaction is required to start or resume playback. (iOS does not allow auto-play of audio; user interaction is required for audio playback to start.)

      +
    • + +
    • +

      Added try...catch for dumb IE 9 Audio() "not implemented" error in Windows server case without "desktop experience" installed, means no HTML5 audio/video support. Hat tip: Modernizr issue 224.

      +
    • + +
    + +

    As of the V2.97.20110801 release of SM2:

    + +
      +
    • A regression was introduced in V2.97.20110706 where SM2 would fail to start in HTML5-only mode on supported desktop browsers when flash was disabled or not installed, eg., Safari on new Macs or IE 9 without flash. (iOS was not affected.) This has been fixed with the 2.97.20110801 release.

    • +
    • +

      soundManager.useHTML5Audio is now true by default; however, soundManager.preferFlash is also true and HTML5 browsers will still attempt to use flash for playing MP3/MP4 by default, if those formats are marked as "required".

      +

      If you wish to have 100% HTML5 mode in more cases, set soundManager.preferFlash = false. Presently, the MP3 links and MP3 button SM2 demos are more HTML5-friendly and will serve as a test for exposing bugs that may be in the wild.

      +
    • +
    • +

      soundManager.html5Test has been relaxed to use (probably|maybe) for Audio's canPlayType() test (previously, was only "probably") - so formats will be more likely to work on HTML5-only devices that conservatively report "maybe" for MIME types like audio/mpeg; codecs="mp3" at this point.

      +
    • +
    • +

      Certain mobile and tablet-like devices are special-cased as preferring HTML5, and will ignore checking for flash altogether; this presently includes the iPad, iPhone and iPod, Palm Pre and Motorola Xoom.

      +
    • +
    • +

      The HTML5 audio "loadeddata" event triggers an SMSound onload() event, which now fires whileplaying() and tries to pass identical bytesLoaded, bytesTotal parameters so that UIs will correctly show the sound as fully-"loaded" - even if in truth, not all bytes have actually been fetched (depending on the browser and server, etc.) because of the ability to do arbitrary seeking.

      +
    • +
    • +

      The experimental soundManager.useGlobalHTML5Audio and soundManager.requireFlash properties were removed. Internally the global HTML5 audio logic still applies to iOS, but it does not seem to be necessary for other devices at this time.

      +
    • +
    + +

    As of the V2.97.20110706 release of SM2:

    + +
      +
    • HTML5 audio appears to have been fixed in Safari with Snow Leopard 10.6.8, the "pre-Lion release", from 06/2011. SM2 will now only blacklist Safari + OS X 10.6.3 through 10.6.7 as having broken HTML5 audio (intermittent load/playback failures), and falling back to Flash where available.

    • +
    • +

      New, experimental soundManager.preferFlash for handling "mixed-mode" HTML5 + flash cases. In the event HTML5 supports MP3/MP4 and preferFlash is true (and flash is installed), flash will be used for MP3/MP4 content while allowing HTML5 to play OGG, WAV and other formats etc.

      +

      Important note: Because HTML5 audio is still quirky and has bugs, preferFlash is true by default to help ensure MP3/MP4 play consistently. If set to false or flash is not available, "HTML5-only" mode will kick in and will apply to all formats.

      +
    • +
    + +

    As of the V2.97.20110424 release of SM2:

    + +
      +
    • HTML5 audio in Safari on Snow Leopard 10.6.3 through 10.6.9 (10.6.7 was released 03/2011) are blacklisted and will fall back to Flash. 10.6.8 and 10.6.9 are preemptive guesses. According to beta testers, OS X 10.7 ("Lion") has fixed the intermittent HTML5 audio load/playback issue.

    • +
    • new Audio(null) is no longer used for iOS, as iOS would attempt to load a URL called "null".

    • +
    • iOS 4.2 or 4.3 may have introduced new security restrictions around onfinish()->unload()->play() that prevents the "play-through" behaviour previously allowed in certain cases. The unload() attempts to nullify the audio's src attribute, breaking the future play() request. The Muxtape/button/link demos were affected by this, and have been fixed with this release. To prevent this issue in your own apps, avoid unload() and simply use onfinish()->play() for iOS.

    • +
    + +

    As of the V2.97.20110306 release of SM2:

    + +
      +
    • Testing suggests that auto-play ("auto-annoy?") does work on iOS 4.1, but are aggressively blocked as of iOS 4.2.

    • +
    • _resetProperties() when setting Audio().src, fix sound1.play() -> sound2.play() -> sound1.play() case on iOS 4.1 not correctly re-assigning original sound URL (related to global audio object.)

    • +
    • If no flash is detected, try forcing useHTML5Audio = true (eg. desktop safari on new Macs which don't come with Flash.) Related: flash detection code tweak.

    • +
    • isNaN() check for HTML5 loading (saw one under Safari, in testing).

    • +
    • Use new Audio(null) vs (), Opera 9.64 expects URL argument; throws WRONG_ARGUMENTS_ERR otherwise. Doesn't implement canPlayType() either, but both are fixed in future releases.

    • +
    + +

    As of the V2.97.20110123 release of SM2:

    + +
      +
    • New (experimental) soundManager.useGlobalHTML5Audio attribute, enabled by default for mobile + iOS. Enables use of a single audio object, re-used for loading and playing all sounds. iOS currently can only play one sound at a time, so this limitation is safe for now. The global object fixes previous regression of play-through/playNext()-style behaviours.

    • +
    • Sound recycling with new global audio feature should work better than in prior (development) versions.

    • +
    • Improved broken Safari/Snow Leopard HTML5 audio situation: HTML5 mode is no longer disabled - and if available, Flash is used to play MP3/MP4 content to work around known playback issues with native HTML5 audio.

    • +
    • New (experimental) soundManager.requireFlash property (default: false.) If true, prevents HTML5-only mode on devices with both HTML5 and Flash. May be useful when HTML5 is enabled (and can play MP3), but Flash is desired to play RTMP content etc. As of this version, will only use Flash for RTMP.

    • +
    • Fix for type:'audio/mp3' returning false on canPlay(). Timer update-while-paused tweak.

    • +
    • More event listeners, ignore events on destroyed sounds, improved event clean-up, "seek before load" fix

    • +
    + +

    As of the January 1, 2011 (V2.97a.20110101) and December, 2010 releases of SM2 (V2.97a.20101221):

    +
      +
    • The bytesLoaded and bytesTotal properties may become less-relevant under HTML5 due to non-linear HTTP downloading (using ranges and partials), but they are still provided under Firefox at this time.

    • +
    • Related to bytes loading/total, a sound's onload event may not always be fired (Mozilla currently discourage use of the DOM loaded event), again because of range requests and the ability to arbitrarily seek within a file.

    • +
    • Basic support for the W3 TimeRanges implementation of sound buffering (ie., loaded data) has been implemented. This gives an idea of "total time loaded", but again, is not necessarily sequential.

    • +
    • HTML5 audio is disabled for all versions of Safari (4 and 5) on Snow Leopard (OS X 10.6.3 - 10.6.5) until Apple fixes issues with audio loading and playback due to bugs in "underlying frameworks." See Webkit #32159. HTML5 audio in Safari on Windows (provided QuickTime is installed) does not have the same fatal bug.

    • +
    + +

    As of the October, 2010 release of SM2 (V2.97a.20101010):

    +
      +
    • HTML5 audio is disabled for all versions of Safari (4 and 5) on Snow Leopard (OS X 10.6.3 and 10.6.4) until Apple fixes issues with audio loading and playback due to bugs in "underlying frameworks." See Webkit #32159.

    • +
    + +

    As of the August, 2010 release of SM2 (V2.96a.20100822):

    +
      +
    • Safari 5.0.1 (533.17.18) on Snow Leopard (10.6.x) continues to show buggy HTML5 audio load/playback behaviour. Apple are aware of the regression, which began with Safari 4.0 on Snow Leopard (perhaps with the new QuickTime.) See Webkit #32159.

    • +
    • iPad/iPhone iOS4 will now play a sequence of sounds if using onfinish() to create/start the next (eg., the Muxtape-style playlist on the SM2 homepage will play through once the user starts it.) In any event, user interaction is always required to start the first sound.

    • +
    + +

    As of the June, 2010 release of SM2 (V2.96a.20100624):

    +
      +
    • Safari 5.0 (533.16) on OS X Snow Leopard (10.6.x) continues to show buggy HTML5 audio load/playback behaviour, same as with Safari 4.0.5 on Snow Leopard only - may be related to underlying QuickTime implementation (a guess, at this point.) SM2 will disable HTML5 audio support by default for this specific browser + OS combo. See Webkit #32159 for discussion + testcases.

    • +
    + +

    As of the May, 2010 release of SM2 (V2.96a.20100520):

    +
      +
    • Safari 4.0.5 on OS X Snow Leopard (10.6.x) appears to have an annoying bug where audio inconsistently fails to load / play; SM2 will currently disable or ignore the HTML5 feature on this exact browser + OS version. See Webkit #32159 for discussion + testcases. Note that Safari on OS X 10.5 "Leopard" and on Windows do not appear to have this bug; it seems to be limited to Snow Leopard, seen on OS X 10.6.3.

    • +
    • Some browsers (and iPad 3.2?) do not fire progress events, and/or do not implement bytesLoaded/bytesTotal-style attributes.

    • +
    • iPad 3.2 appears to be able to only play one sound at a time, and will terminate other sounds.

    • +
    • iPad 3.2 may also loop AAC+ (HE-AAC) and WAV sounds, perhaps not firing onfinish() and resetting the position to 0 each time, but is fine with MP3s. This has been observed, but not fully-tested.

    • +
    • Looping in HTML5 is either "infinite" or "none". A wrapper may be created for SM2 so that a number of loops can be specified, as with Flash. This is not yet implemented.

    • +
    • Panning (left/right channel balance) does not appear to be in HTML5.

    • +
    • Flash-only features such as ID3 tag reading, waveform and spectrum data will simply be ignored, and their related events will not fire on SMSound objects which are using HTML5.

    • +
    + +
    + + + + +
    + + +
    + + +
    + + + +
    + + + +
    + + + +
    + +
    + +
    + + +
    + + +
    + + +
    + + + + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/download/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/download/index.html new file mode 100755 index 00000000..25fb5a13 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/download/index.html @@ -0,0 +1,1452 @@ + + + +SoundManager 2: Download + + + + + + + + + + + + + + + + +
    + + + +
    + +
    + + +
    + +
    +
    +
    + +
    +
    +
    + +
    + +
    + +
    +

    Get SoundManager 2

    +

    Get the latest and greatest.

    +
    + +
    + +

    Download SoundManager 2

    + +

    Latest changes: 100% HTML5 mode by default, where available. Duration fix for Adobe FMS/RTMP server-based streaming. HTML5 unload, multiShot, autoPlay tweaks and more. See revision history for details.

    + +

    Download SoundManager 2.97a.20131201 or see on GitHub

    + +

    Performance tip: SM2's code size varies from over 150 KB (commented, debug-enabled) down to 11 KB (optimized) over HTTP; check the pre-optimized builds for details.

    + +

    Side reading + video talks, slides etc.

    + + + +
    + +
    + + +
    + +
    + +

    Revision History

    +

    Latest changes and archived notes from bug fixes, API updates, feature development etc.

    + +
    + +
    + +
    + +

    Revision History

    + +

    A changelog of sorts.

    + +
      + +
    • + +

      V2.97a.20131201 - 100% HTML5 mode by default. Duration fix for Adobe FMS/RTMP server-based streaming. HTML5 unload, multiShot and autoPlay tweaks. See GitHub commits.

      + +
        + +
      • + +

        Bug fixes

        + +
          + +
        • +

          + Adobe FMS (RTMP Server) fix: Invoke server-side getStreamLength() call to determine duration. (Red5 and other free RTMP servers use NetStream onMetaData() to pass duration.) +

          +
        • + +
        • +

          + Fix html5Unload() by loading a tiny base64-encoded data: URI WAVe file where supported. Elsewhere, use about:blank. This fixes errors in Chrome where the browser attempts to load the url "null" (a string.) +

          +
        • + +
        • +

          + D'oh! Fix HTML5 sprite regression where _oncanplay() was not being picked up & fired, sound would not play on first click. +

          +
        • + +
        • +

          + HTML5: Fix double-play bug with autoPlay: true. Correct edge case where onposition() items would sometimes be cleared if called/assigned before play(). +

          +
        • + +
        • +

          + ontimeout: function(status) {} callback parameter corrections. Fix missing error { type: 'INIT_TIMEOUT' } for missing/404 SWF case, and INIT_FLASHBLOCK for flashblock-specific case. +

          +
        • + +
        • +

          + HTML5: Apply volume to cloned sounds in HTML5 multiShot case. +

          +
        • + +
        • +

          + Fixed issue in _processOnPosition where the item in onPositionItems[i] can be undefined mid-loop if the callback that is triggered changes the length of the onPositionItems array, where onPositionItems.length becomes zero and there's an uncaught TypeError when trying to access item.fired the next time around. +

          +
        • + +
        • +

          + Fixed mute in HTML5. +

          +
        • + +
        • +

          + Fix onload in Firefox 3.6 with no flash (and yes, Firefox 25 is the current release. :D) +

          +
        • + +
        • +

          + Correct event removal (cloned HTML5 nodes) - onendedended +

          +
        • + +
        + +
      • + +
      • + +

        API Updates

        + +
          + +
        • +

          + Use 100% HTML5 mode by default, where available. preferFlash: false is now the default setting. Firefox does MP3 on Vista (and newer) via HTML5, and recently (via Firefox Aurora builds) on OS X - the last major hold-out. The vast majority of browsers now support MP3 via HTML5, thus reducing the reliance on Flash. +

          +
        • + +
        • +

          + Reboot into 100% HTML5 mode where supported if flash fails after loading, i.e., local/offline/file:// or other edge case. +

          +
        • + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + +
        • +

          + Fixed canPlayMIME() documentation example. +

          +
        • + +
        + +
      • + +
      + +
    • + + + +
    • + +

      V2.97a.20130512 - multiShot for polyphonic HTML5 clients. createSound() no longer requires an id. Auto-reboot() into 100% HTML5 mode where supported. HTML5 unload tweaks. (Download archived version)

      + +
        + +
      • + +

        Bug fixes

        + +
          + +
        • +

          + Init enhancement: If preferFlash: true but useFlashBlock: false (the default SM2 config) and flash timeout / blocked case occurs, SM2 will reboot reboot into 100% HTML5 mode if available so init can succeed. If flash block handling is enabled, user interaction will be required to whitelist the flash movie and init will be delayed until the SWF loads. +

          +
        • + +
        • +

          + Correct reboot() to allow 100% HTML5 mode when Flash was previously required due to preferFlash: true. Previously, soundManager.audioFormats.mp3.required = false; soundManager.reboot() did not result in 100% HTML5 mode under Firefox. Now works as expected. +

          +
        • + +
        • +

          + HTML5 unloading: Firefox was supposed to like assigning '' to Audio().url for canceling requests, unloading and destroying the decoder (perhaps only on <audio>, in retrospect?) - similarly, .src = null did not seem to work, possible request to ./ - undesirable. +

          + +

          + Now using more-conservative null URL for unload / destruct on webkit, iOS and others, and emptyURL for Firefox (user-customizable, 'about:blank' by default.) +

          +
        • + +
        • +

          + More HTML5 safety checks so that buffered can't go beyond 100%. +

          +
        • + +
        • +

          + Improve Flash 9 load() -> onload() failure case, when loading a non-404 (eg., HTTP 301 -> 200) with non-audio content. Improved messaging for Flash 8, Flash 9 + HTML5 with zero-duration (invalid / unsupported sound) case. +

          + +
        • + +
        • +

          + Fix flash-only (no HTML5 / useHTML5Audio: false) init case, e.g., running under IE 8. +

          +
        • + +
        • +

          + HTML5: Fix legacy "overloaded" case when soundManager.play('someID', 'some.mp3'); is called twice, second call would fail. This shortcut method is deprecated, and not recommended for use other than a conveience when in development / testing. +

          +
        • + +
        + +
      • + +
      • + +

        API Updates

        + +
          + +
        • + +

          + createSound() no longer requires an id property. If omitted, a unique id will automatically be generated for the new sound object with a prefix based on the SM2 setup option idPrefix. +

          + +

          + Specifying an id is useful if you want to look up the sound via getSoundById() - otherwise, you can simply use the object returned by the createSound() call. +

          + +
        • + +
        • + +

          + multiShot + multiShotEvents for HTML5 Audio()-based sounds, allowing layered / "chorused" playback if play() is called and multiShot: true has been specified to either createSound() or play(). Behaviour should mimic that of Flash 9. If multiShotEvents: true is specified, onfinish() will fire for each instance. Does not apply to mobile clients (e.g., iOS and Android) which only allow one sound to be played at a time. +

          + +

          + Implementation summary: A new Audio(src) instance is created with an onfinish listener, and played immediately. It is unloaded and destroyed when playback finishes. +

          + +

          + Caveat #1: If a position argument is provided eg., play({ position: 1000 }), the cloned Audio() instance must wait for a HTML5 canplay event before a seek and playback can begin. This may mean playback *could* have a slight delay vs. playing without the position offset. +

          + +

          + Caveat #2: The from/to parameters used for "sound sprites", e.g., { from: 500, to: 1500 }, are not presently supported under multiShot. +

          + +

          + Caveat #3: multiShot is not supported where only a single audio instance can be playing at once, e.g., iOS (iPhone/iPad) and some Android devices. +

          + +

          + Secondary instances are "fire-and-forget", similar to the Flash 9 implementation, and fire no events other than onfinish(). They do not respond to position, volume etc. after playback has begun. +

          + +
        • + + + + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + +
        • +

          + Remove debug-related complain() calls from -nodebug and minified script builds +

          +
        • + +
        • +

          + Force data: URLs over to HTML5. Catch unsupported case under 100% HTML5 mode, preventing attempt to use Flash fallback. +

          +
        • + +
        • +

          + Edge case: Fix error case if setup() called without arguments inline, before DOMReady / init etc. +

          +
        • + +
        • +

          + Tweak soundManager.getSoundById() to not throw error if ID omitted. Improve language on "not found" messaging. +

          +
        • + +
        • +

          + Warn on possible 32-sound channel Flash ceiling/limit, which can occur when Flash tries to begin playback and fails to start. +

          +
        • + +
        • +

          + Documentation updates: How Clients Download Audio (Flash/HTML5 progressive download vs. byte streaming) +

          +
        • + +
        • +

          + Improved API Examples page design, two-column layout with navigation +

          +
        • + +
        + +
      • + +
      + +
    • + + + +
    • + +

      V2.97a.20130324 - Fix for playlist/event chaining when using flashVersion = 8 with Flash Player 11.6.602.171. HTML5 iOS load() fix. Added Opus to audio formats. (Download archived version)

      + +
        + +
      • + +

        Bug fixes

        + +
          + +
        • +

          + Flash Player 11.6.602.171, released by Adobe on 02/26/2013, introduced an issue with SM2's default Flash 8 (flashVersion: 8) API-based JS/Flash interaction, where SM2 methods called from callbacks such as onfinish() would not work. This primarily broke methods used for playing sounds in sequence, serially loading a series of sounds and so on. (See discussion for more.) +

          + +

          + Note that this does not affect cases where soundManager.setup({ flashVersion: 9}) is being used; however, SM2 does use flashVersion: 8 by default. +

          + +

          + Specifically, Flash-initiated events (such as a sound finishing) make Flash -> JS calls to the SM2 API, which subsequently call user-specified event handlers. If the user-specified SM2 onfinish() handler immediately calls a SM2 method like play() that makes a JS -> Flash call, this call either silently fails or is blocked. Other JS + Flash libraries that use similar callback patterns may also be affected, if their SWF is built targeting the Flash 8 API. +

          + +

          + Suspecting a timing or recursion/stack issue, it was found that introducing a setTimeout(callback, 0) to user-specified SM2 callbacks like onfinish() restored sequential/playlist functionality. +

          + +

          + Flash Player 11.6.602.180, relased by Adobe on 3/12/2013, exhibits the same behaviour. To avoid additional hacks, SM2 applies this to all Flash 8-based API callbacks regardless of what version of Flash Player is installed. No regressions are anticipated as a result of this change. +

          + +

          + Alternately, this issue can be avoided by using soundManager.setup({ flashVersion: 9 }) as the Flash 9-based API does not appear to have this problem. +

          +
        • + +
        • +

          + HTML5: Fix for iOS load() case when using an auto-load and looping pattern (related discussion). +

          +
        • + +
        + +
      • + +
      • + +

        API Updates

        + +
          + +
        • +

          + HTML5: Added check for Opus (OGG-based audio codec, audio/opus). +

          +
        • + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + +
        • + +

          + Added documentation for Serving To Clients, and Mobile Device Limitations. +

          +
        • + +
        • + +

          + Minor SM2 homepage + documentation CSS tweaks (design) +

          +
        • + +
        • + +

          + This SM2 release is tagged "Mahalo Edition" to say thank-you, and because some SM2 work was done while on vacation in Hawai'i. Also, some new demo sound recordings from the beach on Kaua'i were added. +

          + + +
        • + +
        + +
      • + +
      + +
    • + + + +
    • + +

      V2.97a.20130101 - Strict Mode. Android 2.3 HTML5 fixes, cleaner debug output, improved default flashblock handling. Confirmed compatibility with Firefox WMF-based HTML5 MP3 support. New reset() method, reboot() tweaks (Download archived version)

      + +
        + +
      • + +

        Bug fixes

        + +
          + +
        • +

          + HTML5: Reset last URL and load state for "singleton" (global HTML5 audio) case, on iOS + Android <= 2.3 for specific use case - createSound() -> play() -> destruct() -> createSound() -> play() with same URL/parameters. +

          +
        • + +
        • +

          + HTML5: Fix for Android 2.3 / Nexus 7 - they work better with the singleton HTML5 audio() instance as well, same as iOS, for chained (i.e., playlist-style) playback cases. +

          +
        • + +
        • +

          + soundManager.setup() now allows html5Test (regular expression, eg. /probably|maybe/i) to be passed. Was previously unrecognized/rejected. +

          +
        • + +
        + +
      • + +
      • + +

        API Updates

        + +
          + +
        • +

          + The SoundManager 2 core API (soundmanager2.js) now runs in Strict Mode, via "use strict";. This is scoped to a closure within soundmanager2.js, and should not cause issues when combined (rolled-up and/or minified) with other JavaScript code. +

          +
        • + + +
        • +

          + New soundManager.reset() method. Similar to reboot(), but also nukes any registered onready() and related callbacks. Based on pull request from Github user jabr. Chaining is now possible too, e.g., soundManager.reset().setup({onready:function(){console.log('reset() complete, reboot OK')}});. Call soundManager.beginDelayedInit() to re-init after a reset(). +

          +
        • + +
        • +

          + soundManager.setup({url:...}) + lazy-loading (dynamically-loaded JS) case: If setup() given a url parameter after DOMContentLoaded has fired, assume we should start right away. (Helps reduce need for beginDelayedInit() + "just works" for most users). +

          +
        • + +
        • +

          + Don't init inline after document.readyState === 'complete' (improve lazy-loading case, wait for setup() with url instead). +

          +
        • + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + +
        • + +

          + Prerelease Firefox builds can play MP3 audio via HTML5 in some cases, as part of a move to support H.264 video (see Bugzilla #799318 for details). Firefox 20 (nightlies, and Aurora channel builds in January 2013) can get native MP3 support via Windows Media Foundation (OS-level codec support) components on Windows 8, Windows 7, and soon, Windows Vista. As of 12/2012, OS X support is planned, and Windows XP support is not. (Disclaimer: Vista, OS X and XP notes sourced from comments on Hacker News; see links). +

          + +

          + When enabled with media.windows-media-foundation.enabled = true under about:config, Firefox may be able to play MP3s via HTML5 and thus get "100% HTML5 mode" when soundManager.setup({preferFlash: false}) is used. +

          + +

          + At time of writing (12/30/2012), Firefox 20 (nightly) returns "" for canPlayType('audio/mpeg; codecs="mp3"'), a test commonly used to query for MP3 support under HTML5 and one which works in other modern browsers. Firefox's behaviour differs because it is trying to follow the MPEG spec, which does not include an explicit MP3 MIME type. Instead, canPlayType('audio/mpeg'), which is in-spec, presently returns a "maybe" when MP3 is supported under Firefox. +

          + +
        • + +
        • +

          + Improved SM2 console.log() debug output, aiming to be less "noisy". Core setup options are shown better at start-up, eg. "SoundManager V2.97a.20130101 (AS3/Flash 9) + HTML5 audio + preferFlash + html5PollingInterval (50ms) + flashBlock". +

          +
        • + +
        • +

          + Christmas light demo: Tweaks for iOS + Android touch devices. +

          +
        • + +
        • +

          + MP3 Player Button demo: Include HTML type (MIME hint) attribute, if specified. +

          +
        • + +
        + +
      • + +
      + +
    • + +
    • + +

      V2.97a.20121104 - HTML5 + iOS load fixes, Windows 8 App Store compatibility tweak, code pattern improvements (Download archived version)

      + +
        + +
      • + +

        Bug fixes

        + +
          + +
        • +

          + Fix HTML5 unload() -> play() case (re-use of same object without assigning new URL). +

          +
        • + +
        • +

          + More global (iOS) HTML5 object unload() / play() re-use tweaks, improved handling of re-use and empty / load() cases +

          +
        • + +
        • +

          + HTML5: Ensure instanceOptions are set after play() call results in load(). Noted instanceOptions not being set from within whileplaying(). +

          +
        • + +
        • +

          + Fix call signature for Flash 8 load method, was tying usePolicyFile (enables remote crossdomain.xml request for ID3/waveform data on 3rd-party domains) to precence of whileloading() due to driver error. Derp. :D +

          +
        • + +
        • +

          + Windows 8 Store Apps (IE 10/"MSAppHost" in UA) don't support Flash or ActiveX, except for (at time of writing), three special ActiveX controls. Thus, new window.ActiveXObject('ShockwaveFlash.ShockwaveFlash') seems to work without error. However, an error is thrown if an <object> with a Flash ActiveX CLSID is appended to the DOM. http://msdn.microsoft.com/en-us/library/windows/apps/hh465143.aspx +

          +
        • + + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + +
        • +

          + Death to underscores! Removed legacy pattern of var _foo = ... for most private internals. +

          +
        • + +
        • +

          + Better typeof x === 'undefined' -> x === undefined pattern per newer jslint rules. +

          +
        • +
        + +
      • + +
      + +
    • + +
    • + +

      V2.97a.20120916 - Inline, deferred and lazy-load init improvements, HTML5 format / detection improvements, "re-use" load/play URL fix. (Download archived version)

      + +
        + +
      • + +

        API Updates

        + +
          + +
        • +

          + Init improvement: Don't fail if Flash URL is null in normal include + init case. Instead, show note in debug input and wait for soundManager.setup() with url param, then treat as delayed init case. Improved experience if including <script>, then trying to do setup() after DOM Ready (common jQuery case). +

          +
        • + +
        • +

          + soundManager.setup({url:...}) + lazy-loading (dynamically-loaded JS) case: If setup() given url parameter after DOMContentLoaded has fired, assume we should start right away. (Helps reduce need for beginDelayedInit() + "just works" for most users) +

          +
        • + +
        • +

          + Don't init inline after document.readyState === 'complete' (improve lazy-loading case, wait for setup() with url: instead) +

          +
        • + +
        + +
      • + +
      • + +

        Bug fixes

        + +
          + +
        • +

          + Fix 'audio/mpeg' canPlay() checks, was incorrectly returning false due to audio/mpeg; codecs="mp3" working and preventing audio/mpeg from being checked. +

          +
        • + +
        • +

          + More paranoid Audio() handling for "bad" Opera (< 10) where new Audio() would throw not_enough_arguments (always required URL). +

          +
        • + +
        • +

          + Safer HTML5 duration checks - null now assigned instead of undefined. +

          +
        • + +
        • +

          + Improve durationEstimate under HTML5 during whileloading(). +

          +
        • + +
        • +

          + Flash 9/RTMP: Actually provide caption data to oncaptiondata(). +

          +
        • + +
        • +

          + Fix SMSound.play({url:...}) "re-use" case where new URL wasn't being assigned + loaded right away, and SMSound.url property was not being updated. +

          +
        • + +
        • +

          + Correct load() and play() with new URL parameter, so that subsequent play() call uses new URL (and not URL assigned with original createSound() call). +

          +
        • + +
        • +

          + Use seconds for SMSound.buffered (time ranges) whether HTML5 or Flash, since SM2 API uses seconds for setPosition() etc. +

          +
        • + +
        • +

          + Correct play() -> pause() -> setPosition(0) -> play() -> pause() case where the latter wasn't firing due to invalid state. +

          +
        • + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + +
        • +

          + New Cassette Tape UI Prototype/demo (experimental). +

          +
        • + +
        • +

          + Tweaked documentation layout for legibility. Webfont (deja vu sans mono) from dejavu-fonts.org for code examples. +

          +
        • + +
        • +

          + Improved lazy-load / deferred example based on new setup() logic +

          +
        • + +
        • +

          + Added SMSound.buffered documentation +

          +
        • + +
        • +

          + Added m4b extension as an mp4 format +

          +
        • + +
        • +

          + Safer initial HTML5 support checks +

          +
        • + +
        + +
      • + +
      + +
    • + + + +
    • + +

      V2.97a.20120624 - New soundManager.setup() method, numerous HTML5 improvements for createSound(), load(), progress and reuse cases, and minor flash audio bug fixes (Download archived version)

      + +
        + +
      • + +

        API: New sugar-like stuff

        + +
          + +
        • + +

          + New soundManager.setup() mixin-style method for assigning properties and common start-up callbacks. Collects top-level soundManager configuration properties and object collections - onready, ontimeout, defaultOptions, flash9Options and movieStarOptions - under a single method call. +

          +

          + Upgrade / legacy note: This is a modern replacement for the direct property assignment method used in all previous versions - eg., soundManager.url = '/swfs/' - the old method continues to work for legacy support, but you should migrate to using the new method as it's much cleaner. All included demos use the new method where applicable. +

          + +

          + New soundManager.setup() method example +

          + +
          soundManager.setup({
          +  // required
          +  url: '/path/to/swfs/',
          +  // optional
          +  flashVersion: 9,
          +  // convenience
          +  onready: function() {
          +    console.log('Ready to play sound!');
          +  },
          +  ontimeout: function() {
          +    console.log('SM2 start-up failed.');
          +  },
          +  // more custom parameters
          +  defaultOptions: {
          +    volume: 50
          +  }
          +});
          + +

          + See soundManager.setup() for details. +

          + +
        • + +
        + +
      • + +
      • + +

        Bug fixes

        + +
          + +
        • +

          + Improve HTML5 audio load/playback reliability + stability on iOS, and for object reuse cases (play() -> load({url: ...}). Prior behaviour was making initial HTTP request when object was created (meta/preload, not necessarily loading entire file.) Request now only happens with preload/load/play-related calls. +

          +
        • + +
        • +

          + HTML5: Firefox seems to have changed when unloading HTML5 audio, url = '' now loads hosting page HTML (boo) instead of null / no request. Changed to about:blank like everyone else. Also fixed boolean logic on isMovieStar assignment. +

          +
        • + +
        • +

          + Add audio/mp3 and related MIME checks for flash, correct edge case where play({type:'audio/mp3'}) would use HTML5 when preferFlash = true, due to seeming lack of Flash support for the MIME type. +

          +
        • + +
        • +

          + Fixed old Flash 8 onload() edge case where loading from cache might return incorrect didLoad: false result - corrected by checking for a non-zero sound duration. +

          +
        • + +
        • +

          + Properly reset SMSound.id3 = {} with internal resetProperty and public methods like load(). +

          +
        • + +
        • +

          + Edge case fix: Don't attempt to remove flash unless reference exists (prevent false warning when reboot() called in 100% HTML5 mode.) +

          +
        • + +
        • +

          + Correct empty options JS error on internal _setup_html5() when reusing HTML5 audio object per V2.97a.20120527 bug report +

          +
        • + +
        • +

          + Fix minor false positive (undocumented error handler case) with HTML5 play() falsely reporting 32-sound ceiling edge case and calling SMSound.onplayerror() (if assigned) when using flashVersion = 9. Should only apply when flash 9 is being used for playback, and ceiling hit. +

          +
        • + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + +
        • +

          + Finally assign + use SMSound.id (instead of sID), matching createSound({id: 'foo'}) pattern; maintain legacy sID property (ancient behaviour, originally intended to avoid potential namespace conflicts many years ago - now silly and not a concern.) +

          +
        • + +
        • +

          + Improved handling of whileloading() vs. HTML5 onload (when using HTTP range/partial requests). +

          +

          + HTML5 onload() (now triggered via native canplaythrough event) may fire early, followed by numerous HTML5 progress requests during playback as the audio object requests and buffers more audio ranges (eg., 0-10 seconds), eventually matching the total sound duration. +

          +

          + Bytes loaded / total are not available, so bytesLoaded instead reflects a fraction of "duration loaded", between 0 and 1 as data is buffered in. Previously, whileloading events would not fire once onload had fired under HTML5. +

          +
        • + +
        • +

          + New (undocumented, for now) buffered array on SMSound objects; list of objects following the pattern SMSound.buffered = [{ start: 0, end: 706 }] representing loaded time ranges (somewhat similar to HTML5 TimeRanges spec, but using static properties instead of method calls with an index parameter.) Array will initially be empty, zero-length. This can be looped through to show overlays of "loaded" time fragments on progress bars, for example.

          +

          SMSound buffered is updated during whileloading() calls, where values are provided by the browser. For flash, will always be one item with { start: 0, end: SMSound.duration } assigned. Also stopped sending 1/1 values to whileplaying() at onload(), since HTML5 can fire onload() (via canplaythrough) very early followed by many progress (whileloading()) events. +

          +

          + Support note: Not all browsers (eg., Safari 5.1.7) appear to provide buffer / TimeRanges data for HTML5 audio objects. At time of writing (06/2012), Firefox, Chrome Canary, IE 9 and Opera provide TimeRanges alongside progress events. +

          +
        • + +
        • +

          + Upgraded demos to use to soundManager.setup({...}) for most configuration cases (vs. setting soundManager.url, soundManager.defaultOptions.autoLoad directly etc.) +

          +
        • + +
        • +

          + Warn if soundManager.setup() called with url or flashVersion, and init has already fired (ie., flash options already set + movie already loaded) where changes will not take effect until soundManager.reboot(). +

          + +
        • + +
        • +

          + Assign top-level soundManager properties (eg. soundManager.url) from soundManager.setupOptions at DOMReady time; this allows legacy soundManager.url = ... assignment to work, and helps to ensure legacy-style, directly-assigned top-level property values get written back to soundManager.setupOptions. +

          +
        • + +
        + +
      • + +
      + +
    • + + + +
    • + +

      V2.97a.20120527 - Fix for ontimeout() regression. GWT/JSNI compatibility, slow connection and Safari "background tab" SWF load handling improvements (Download archived version)

      + +
        + +
      • + +

        Bug fixes

        + +
          + +
        • +

          + Fix for ontimeout() regression seen when using lazy-loading / SM2_DEFER introduced with V2.97a.20120513; bug introduced when making edits to pass newer jslint rules regarding return within if...else blocks. +

          +
        • + +
        • +

          + Replaced instanceof Function with "safer" typeof x === 'function' for onready(), ontimeout() and related callback argument checks as GWT + JSNI was passing arguments that failed the instanceof check. (Related bug report.) +

          +
        • + +
        • +

          + Corrected another small regression for the ontimeout() -> onready() "recovery" edge case, ensuring "ready" does not fire after a timeout when init was unsuccessful. +

          +
        • + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + + +
        • +

          + Improved handling for special Safari page load case: When a new tab is opened that does not have focus, the Flash SWF does not load/init until the tab is brought to the foreground. SM2 now recognizes this special case and waits until window.onfocus() before attempting to do the JS/Flash part of init. Previously, it would fail with a timeout. +

          +

          + Code written to originally handle Safari 3.1, which did not support document.hasFocus(), was modified and updated for this purpose. The Safari 3.1 logic previously deferred SM2's start-up in a similar fashion. (The old Safari 3.1 mousemove() focus-detection hack has been removed as Safari 4 has been out since mid-2009, and Safari 5 since mid-2010.) +

          + +
        • + +
        • +

          + SM2 init process will now delay and retry if no Flash response, and SWF has loaded > 0 and < 100%. Timeout will now happen only after delay and when SWF has loaded 100%. Should help prevent first-visit (non-cached) failure on very slow or laggy connections. +

          + +
        • + +
        • +

          + Added note about potential Firefox regression: Offline JS/Flash start-up (viewing HTML pages via file:// and/or c:/ and so forth), possibly not working as of Firefox 9 and newer (at time of writing, also up to and including Firefox 12), even despite special security whitelisting under Flash Player "trusted locations" preferences / control panel. +

          +

          + After successful Flash -> JS call, SM2's "return" JS -> Flash call fails with unusual JS/Flash exception, "Error in ActionScript" error with no further detail. Offline viewing still works in other browsers. +

          +
        • + +
        + +
      • + +
      + +
    • + + + +
    • + +

      V2.97a.20120513 - Fixes for Android 2.3 playback, onPosition() in HTML5, Flash 9 double-play edge case. Minor new Flash 9-specific features (Download archived version)

      + +
        + +
      • + +

        Bug fixes

        + +
          + +
        • +

          + Android 2.3 playback fix (some sounds started only after 2+ play attempts due to Android not liking load() immediately followed by play()?) +

          +
        • + +
        • +

          + onPosition() fix for HTML5 playback, items were mistakenly being removed. +

          +
        • + +
        • +

          + Fix RTMP stream duration reporting via onmetadata() (wrong value was being returned, previously.) +

          +
        • + +
        • +

          + Fix for Flash 9 double-play edge case found with pause() + setPosition() calls. +

          +
        • + + +
        • +

          + JSLINT validation per 04-15-2012 edition rules, mostly removal of multiple return statements within if ... else blocks and inverted loop tricks. +

          +
        • + +
        + +
      • + +
      • + +

        API updates

        + +
          + +
        • +

          + Enabled waveform/eq/spectrum data features for MovieStar (H.264/NetStream content.) +

          +
        • + +
        • +

          + Added oncaptiondata() callback for caption data from Flash 9 (NetStream/RTMP-only, similar to onmetadata(). Contributor: GitHub user karma.) +

          +
        • + +
        • +

          + Added SMSound.onplayerror(), presently for Flash 9 (non-MovieStar/NetStream) which can detect lack of available sound hardware or 32-channel ceiling as reasons for playback failure. +

          +
        • + +
        • +

          + Added oncaptiondata() callback for caption data from Flash 9 (NetStream/RTMP-only, similar to onmetadata().) +

          +
        • + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + +
        • +

          + Scaling added to 360 UI (via GitHub user tomasdev) +

          +
        • + +
        + +
      • + +
      + +
    • + + + +
    • + +

      V2.97a.20120318 - Minor updates. from / to and onplay() bug fixes, canPlayMIME() and canPlayLink() Flash-specific corrections. (Download archived version)

      + +
        + +
      • + +

        Bug fixes

        + +
          + +
        • +

          + Fix silly undefined"soundID" debug output message shown at SMSound.onload (now says SMSound._onload() as previously.) +

          +
        • + +
        • +

          + soundManager.sounds = {} instead of [] on reboot (per bug report) +

          +
        • + +
        • +

          + Fix logic for calling onplay(), was always non-truthy. D'oh! +

          +
        • + +
        • +

          + Add missing typeof to fix html5 MIME check for playability tests +

          +
        • + +
        • +

          + Don't apply width:auto to SWF (invalid per HTML5, allegedly: Related patch.) +

          +
        • + +
        • +

          + Make soundManager.canPlayMIME() and canPlayLink() check flash support before returning (check after ontimeout() was returning truthy when flash required under Firefox, for example, for 'audio/mp3') +

          +
        • + +
        • +

          + Fix play() "from" + "to" sound sprite playback issue: In some cases, previously-fired "to" events were re-firing due to not being removed, because an equality check was comparing against a potential "to" value of a string rather than a number. (eg., 0-700 followed by 1500-2000; playback would stop in second case, saying 700 had been reached. (Related bug report.) +

          +
        • + +
        • +

          + Re-appeased the jslint gods, removed unused variables and two-statement reverse loop (for i=x; i--;) { } trickery. +

          +
        • + +
        + +
      • + +
      • + +

        Miscellaneous

        + +
          + +
        • +

          + The SoundManager project turned 10 years old, having originally launched in late 2001. Thanks for using it! +

          +
        • + +
        + +
      • + +
      + +
    • + + + +
    • + +

      Older Release Info

      +

      For release and changelog history going back to 2010, see the archive page.

      + +
    • + +
    + + +
    + + +
    + + +
    + + +
    + + + +
    + + + +
    + + + +
    + +
    + + +
    + + +
    + + +
    + + + + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/SoundManager2_AS.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/SoundManager2_AS.html new file mode 100755 index 00000000..df95c37e --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/SoundManager2_AS.html @@ -0,0 +1,938 @@ + + + + + SoundManager2_AS.as + + + + + + +
    +
    + + + +
      + +
    • +
      +

      SoundManager2_AS.as

      +
      +
    • + + + +
    • +
      + +
      + +
      + +
      + +
      /**
      + * SoundManager 2: Javascript Sound for the Web
      + * ----------------------------------------------
      + * http://schillmania.com/projects/soundmanager2/
      + *
      + * Copyright (c) 2007, Scott Schiller. All rights reserved.
      + * Code licensed under the BSD License:
      + * http://www.schillmania.com/projects/soundmanager2/license.txt
      + *
      + * Flash 8 / ActionScript 2 version
      + *
      + * Compiling AS to Flash 8 SWF using MTASC (free compiler - http://www.mtasc.org/):
      + * mtasc -swf soundmanager2.swf -main -header 16:16:30 SoundManager2.as -version 8
      + *
      + * ActionScript Sound class reference (Macromedia), documentation download:
      + * http://livedocs.macromedia.com/flash/8/
      + * Previously-live URL:
      + * http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002668.html
      + *
      + * *** NOTE ON LOCAL FILE SYSTEM ACCESS ***
      + *
      + * Flash security allows local OR network access, but not both
      + * unless explicitly whitelisted/allowed by the flash player's
      + * security settings.
      + *
      + * To enable in-flash messaging for troubleshooting, pass debug=1 in FlashVars (within object/embed code)
      + * SM2 will do this by default when soundManager.debugFlash = true.
      + *
      + */
      +
      +import flash.external.ExternalInterface; // woo
      +
      +class SoundManager2 {
      +
      +  static var app: SoundManager2;
      +
      +  function SoundManager2() {
      +
      +    var version = "V2.97a.20131201";
      +    var version_as = "(AS2/Flash 8)";
      +
      +    /**
      +     *  Cross-domain security options
      +     *  HTML on foo.com loading .swf hosted on bar.com? Define your "HTML domain" here to allow JS+Flash communication to work.
      +     *  // allow_xdomain_scripting = true;
      +     *  // xdomain = "foo.com";
      +     *  For all domains (possible security risk?), use xdomain = "*"; which ends up as System.security.allowDomain("*");
      +     *  When loading from HTTPS, use System.security.allowInsecureDomain();
      +     *  See "allowDomain (security.allowDomain method)" in Flash 8/AS2 liveDocs documentation (AS2 reference -> classes -> security)
      +     *  download from http://livedocs.macromedia.com/flash/8/
      +     *  Related AS3 documentation: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/system/Security.html#allowDomain%28%29
      +     */
      +
      +    var allow_xdomain_scripting = false;
      +    var xdomain = "*";
      +
      +    if (allow_xdomain_scripting && xdomain) {
      +      System.security.allowDomain(xdomain);
      +      version_as += ' - cross-domain enabled';
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      externalInterface references (for Javascript callbacks)

      + +
      + +
          var baseJSController = "soundManager";
      +    var baseJSObject = baseJSController + ".sounds";
      + +
    • + + +
    • +
      + +
      + +
      +

      internal objects

      + +
      + +
          var sounds = []; // indexed string array
      +    var soundObjects = []; // associative Sound() object array
      +    var timer = null;
      +    var pollingEnabled = false; // polling (timer) flag - disabled by default, enabled by JS->Flash call
      +    var debugEnabled = true; // Flash debug output enabled by default, disabled by JS call
      +    var flashDebugEnabled = false; // debug output to flash movie, off by default
      +    var didSandboxMessage = false;
      +    var caughtFatal = false;
      + +
    • + + +
    • +
      + +
      + +
      +

      for flash text output, debugging etc.

      + +
      + +
          var _messages = [];
      +    var _messageObj = null;
      +    flashDebugEnabled = (_root.debug == 1);
      + +
    • + + +
    • +
      + +
      + +
      +

      display stuffs

      + +
      + +
          Stage.scaleMode = 'noScale';
      +    Stage.align = 'TL';
      + +
    • + + +
    • +
      + +
      + +
      +

      context menu item with version info

      + +
      + +
      +    var doNothing = function() {}
      +
      +    var sm2Menu:ContextMenu = new ContextMenu();
      +    var sm2MenuItem:ContextMenuItem = new ContextMenuItem('SoundManager ' + version + ' ' + version_as, doNothing);
      +    sm2MenuItem.enabled = false;
      +    sm2Menu.customItems.push(sm2MenuItem);
      +    _root.menu = sm2Menu;
      +
      +    var writeDebug = function(s, logLevel) {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            if (!debugEnabled) return false;
      +      ExternalInterface.call(baseJSController + "['_writeDebug']", "(Flash): " + s, (logLevel || 0));
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
          }
      +
      +    var flashDebug = function(messageText) {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            _messages.push(messageText);
      +      if (!flashDebugEnabled) {
      +        return false;
      +      }
      +      var sans = new TextFormat();
      +      sans.size = 12;
      +      sans.font = "Arial";
      + +
    • + + +
    • +
      + +
      + +
      +

      320x240 if no stage dimensions (happens in IE, apparently 0 before stage resize event fires.)

      + +
      + +
            var w = Stage.width?Stage.width:320;
      +      var h = Stage.height?Stage.height:240;
      +      if (!_messageObj) {
      +        _messageObj = _root.createTextField("_messageObj", 0, 0, 0, w, h);
      +        _messageObj.x = 0;
      +        _messageObj.y = 0;
      +        _messageObj.multiline = true;
      +        _messageObj.html = true;
      +        _messageObj.wordWrap = true;
      +        _messageObj.align = 'left';
      +        _messageObj.autoSize = false;
      +      }
      +      _messageObj.htmlText = _messages.join('\n');
      +      _messageObj.setTextFormat(sans);
      +      _messageObj.width = w;
      +      _messageObj.height = h;
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
          }
      +
      +    var _externalInterfaceTest = function(isFirstCall) {
      +      var sandboxType = System.security['sandboxType'];
      +      try {
      +        if (isFirstCall) {
      +          flashDebug('Testing Flash -&gt; JS...')
      +          if (!didSandboxMessage && sandboxType != 'remote' && sandboxType != 'localTrusted') {
      +            didSandboxMessage = true;
      +            flashDebug('<br><b>Fatal: Security sandbox error: Got "' + sandboxType + '", expected "remote" or "localTrusted".<br>Additional security permissions need to be granted.<br>See <a href="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html">flash security settings panel</a> for non-HTTP, eg. file:// use.</b><br>http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html<br><br>You may also be able to right-click this movie and choose from the menu: <br>"Global Settings" -> "Advanced" tab -> "Trusted Location Settings"<br>');
      +          }
      +          ExternalInterface.call(baseJSController + "._externalInterfaceOK", version);
      +          if (!didSandboxMessage) {
      +            flashDebug('Flash -&gt; JS OK');
      +            flashDebug('Waiting for JS -&gt; Flash...');
      +          }
      +        } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('SM2 SWF ' + version + ' ' + version_as, 1);

      + +
      + +
                ExternalInterface.call(baseJSController + "._setSandboxType", sandboxType);
      +          flashDebug('JS -&gt; Flash OK');
      +        }
      +      } catch(e) {
      +        flashDebug(e.toString());
      +        if (!caughtFatal) {
      +          caughtFatal = true;
      +        }
      +        return false;
      +      }
      +      return true; // to verify that a call from JS to here, works. (eg. JS receives "true", thus OK.)
      +    }
      +
      +    var _disableDebug = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      prevent future debug calls from Flash going to client (maybe improve performance)

      + +
      + +
            writeDebug('_disableDebug()');
      +      debugEnabled = false;
      +    }
      +
      +    var checkProgress = function() {
      +      var bL = 0;
      +      var bT = 0;
      +      var nD = 0;
      +      var nP = 0;
      +      var oSound = null;
      +      for (var i = 0, j = sounds.length; i < j; i++) {
      +        oSound = soundObjects[sounds[i]];
      +        bL = oSound.getBytesLoaded();
      +        bT = oSound.getBytesTotal();
      +        nD = oSound.duration || 0; // can sometimes be null with short MP3s? Wack.
      +        nP = oSound.position;
      +        if (bL && bT && bL != oSound.lastValues.bytes) {
      +          oSound.lastValues.bytes = bL;
      +          ExternalInterface.call(baseJSObject + "['" + oSound.sID + "']._whileloading", bL, bT, nD);
      +        }
      +        if (typeof nP != 'undefined' && nP != oSound.lastValues.position) {
      +          oSound.lastValues.position = nP;
      +          ExternalInterface.call(baseJSObject + "['" + oSound.sID + "']._whileplaying", nP);
      + +
    • + + +
    • +
      + +
      + +
      +

      if position changed, check for near-end

      + +
      + +
              }
      +      }
      +    }
      +
      +    var onLoad = function(bSuccess) {
      +      checkProgress(); // ensure progress stats are up-to-date
      + +
    • + + +
    • +
      + +
      + +
      +

      force duration update (doesn't seem to be always accurate)

      + +
      + +
            ExternalInterface.call(baseJSObject + "['" + this.sID + "']._whileloading", this.getBytesLoaded(), this.getBytesTotal(), this.duration);
      +      ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onload", this.duration > 0 ? 1 : 0); // bSuccess doesn't always seem to work, so check MP3 duration instead.
      +    }
      +
      +    var onID3 = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      --- NOTE: BUGGY? ---

      +

      TODO: Investigate holes in ID3 parsing - for some reason, Album will be populated with Date if empty and date is provided. (?) +ID3V1 seem to parse OK, but "holes" / blanks in ID3V2 data seem to get messed up (eg. missing album gets filled with date.) +iTunes issues: onID3 was not called with a test MP3 encoded with iTunes 7.01, and what appeared to be valid ID3V2 data. +May be related to thumbnails for album art included in MP3 file by iTunes. See http://mabblog.com/blog/?p=33

      + +
      + +
            var id3Data = [];
      +      var id3Props = [];
      +      for (var prop in this.id3) {
      +        id3Props.push(prop);
      +        id3Data.push(this.id3[prop]);
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('id3['+prop+']: '+this.id3[prop]);

      + +
      + +
            }
      +      ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onid3", id3Props, id3Data);
      + +
    • + + +
    • +
      + +
      + +
      +

      unhook own event handler, prevent second call (can fire twice as data is received - ID3V2 at beginning, ID3V1 at end.) +Therefore if ID3V2 data is received, ID3V1 is ignored.

      + +
      + +
            soundObjects[this.sID].onID3 = null;
      +    }
      +
      +    var registerOnComplete = function(sID) {
      +      soundObjects[sID].onSoundComplete = function() {
      +        checkProgress();
      +        ExternalInterface.call(baseJSObject + "['" + sID + "']._onfinish");
      +      }
      +    }
      +
      +    var _setPosition = function(sID, nSecOffset, isPaused, _allowMultiShot) {
      + +
    • + + +
    • +
      + +
      + +
      +

      note: multiShot is Flash 9-only; retained so JS/Flash function signatures are identical.

      + +
      + +
            var s = soundObjects[sID];
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('_setPosition()');

      + +
      + +
            s.lastValues.position = s.position;
      +      if (s.lastValues.loops > 1 && nSecOffset != 0) {
      +        writeDebug('Warning: Looping functionality being disabled due to Flash limitation.', 240);
      +        s.lastValues.loops = 1;
      +      }
      +      s.start(nSecOffset, s.lastValues.nLoops || 1); // start playing at new position
      +      if (isPaused) {
      +        s.stop();
      +      }
      +    }
      +
      +    var _load = function(sID, sURL, bStream, bAutoPlay, bCheckPolicyFile) {
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('_load(): '+sID+', '+sURL+', '+bStream+', '+bAutoPlay+', '+bCheckPolicyFile);

      + +
      + +
            if (typeof bAutoPlay == 'undefined') {
      +        bAutoPlay = false;
      +      }
      +      if (typeof bStream == 'undefined') {
      +        bStream = true;
      +      }
      +      if (typeof bCheckPolicyFile == 'undefined') {
      +        bCheckPolicyFile = false;
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('bStream: '+bStream); +writeDebug('bAutoPlay: '+bAutoPlay); +checkProgress();

      + +
      + +
            var s = soundObjects[sID];
      +      s.onID3 = onID3;
      +      s.onLoad = onLoad;
      +      s.loaded = true;
      +      s.checkPolicyFile = bCheckPolicyFile;
      +      s.loadSound(sURL, bStream);
      +      if (bAutoPlay != true) {
      +        s.stop(); // prevent default auto-play behaviour
      +      } else {
      +        writeDebug('auto-play allowed');
      +      }
      +      registerOnComplete(sID);
      +    }
      +
      +    var _unload = function(sID, sURL) {
      + +
    • + + +
    • +
      + +
      + +
      +

      effectively "stop" loading by loading a tiny MP3

      + +
      + +
            var s = soundObjects[sID];
      +      s.onID3 = null;
      +      s.onLoad = null;
      +      s.loaded = false;
      + +
    • + + +
    • +
      + +
      + +
      +

      ensure position is reset, if unload fails

      + +
      + +
            s.start(0,1);
      +      s.stop();
      +      s.loadSound(sURL, true);
      +      s.stop(); // prevent auto-play
      +    }
      +
      +    var _createSound = function(sID, loops, checkPolicyFile) {
      +      var s = new Sound();
      +      if (!soundObjects[sID]) {
      +        sounds.push(sID);
      +      }
      +      soundObjects[sID] = s;
      +      s.setVolume(100);
      +      s.sID = sID;
      +      s.paused = false;
      +      s.loaded = false;
      +      s.checkPolicyFile = checkPolicyFile;
      +      s.lastValues = {
      +        bytes: 0,
      +        position: 0,
      +        nLoops: loops||1
      +      };
      +    }
      +
      +    var _destroySound = function(sID) {
      + +
    • + + +
    • +
      + +
      + +
      +

      for the power of garbage collection! .. er, Greyskull!

      + +
      + +
            var s = (soundObjects[sID] || null);
      +      if (!s) {
      +        return false;
      +      }
      +      for (var i = 0; i < sounds.length; i++) {
      +        if (sounds[i] == sID) {
      +          sounds.splice(i, 1);
      +          break;
      +        }
      +      }
      +      s = null;
      +      delete soundObjects[sID];
      +    }
      +
      +    var _stop = function(sID, bStopAll) {
      + +
    • + + +
    • +
      + +
      + +
      +

      stop this particular instance (or "all", based on parameter)

      + +
      + +
            if (bStopAll) {
      +        _root.stop();
      +      } else {
      +        soundObjects[sID].stop();
      +        soundObjects[sID].paused = false;
      +      }
      +    }
      +
      +    var _start = function(sID, nLoops, nMsecOffset, _allowMultiShot) {
      + +
    • + + +
    • +
      + +
      + +
      +

      note: multiShot is Flash 9-only; retained so JS/Flash function signatures are identical. +writeDebug('_start: ' + sID + ', loops: ' + nLoops + ', nMsecOffset: ' + nMsecOffset);

      + +
      + +
            registerOnComplete();
      +      var s = soundObjects[sID];
      +      s.lastValues.paused = false; // reset pause if applicable
      +      s.lastValues.nLoops = (nLoops || 1);
      +      s.start(nMsecOffset, nLoops);
      +      return true;
      +    }
      +
      +    var _pause = function(sID, _allowMultiShot) {
      + +
    • + + +
    • +
      + +
      + +
      +

      note: multiShot is Flash 9-only; retained so JS/Flash function signatures are identical. +writeDebug('_pause()');

      + +
      + +
            var s = soundObjects[sID];
      +      if (!s.paused) {
      + +
    • + + +
    • +
      + +
      + +
      +

      reference current position, stop sound

      + +
      + +
              s.paused = true;
      +        s.lastValues.position = s.position;
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('_pause(): position: '+s.lastValues.position);

      + +
      + +
              s.stop();
      +      } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      resume playing from last position +writeDebug('resuming - playing at '+s.lastValues.position+', '+s.lastValues.nLoops+' times');

      + +
      + +
              s.paused = false;
      +        s.start(s.lastValues.position / 1000, s.lastValues.nLoops);
      +      }
      +    }
      +
      +    var _setPan = function(sID, nPan) {
      +      soundObjects[sID].setPan(nPan);
      +    }
      +
      +    var _setVolume = function(sID, nVol) {
      +      soundObjects[sID].setVolume(nVol);
      +    }
      +
      +    var _setPolling = function(bPolling, timerInterval) {
      +      if (typeof timerInterval === 'undefined') {
      +        timerInterval = 50;
      +      }
      +      pollingEnabled = bPolling;
      +      if (timer == null && pollingEnabled) {
      +        flashDebug('Enabling polling, ' + timerInterval + ' ms interval');
      +        timer = setInterval(checkProgress, timerInterval);
      +      } else if (timer && !pollingEnabled) {
      +        flashDebug('Disabling polling');
      +        clearInterval(timer);
      +        timer = null;
      +      }
      +    }
      +
      +    var _init = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      OK now stuff should be available

      + +
      + +
            try {
      +        flashDebug('Adding ExternalInterface callbacks...');
      +        ExternalInterface.addCallback('_load', this, _load);
      +        ExternalInterface.addCallback('_unload', this, _unload);
      +        ExternalInterface.addCallback('_stop', this, _stop);
      +        ExternalInterface.addCallback('_start', this, _start);
      +        ExternalInterface.addCallback('_pause', this, _pause);
      +        ExternalInterface.addCallback('_setPosition', this, _setPosition);
      +        ExternalInterface.addCallback('_setPan', this, _setPan);
      +        ExternalInterface.addCallback('_setVolume', this, _setVolume);
      +        ExternalInterface.addCallback('_setPolling', this, _setPolling);
      +        ExternalInterface.addCallback('_externalInterfaceTest', this, _externalInterfaceTest);
      +        ExternalInterface.addCallback('_disableDebug', this, _disableDebug);
      +        ExternalInterface.addCallback('_createSound', this, _createSound);
      +        ExternalInterface.addCallback('_destroySound', this, _destroySound);
      +      } catch(e) {
      +        flashDebug('Fatal: ExternalInterface error: ' + e.toString());
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      try to talk to JS, do init etc.

      + +
      + +
            _externalInterfaceTest(true);
      + +
    • + + +
    • +
      + +
      + +
      +

      flashDebug('Init OK');

      + +
      + +
          }
      +
      +    flashDebug('SM2 SWF ' + version + ' ' + version_as);
      +
      +    if (ExternalInterface.available) {
      +      flashDebug('ExternalInterface available');
      +      _init();
      +    } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      d'oh! - may be from a corrupt install, ancient (pre-Netscape 6?) browser etc.

      + +
      + +
            flashDebug('Fatal: ExternalInterface (Flash &lt;-&gt; JS) not available');
      +    }
      +
      +
      +  } // SoundManager2()
      + +
    • + + +
    • +
      + +
      + +
      +

      entry point

      + +
      + +
        static function main(mc) {
      +    app = new SoundManager2();
      +  }
      +
      +}
      + +
    • + +
    +
    + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/SoundManager2_AS3.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/SoundManager2_AS3.html new file mode 100755 index 00000000..a41e3fe8 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/SoundManager2_AS3.html @@ -0,0 +1,2026 @@ + + + + + SoundManager2_AS3.as + + + + + + +
    +
    + + + +
      + +
    • +
      +

      SoundManager2_AS3.as

      +
      +
    • + + + +
    • +
      + +
      + +
      + +
      + +
      /**
      + * SoundManager 2: Javascript Sound for the Web
      + * ----------------------------------------------
      + * http://schillmania.com/projects/soundmanager2/
      + *
      + * Copyright (c) 2007, Scott Schiller. All rights reserved.
      + * Code licensed under the BSD License:
      + * http://www.schillmania.com/projects/soundmanager2/license.txt
      + *
      + * Flash 9 / ActionScript 3 version
      + */
      +
      +package {
      +
      +  import flash.display.Sprite;
      +  import flash.events.Event;
      +  import flash.events.IOErrorEvent;
      +  import flash.events.MouseEvent;
      +  import flash.events.SecurityErrorEvent;
      +  import flash.events.AsyncErrorEvent;
      +  import flash.events.NetStatusEvent;
      +  import flash.events.TimerEvent;
      +  import flash.external.ExternalInterface; // woo
      +  import flash.media.Sound;
      +  import flash.media.SoundChannel;
      +  import flash.media.SoundMixer;
      +  import flash.net.URLLoader;
      +  import flash.net.URLRequest;
      +  import flash.system.Security;
      +  import flash.system.System;
      +  import flash.text.TextField;
      +  import flash.text.TextFormat;
      +  import flash.text.TextFieldAutoSize;
      +  import flash.ui.ContextMenu;
      +  import flash.ui.ContextMenuItem;
      +  import flash.utils.setInterval;
      +  import flash.utils.clearInterval;
      +  import flash.utils.Dictionary;
      +  import flash.utils.Timer;
      +
      +  public class SoundManager2_AS3 extends Sprite {
      +
      +    public var version:String = "V2.97a.20131201";
      +    public var version_as:String = "(AS3/Flash 9)";
      +
      +    /**
      +     *  Cross-domain security options
      +     *  HTML on foo.com loading .swf hosted on bar.com? Define your "HTML domain" here to allow JS+Flash communication to work.
      +     *  // allow_xdomain_scripting = true;
      +     *  // xdomain = "foo.com";
      +     *  For all domains (possible security risk?), use xdomain = "*"; which ends up as System.security.allowDomain("*");
      +     *  When loading from HTTPS, use System.security.allowInsecureDomain();
      +     *  See http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/system/Security.html#allowDomain()
      +     */
      +    public var allow_xdomain_scripting:Boolean = false;
      +    public var xdomain:String = "*";
      + +
    • + + +
    • +
      + +
      + +
      +

      externalInterface references (for Javascript callbacks)

      + +
      + +
          public var baseJSController:String = "soundManager";
      +    public var baseJSObject:String = baseJSController + ".sounds";
      + +
    • + + +
    • +
      + +
      + +
      +

      internal objects

      + +
      + +
          public var sounds:Array = []; // indexed string array
      +    public var soundObjects: Dictionary = new Dictionary(); // associative Sound() object Dictionary type
      +    public var timer: Timer = null;
      +    public var pollingEnabled: Boolean = false; // polling (timer) flag - disabled by default, enabled by JS->Flash call
      +    public var debugEnabled: Boolean = true; // Flash debug output enabled by default, disabled by JS call
      +    public var flashDebugEnabled: Boolean = false; // Flash internal debug output (write to visible SWF in browser)
      +    public var loaded: Boolean = false;
      +    public var currentObject: SoundManager2_SMSound_AS3 = null;
      +    public var paramList:Object = null;
      +    public var messages:Array = [];
      +    public var textField: TextField = null;
      +    public var textStyle: TextFormat = new TextFormat();
      +    public var didSandboxMessage: Boolean = false;
      +    public var caughtFatal: Boolean = false;
      +
      +    public function SoundManager2_AS3() {
      +
      +      if (allow_xdomain_scripting && xdomain) {
      +        Security.allowDomain(xdomain);
      +        version_as += ' - cross-domain enabled';
      +      }
      +
      +      this.paramList = this.root.loaderInfo.parameters;
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            if (this.paramList['debug'] == 1) {
      +        this.flashDebugEnabled = true;
      +      }
      +
      +      if (this.flashDebugEnabled) {
      +        var canvas: Sprite = new Sprite();
      +        canvas.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
      +        addChild(canvas);
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +      flashDebug('SM2 SWF ' + version + ' ' + version_as);
      + +
    • + + +
    • +
      + +
      + +
      +

      context menu item with version info

      + +
      + +
      +      var sm2Menu:ContextMenu = new ContextMenu();
      +      var sm2MenuItem:ContextMenuItem = new ContextMenuItem('SoundManager ' + version + ' ' + version_as);
      +      sm2MenuItem.enabled = false;
      +      sm2Menu.customItems.push(sm2MenuItem);
      +      contextMenu = sm2Menu;
      +
      +      if (ExternalInterface.available) {
      +        flashDebug('ExternalInterface available');
      +        try {
      +          flashDebug('Adding ExternalInterface callbacks...');
      +          ExternalInterface.addCallback('_load', _load);
      +          ExternalInterface.addCallback('_unload', _unload);
      +          ExternalInterface.addCallback('_stop', _stop);
      +          ExternalInterface.addCallback('_start', _start);
      +          ExternalInterface.addCallback('_pause', _pause);
      +          ExternalInterface.addCallback('_setPosition', _setPosition);
      +          ExternalInterface.addCallback('_setPan', _setPan);
      +          ExternalInterface.addCallback('_setVolume', _setVolume);
      +          ExternalInterface.addCallback('_setPolling', _setPolling);
      +          ExternalInterface.addCallback('_externalInterfaceTest', _externalInterfaceTest);
      +          ExternalInterface.addCallback('_disableDebug', _disableDebug);
      +          ExternalInterface.addCallback('_getMemoryUse', _getMemoryUse);
      +          ExternalInterface.addCallback('_createSound', _createSound);
      +          ExternalInterface.addCallback('_destroySound', _destroySound);
      +          ExternalInterface.addCallback('_setAutoPlay', _setAutoPlay);
      +        } catch(e: Error) {
      +          flashDebug('Fatal: ExternalInterface error: ' + e.toString());
      +        }
      +      } else {
      +        flashDebug('Fatal: ExternalInterface (Flash &lt;-&gt; JS) not available');
      +      };
      + +
    • + + +
    • +
      + +
      + +
      +

      call after delay, to be safe (ensure callbacks are registered by the time JS is called below)

      + +
      + +
            var timer: Timer = new Timer(20, 0);
      +      timer.addEventListener(TimerEvent.TIMER, function() : void {
      +        timer.reset();
      +        _externalInterfaceTest(true);
      + +
    • + + +
    • +
      + +
      + +
      +

      timer.reset(); +flashDebug('Init OK');

      + +
      + +
            });
      +      timer.start();
      + +
    • + + +
    • +
      + +
      + +
      +

      delayed, see above +_externalInterfaceTest(true);

      + +
      + +
          } // SoundManager2()
      +
      +    public function flashDebug (txt:String) : void {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            messages.push(txt);
      +      if (this.flashDebugEnabled) {
      +        var didCreate: Boolean = false;
      +        textStyle.font = 'Arial';
      +        textStyle.size = 12;
      + +
    • + + +
    • +
      + +
      + +
      +

      320x240 if no stage dimensions (happens in IE, apparently 0 before stage resize event fires.)

      + +
      + +
             var w:Number = this.stage.width?this.stage.width:320;
      +       var h:Number = this.stage.height?this.stage.height:240;
      +        if (textField == null) {
      +          didCreate = true;
      +          textField = new TextField();
      +          textField.autoSize = TextFieldAutoSize.LEFT;
      +          textField.x = 0;
      +          textField.y = 0;
      +          textField.multiline = true;
      +          textField.textColor = 0;
      +          textField.wordWrap = true;
      +        }
      +        textField.htmlText = messages.join('\n');
      +        textField.setTextFormat(textStyle);
      +        textField.width = w;
      +        textField.height = h;
      +        if (didCreate) {
      +          this.addChild(textField);
      +        }
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
          }
      +
      +    public function _setAutoPlay(sID:String, autoPlay:Boolean) : void {
      +      var s: SoundManager2_SMSound_AS3 = soundObjects[sID];
      +      if (s) {
      +        s.setAutoPlay(autoPlay);
      +      }
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      methods

      + +
      + +
      +    public function writeDebug (s:String, logLevel:Number = 0) : Boolean {
      +      if (!debugEnabled) {
      +        return false;
      +      }
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            ExternalInterface.call(baseJSController + "['_writeDebug']", "(Flash): " + s, null, logLevel);
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
            return true;
      +    }
      +
      +    public function _externalInterfaceTest(isFirstCall: Boolean) : Boolean {
      +      var sandboxType:String = flash.system.Security['sandboxType'];
      +      if (!didSandboxMessage && sandboxType != 'localTrusted' && sandboxType != 'remote') {
      +        didSandboxMessage = true;
      +        flashDebug('<br><b>Fatal: Security sandbox error: Got "' + sandboxType + '", expected "remote" or "localTrusted".<br>Additional security permissions need to be granted.<br>See <a href="http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html">flash security settings panel</a> for non-HTTP, eg., file:// use.</b><br>http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html<br><br>You may also be able to right-click this movie and choose from the menu: <br>"Global Settings" -> "Advanced" tab -> "Trusted Location Settings"<br>');
      +      }
      +      try {
      +        if (isFirstCall == true) {
      +          flashDebug('Testing Flash -&gt; JS...');
      +          ExternalInterface.call(baseJSController + "._externalInterfaceOK", version);
      +          flashDebug('Flash -&gt; JS OK');
      +          flashDebug('Waiting for JS -&gt; Flash...');
      +        } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('SM2 SWF ' + version + ' ' + version_as, 1);

      + +
      + +
                ExternalInterface.call(baseJSController + "._setSandboxType", sandboxType);
      +          flashDebug('JS -&gt; Flash OK');
      +        }
      +      } catch(e: Error) {
      +        flashDebug('Fatal: Flash &lt;-&gt; JS error: ' + e.toString());
      +        writeDebug('_externalInterfaceTest: Error: ' + e.toString(), 2);
      +        if (!caughtFatal) {
      +          caughtFatal = true;
      +        }
      +        return false;
      +      }
      +      return true; // to verify that a call from JS to here, works. (eg. JS receives "true", thus OK.)
      +    }
      +
      +    public function _disableDebug() : void {
      + +
    • + + +
    • +
      + +
      + +
      +

      prevent future debug calls from Flash going to client (maybe improve performance)

      + +
      + +
            writeDebug('_disableDebug()');
      +      debugEnabled = false;
      +    }
      +
      +    public function checkLoadProgress(e: Event) : void {
      +      try {
      +        var oSound:Object = e.target;
      +        var bL: int = oSound.bytesLoaded;
      +        var bT: int = oSound.bytesTotal;
      +        var nD: int = oSound.length || oSound.duration || 0;
      +        var sMethod:String = baseJSObject + "['" + oSound.sID + "']._whileloading";
      +        ExternalInterface.call(sMethod, bL, bT, nD);
      +        if (bL && bT && bL != oSound.lastValues.bytes) {
      +          oSound.lastValues.bytes = bL;
      +          ExternalInterface.call(sMethod, bL, bT, nD);
      +        }
      +      } catch(e: Error) {
      +        writeDebug('checkLoadProgress(): ' + e.toString());
      +      }
      +    }
      +
      +    public function checkSoundProgress(oSound:SoundManager2_SMSound_AS3, forceCheck:Boolean = false, forceEndCheck:Boolean = false) : void {
      +      var bL: int = 0;
      +      var bT: int = 0;
      +      var nD: int = 0;
      +      var nP: int = 0;
      +      var bufferLength: int = 0;
      +      var lP:Number = 0;
      +      var rP:Number = 0;
      +      var isBuffering:Object = null;
      +      var oSoundChannel: flash.media.SoundChannel = null;
      +      var sMethod:String = null;
      +      var newPeakData: Boolean = false;
      +      var newWaveformData: Boolean = false;
      +      var newEQData: Boolean = false;
      +      var areSoundsInaccessible: Boolean = SoundMixer.areSoundsInaccessible();
      +      var isPlaying: Boolean = true; // special case for NetStream when ending
      +      var hasNew:Boolean = false;
      +      var hasNewLoaded:Boolean = false;
      +
      +      if (!oSound || !oSound.useEvents || oSound.failed || !oSound.connected) {
      + +
    • + + +
    • +
      + +
      + +
      +

      edge cases for ignoring: if sounds are destructed within event handlers while checkProgress() is running, may be null

      + +
      + +
              return;
      +      }
      +
      +      sMethod = baseJSObject + "['" + oSound.sID + "']._whileloading";
      +
      +      if (oSound.useNetstream) {
      + +
    • + + +
    • +
      + +
      + +
      +

      Don't do anything if there is no NetStream object yet

      + +
      + +
              if (!oSound.ns) {
      +          return;
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      stream

      + +
      + +
              bufferLength = oSound.ns.bufferLength;
      +        bL = oSound.ns.bytesLoaded;
      +        bT = oSound.ns.bytesTotal;
      +        nD = int(oSound.duration || 0); // can sometimes be null with short MP3s? Wack.
      +        nP = oSound.ns.time * 1000;
      +
      +        if (oSound.paused) {
      + +
    • + + +
    • +
      + +
      + +
      +

      special case: paused netStreams don't update if setPosition() is called while they are paused. +instead, return lastValues.position which should reflect setPosition() call. +writeDebug('paused case, setting nP of '+nP+' to -1'); +writeDebug('lastValues: '+oSound.lastValues.position);

      + +
      + +
                nP = oSound.lastValues.position;
      +        }
      +
      +        if (nP >= 0 && nP != oSound.lastValues.position) {
      +          oSound.lastValues.position = nP;
      +          hasNew = true;
      +        }
      +        if (nD > oSound.lastValues.duration) {
      +          oSound.lastValues.duration = nD;
      +          hasNew = true;
      +        }
      +        if (bL > oSound.lastValues.bytesLoaded) {
      +          oSound.lastValues.bytesLoaded = bL;
      +          hasNew = true;
      +        }
      +        if (bT > oSound.lastValues.bytes) {
      +          oSound.lastValues.bytes = bT;
      +          hasNew = true;
      +        }
      +        if (bufferLength != oSound.lastValues.bufferLength) {
      +          oSound.lastValues.bufferLength = bufferLength;
      +          hasNew = true;
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      Don't set loaded for streams because bytesLoaded and bytesTotal are always 0 +writeDebug('ns: time/duration, bytesloaded/total: '+nP+'/'+nD+', '+bL+'/'+bT);

      + +
      + +
              if (oSound.loaded != true && nD > 0 && bL == bT && bL != 0 && bT != 0) {
      + +
    • + + +
    • +
      + +
      + +
      +

      non-MP3 has loaded

      + +
      + +
                oSound.loaded = true;
      +          try {
      +            ExternalInterface.call(sMethod, bL, bT, nD, bufferLength);
      +            ExternalInterface.call(baseJSObject + "['" + oSound.sID + "']._onload", oSound.duration > 0 ? 1 : 0);
      +          } catch(e: Error) {
      +            writeDebug('_whileLoading/_onload error: ' + e.toString(), 2);
      +          }
      +        } else if (oSound.loaded != true && hasNew) {
      +          ExternalInterface.call(sMethod, bL, bT, nD, bufferLength);
      +        }
      +
      +      } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      MP3 sound

      + +
      + +
              oSoundChannel = oSound.soundChannel;
      +        bL = oSound.bytesLoaded;
      +        bT = oSound.bytesTotal;
      +        nD = int(oSound.length || 0); // can sometimes be null with short MP3s? Wack.
      +        isBuffering = oSound.isBuffering;
      +
      +        if (oSoundChannel) {
      +          nP = (oSoundChannel.position || 0);
      +          if (oSound.lastValues.loops > 1 && nP > oSound.length) {
      + +
    • + + +
    • +
      + +
      + +
      +

      round down to nearest loop

      + +
      + +
                  var playedLoops:Number = Math.floor(nP/oSound.length);
      +            nP = nP - (oSound.length*playedLoops);
      +          }
      +          if (oSound.usePeakData) {
      +            lP = int((oSoundChannel.leftPeak) * 1000) / 1000;
      +            rP = int((oSoundChannel.rightPeak) * 1000) / 1000;
      +          } else {
      +            lP = 0;
      +            rP = 0;
      +          }
      +          } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      stopped, not loaded or feature not used

      + +
      + +
                nP = 0;
      +        }
      +
      +        if (forceEndCheck) {
      + +
    • + + +
    • +
      + +
      + +
      +

      sound finish case: Ensure position is at end (sound duration), as flash 9 does not always correctly match the two.

      + +
      + +
                if (nP < nD) {
      +            writeDebug('correcting sound ' + oSound.sID + ' end position ('+nP+') to length: '+ nD, 2);
      +            nP = nD;
      +          }
      +        }
      +
      +        if (nP != oSound.lastValues.position && nP !== 0 && !oSound.didFinish) { // once "completed", sound is locked via didFinish so no more position-type events fire.
      +          oSound.lastValues.position = nP;
      +          hasNew = true;
      +        }
      +
      +        if (nD > oSound.lastValues.duration) { // original sound duration * number of sound loops
      +          oSound.lastValues.duration = nD;
      +          hasNew = true;
      +        }
      +
      +        if (bL > oSound.lastValues.bytesLoaded) {
      +          oSound.lastValues.bytesLoaded = bL;
      +          hasNew = true;
      +        }
      +
      +        if (bT > oSound.lastValues.bytes) {
      +          oSound.lastValues.bytes = bT;
      +          hasNew = true;
      +          hasNewLoaded = true;
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      loading progress

      + +
      + +
              if (hasNewLoaded) {
      +          oSound.lastValues.bytes = bL;
      +          ExternalInterface.call(sMethod, bL, bT, nD);
      +        }
      +
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      peak data

      + +
      + +
            if (oSoundChannel && oSound.usePeakData) {
      +        if (lP != oSound.lastValues.leftPeak) {
      +          oSound.lastValues.leftPeak = lP;
      +          newPeakData = true;
      +        }
      +        if (rP != oSound.lastValues.rightPeak) {
      +          oSound.lastValues.rightPeak = rP;
      +          newPeakData = true;
      +        }
      +      }
      +
      +      var newDataError:Boolean = false;
      +      var dataError:String;
      + +
    • + + +
    • +
      + +
      + +
      +

      special case: Netstream may try to fire whileplaying() after finishing. check that stop hasn't fired.

      + +
      + +
            isPlaying = (oSound.didLoad && !oSound.paused && (!oSound.useNetstream || (oSound.useNetstream && oSound.lastNetStatus != "NetStream.Play.Stop"))); // don't update if stream has ended
      + +
    • + + +
    • +
      + +
      + +
      +

      raw waveform + EQ spectrum data

      + +
      + +
            if (isPlaying && (oSoundChannel || oSound.useNetstream)) {
      +
      +        if (oSound.useWaveformData) {
      +          if (!areSoundsInaccessible && !oSound.handledDataError && !oSound.ignoreDataError) {
      +            try {
      +              oSound.getWaveformData();
      +            } catch(e: Error) {
      +              if (!oSound.handledDataError) {
      +                writeDebug('getWaveformData() (waveform data) '+e.toString());
      +              }
      + +
    • + + +
    • +
      + +
      + +
      +

      oSound.useWaveformData = false;

      + +
      + +
                    newDataError = true;
      +              dataError = e.toString();
      +            }
      +          }
      +        }
      +
      +        if (oSound.useEQData) {
      +          if (!areSoundsInaccessible && !oSound.handledDataError && !oSound.ignoreDataError) {
      +            try {
      +              oSound.getEQData();
      +            } catch(e: Error) {
      +              if (!oSound.handledDataError) {
      +                writeDebug('computeSpectrum() (EQ data) '+e.toString());
      +              }
      + +
    • + + +
    • +
      + +
      + +
      +

      oSound.useEQData = false;

      + +
      + +
                    newDataError = true;
      +              dataError = e.toString();
      +            }
      +          }
      +        }
      +
      +        if (oSound.waveformDataArray != oSound.lastValues.waveformDataArray) {
      +          oSound.lastValues.waveformDataArray = oSound.waveformDataArray;
      +          newWaveformData = true;
      +        }
      +
      +        if (oSound.eqDataArray != oSound.lastValues.eqDataArray) {
      +          oSound.lastValues.eqDataArray = oSound.eqDataArray;
      +          newEQData = true;
      +        }
      +
      +        if (newDataError && !oSound.handledDataError) {
      +          sMethod = baseJSObject + "['" + oSound.sID + "']._ondataerror";
      +          ExternalInterface.call(sMethod, 'data unavailable: ' + dataError);
      +          oSound.handledDataError = true;
      +        }
      +
      +      }
      +
      +      if (typeof nP != 'undefined' && (hasNew && (oSound.soundChannel || oSound.useNetstream || forceCheck || forceEndCheck))) { // && isPlaying - removed to allow updates while paused, eg. from setPosition() calls. Also be more liberal if we're using netStream.
      + +
    • + + +
    • +
      + +
      + +
      +

      oSound.lastValues.position = nP;

      + +
      + +
              sMethod = baseJSObject + "['" + oSound.sID + "']._whileplaying";
      +        var waveDataLeft:String = (newWaveformData ? oSound.waveformDataArray.slice(0, 256).join(',') : null);
      +        var waveDataRight:String = (newWaveformData ? oSound.waveformDataArray.slice(256).join(',') : null);
      +        var eqDataLeft:String = (newEQData ? oSound.eqDataArray.slice(0, 256).join(',') : null);
      +        var eqDataRight:String = (newEQData ? oSound.eqDataArray.slice(256).join(',') : null);
      +        ExternalInterface.call(sMethod, nP, (newPeakData ? {
      +          leftPeak: lP,
      +          rightPeak: rP
      +        } : null), waveDataLeft, waveDataRight, (newEQData ? {
      +          leftEQ: eqDataLeft,
      +          rightEQ: eqDataRight
      +        } : null));
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      check isBuffering

      + +
      + +
            if (!oSound.useNetstream && oSound.isBuffering != oSound.lastValues.isBuffering) {
      + +
    • + + +
    • +
      + +
      + +
      +

      property has changed

      + +
      + +
              oSound.lastValues.isBuffering = oSound.isBuffering;
      +        sMethod = baseJSObject + "['" + oSound.sID + "']._onbufferchange";
      +        ExternalInterface.call(sMethod, oSound.isBuffering ? 1 : 0);
      +      }
      +
      +    }
      +
      +    public function checkProgress() : void {
      +      for (var i: int = 0, j: int = sounds.length; i < j; i++) {
      +        checkSoundProgress(soundObjects[sounds[i]]);
      +      }
      +    }
      +
      +    public function onLoadError(oSound:Object) : void {
      + +
    • + + +
    • +
      + +
      + +
      +

      something went wrong. 404, bad format etc.

      + +
      + +
            ExternalInterface.call(baseJSObject + "['" + oSound.sID + "']._onload", 0);
      +    }
      +
      +    public function onLoad(e: Event) : void {
      +      var oSound:Object = e.target;
      +      checkSoundProgress(soundObjects[oSound.sID]); // ensure progress stats are up-to-date
      +      if (!oSound.useNetstream) { // FLV must also have metadata
      +        oSound.loaded = true;
      + +
    • + + +
    • +
      + +
      + +
      +

      force duration update (doesn't seem to be always accurate)

      + +
      + +
              ExternalInterface.call(baseJSObject + "['" + oSound.sID + "']._whileloading", oSound.bytesLoaded, oSound.bytesTotal, oSound.length || oSound.duration);
      + +
    • + + +
    • +
      + +
      + +
      +

      duration > 0 means a valid sound was loaded.

      + +
      + +
              ExternalInterface.call(baseJSObject + "['" + oSound.sID + "']._onload", (oSound.length || oSound.duration ? 1 : 0));
      +      }
      +    }
      +
      +    public function onID3(e: Event) : void {
      + +
    • + + +
    • +
      + +
      + +
      +

      --- NOTE: BUGGY (Flash 8 only? Haven't really checked 9 + 10.) --- +TODO: Investigate holes in ID3 parsing - for some reason, Album will be populated with Date if empty and date is provided. (?) +ID3V1 seem to parse OK, but "holes" / blanks in ID3V2 data seem to get messed up (eg. missing album gets filled with date.) +iTunes issues: onID3 was not called with a test MP3 encoded with iTunes 7.01, and what appeared to be valid ID3V2 data. +May be related to thumbnails for album art included in MP3 file by iTunes. See http://mabblog.com/blog/?p=33

      + +
      + +
            try {
      +        var oSound:Object = e.target;
      +
      +        var id3Data:Array = [];
      +        var id3Props:Array = [];
      +        for (var prop:String in oSound.id3) {
      +          id3Props.push(prop);
      +          id3Data.push(oSound.id3[prop]);
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('id3['+prop+']: '+oSound.id3[prop]);

      + +
      + +
              }
      +        ExternalInterface.call(baseJSObject + "['" + oSound.sID + "']._onid3", id3Props, id3Data);
      + +
    • + + +
    • +
      + +
      + +
      +

      unhook own event handler, prevent second call (can fire twice as data is received - ID3V2 at beginning, ID3V1 at end.) +Therefore if ID3V2 data is received, ID3V1 is ignored. +soundObjects[oSound.sID].onID3 = null;

      + +
      + +
            } catch(e: Error) {
      +        writeDebug('onID3(): Unable to get ID3 info for ' + oSound.sID + '.');
      +      }
      +      oSound.removeEventListener(Event.ID3, onID3);
      +    }
      +
      +    public function registerOnComplete(sID:String) : void {
      +      var oSound: SoundManager2_SMSound_AS3 = soundObjects[sID];
      +      if (oSound && oSound.soundChannel) {
      +        oSound.didFinish = false; // reset this flag
      +        oSound.soundChannel.addEventListener(Event.SOUND_COMPLETE, function() : void {
      +          if (oSound) {
      + +
    • + + +
    • +
      + +
      + +
      +

      force progress check, catching special end-of-sound case where position may not match duration.

      + +
      + +
                  checkSoundProgress(oSound, true, true);
      +            try {
      +              oSound.ignoreDataError = true; // workaround: avoid data error handling for this manual step..
      + +
    • + + +
    • +
      + +
      + +
      +

      oSound.soundChannel.stop();

      + +
      + +
                    oSound.didFinish = true; // "lock" sound, prevent extra whileplaying() position-type updates
      + +
    • + + +
    • +
      + +
      + +
      +

      call onfinish first (with end position)...

      + +
      + +
                    ExternalInterface.call(baseJSObject + "['" + sID + "']._onfinish");
      + +
    • + + +
    • +
      + +
      + +
      +

      then reset sound so it can be played again. +oSound.start(0, 1); // go back to 0

      + +
      + +
                  } catch(e: Error) {
      +              writeDebug('Could not set position on ' + sID + ': ' + e.toString());
      +            }
      +            oSound.ignoreDataError = false; // ..and reset
      +            oSound.handledDataError = false; // reset this flag
      +          } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      safety net

      + +
      + +
                  ExternalInterface.call(baseJSObject + "['" + sID + "']._onfinish");
      +          }
      +        });
      +      }
      +    }
      +
      +    public function doSecurityError(oSound: SoundManager2_SMSound_AS3, e: SecurityErrorEvent) : void {
      +      writeDebug('securityError: ' + e.text);
      + +
    • + + +
    • +
      + +
      + +
      +

      when this happens, you don't have security rights on the server containing the FLV file +a crossdomain.xml file would fix the problem easily

      + +
      + +
          }
      +
      +    public function _setPosition(sID:String, nSecOffset:Number, isPaused: Boolean, allowMultiShot: Boolean) : void {
      +      var s: SoundManager2_SMSound_AS3 = soundObjects[sID];
      +      if (!s) return void;
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('_setPosition()');

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      stop current channel, start new one.

      + +
      + +
            if (s.lastValues) {
      +        s.lastValues.position = nSecOffset; // s.soundChannel.position;
      +      }
      +      if (s.useNetstream) {
      + +
    • + + +
    • +
      + +
      + +
      +

      Minimize the buffer so playback starts ASAP

      + +
      + +
              s.ns.bufferTime = s.bufferTime;
      +        writeDebug('setPosition ('+ sID + '): setting buffer to '+s.ns.bufferTime+' secs');
      +
      +        nSecOffset = nSecOffset > 0 ? nSecOffset / 1000 : 0;
      +        s.ns.seek(nSecOffset);
      +        checkSoundProgress(s); // force UI update
      +      } else {
      +        if (s.soundChannel) {
      +          s.soundChannel.stop();
      +        }
      +        writeDebug('setPosition ('+ sID + '): ' + nSecOffset); // +', '+(s.lastValues.loops?s.lastValues.loops:1));
      +        if (s.lastValues.loops > 1 && nSecOffset != 0) {
      +          writeDebug('Warning: Looping functionality being disabled due to Flash limitation.');
      +          s.lastValues.loops = 1;
      +        }
      +        try {
      +          s.start(nSecOffset, s.lastValues.loops || 1, allowMultiShot); // start playing at new position
      +        } catch(e: Error) {
      +          writeDebug('Warning: Could not set position on ' + sID + ': ' + e.toString());
      +        }
      +        checkSoundProgress(s); // force UI update
      +        try {
      +          registerOnComplete(sID);
      +        } catch(e: Error) {
      +          writeDebug('_setPosition(): Could not register onComplete');
      +        }
      +        if (isPaused && s.soundChannel) {
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('_setPosition: stopping (paused) sound'); +writeDebug('last position: '+s.lastValues.position+' vs '+s.soundChannel.position);

      + +
      + +
                s.soundChannel.stop();
      +        }
      +      }
      +    }
      +
      +    public function _load(sID:String, sURL:String, bStream: Boolean, bAutoPlay: Boolean, nLoops: Number, bAutoLoad: Boolean, bCheckPolicyFile: Boolean) : void {
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('_load()');

      + +
      + +
            if (typeof bAutoPlay == 'undefined') bAutoPlay = false;
      +      var s: SoundManager2_SMSound_AS3 = soundObjects[sID];
      +      if (!s) return void;
      +      var didRecreate: Boolean = false;
      +      if (s.didLoad == true) {
      + +
    • + + +
    • +
      + +
      + +
      +

      need to recreate sound

      + +
      + +
              didRecreate = true;
      +        writeDebug('recreating sound ' + sID + ' in order to load ' + sURL);
      +        var ns:Object = new Object();
      +        ns.sID = s.sID;
      +        ns.loops = nLoops||1;
      +        ns.usePeakData = s.usePeakData;
      +        ns.useWaveformData = s.useWaveformData;
      +        ns.useEQData = s.useEQData;
      +        ns.useNetstream = s.useNetstream;
      +        ns.bufferTime = s.bufferTime;
      +        ns.serverUrl = s.serverUrl;
      +        ns.duration = s.duration;
      +        ns.checkPolicyFile = s.checkPolicyFile;
      +        ns.useEvents = true;
      +        _destroySound(s.sID);
      +        _createSound(ns.sID, sURL, ns.usePeakData, ns.useWaveformData, ns.useEQData, ns.useNetstream, ns.bufferTime, ns.loops, ns.serverUrl, ns.duration, bAutoPlay, ns.useEvents, bAutoLoad, ns.checkPolicyFile);
      +        s = soundObjects[sID];
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('Sound object replaced');

      + +
      + +
            }
      +      checkSoundProgress(s);
      +
      +      if (!s.didLoad) {
      +        try {
      +          s.addEventListener(Event.ID3, onID3);
      +          s.addEventListener(Event.COMPLETE, onLoad);
      +        } catch(e: Error) {
      +          writeDebug('_load(): could not assign ID3/complete event handlers');
      +        }
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      don't try to load if same request already made

      + +
      + +
            s.sURL = sURL;
      +
      +      try {
      +        if (!s.useNetstream) {
      +          s.addEventListener(IOErrorEvent.IO_ERROR, function(e: IOErrorEvent) : void {
      +            s.doIOError(e);
      +          });
      +        }
      +        s.loadSound(sURL);
      +      } catch(e: Error) {
      + +
    • + + +
    • +
      + +
      + +
      +

      oh well

      + +
      + +
              writeDebug('_load: Error loading ' + sURL + '. Flash error detail: ' + e.toString());
      +      }
      +
      +    }
      +
      +    public function _unload(sID:String) : void {
      +      var s: SoundManager2_SMSound_AS3 = (soundObjects[sID] || null);
      +      if (!s) return void;
      +      var sURL:String = s.sURL; // save existing sound URL for object recreation
      +      try {
      +        removeEventListener(Event.ID3, onID3);
      +        removeEventListener(Event.COMPLETE, onLoad);
      +      } catch(e: Error) {
      +        writeDebug('_unload() warn: Could not remove ID3/complete events');
      +      }
      +      s.paused = false;
      +      if (s.soundChannel) {
      +        s.soundChannel.stop();
      +      }
      +      try {
      +        if (s.didLoad && !s.loaded && !s.useNetstream) {
      +          s.close(); // close stream only if still loading?
      +        }
      +      } catch(e: Error) {
      + +
    • + + +
    • +
      + +
      + +
      +

      stream may already have closed if sound loaded, etc.

      + +
      + +
              writeDebug(sID + '._unload(): Note: Unable to close stream: ' + e.toString());
      + +
    • + + +
    • +
      + +
      + +
      +

      oh well

      + +
      + +
            }
      + +
    • + + +
    • +
      + +
      + +
      +

      destroy and recreate Flash sound object, try to reclaim memory +writeDebug('sound._unload(): recreating sound '+sID+' to free memory');

      + +
      + +
            if (s.useNetstream) {
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('_unload(): closing netStream stuff');

      + +
      + +
              try {
      +          s.removeNetstreamEvents();
      +          s.ns.close();
      +          s.nc.close();
      + +
    • + + +
    • +
      + +
      + +
      +

      s.nc = null; +s.ns = null;

      + +
      + +
              } catch(e: Error) {
      + +
    • + + +
    • +
      + +
      + +
      +

      oh well

      + +
      + +
                writeDebug('_unload(): caught exception during netConnection/netStream close');
      +        }
      +      }
      +      var ns:Object = new Object();
      +      ns.sID = s.sID;
      +      ns.loops = s.loops;
      +      ns.usePeakData = s.usePeakData;
      +      ns.useWaveformData = s.useWaveformData;
      +      ns.useEQData = s.useEQData;
      +      ns.useNetstream = s.useNetstream;
      +      ns.bufferTime = s.bufferTime;
      +      ns.serverUrl = s.serverUrl;
      +      ns.duration = s.duration;
      +      ns.autoPlay = s.autoPlay;
      +      ns.autoLoad = s.autoLoad;
      +      ns.checkPolicyFile = s.checkPolicyFile;
      +      _destroySound(s.sID);
      +      _createSound(ns.sID, sURL, ns.usePeakData, ns.useWaveformData, ns.useEQData, ns.useNetstream, ns.bufferTime, ns.loops, ns.serverUrl, ns.duration, ns.autoPlay, false, ns.autoLoad, ns.checkPolicyFile); // false: don't allow events just yet
      +      soundObjects[sID].connected = true; // fake it?
      +      writeDebug(s.sID + '.unload(): ok');
      +    }
      +
      +    public function _createSound(sID:String, sURL:String, usePeakData: Boolean, useWaveformData: Boolean, useEQData: Boolean, useNetstream: Boolean, bufferTime:Number, loops:Number, serverUrl:String, duration:Number, autoPlay:Boolean, useEvents:Boolean, autoLoad:Boolean, checkPolicyFile:Boolean) : void {
      +      var s: SoundManager2_SMSound_AS3 = new SoundManager2_SMSound_AS3(this, sID, sURL, usePeakData, useWaveformData, useEQData, useNetstream, bufferTime, serverUrl, duration, autoPlay, useEvents, autoLoad, checkPolicyFile);
      +      if (!soundObjects[sID]) {
      +        sounds.push(sID);
      +      }
      +      soundObjects[sID] = s;
      +      this.currentObject = s;
      +      s.sID = sID;
      +      s.sURL = sURL;
      +      s.paused = false;
      +      s.loaded = false;
      +      s.checkPolicyFile = checkPolicyFile;
      +      s.lastValues = {
      +        bytes: 0,
      +        duration: 0,
      +        position: 0,
      +        loops: loops||1,
      +        leftPeak: 0,
      +        rightPeak: 0,
      +        bufferLength: 0
      +      };
      +    }
      +
      +    public function _destroySound(sID:String) : void {
      + +
    • + + +
    • +
      + +
      + +
      +

      for the power of garbage collection! .. er, Greyskull!

      + +
      + +
            var s: SoundManager2_SMSound_AS3 = (soundObjects[sID] || null);
      +      if (!s) return void;
      + +
    • + + +
    • +
      + +
      + +
      +

      try to unload the sound

      + +
      + +
            for (var i: int = 0, j: int = sounds.length; i < j; i++) {
      +        if (sounds[i] == sID) {
      +          sounds.splice(i, 1);
      +          break;
      +        }
      +      }
      +      if (s.soundChannel) {
      +        s.soundChannel.stop();
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      if is a movie, remove that as well.

      + +
      + +
            if (s.useNetstream) {
      + +
    • + + +
    • +
      + +
      + +
      +

      s.nc.client = null;

      + +
      + +
              try {
      +          s.removeNetstreamEvents();
      + +
    • + + +
    • +
      + +
      + +
      +

      s.nc.removeEventListener(NetStatusEvent.NET_STATUS, s.doNetStatus);

      + +
      + +
              } catch(e: Error) {
      +          writeDebug('_destroySound(): Events already removed from netStream/netConnection?');
      +        }
      +        if (s.didLoad) {
      + +
    • + + +
    • +
      + +
      + +
      +

      TODO: figure out if stream is still open first, can't close an already-closed stream.

      + +
      + +
                try {
      +            s.ns.close();
      +            s.nc.close();
      +          } catch(e: Error) {
      + +
    • + + +
    • +
      + +
      + +
      +

      oh well

      + +
      + +
                  writeDebug('_destroySound(): caught exception: '+e.toString());
      +          }
      +        }
      +      } else if (s.didLoad) {
      + +
    • + + +
    • +
      + +
      + +
      +

      non-netstream case

      + +
      + +
              try {
      +          s.close(); // close stream only if still loading?
      +        } catch(e: Error) {
      + +
    • + + +
    • +
      + +
      + +
      +

      oh well

      + +
      + +
              }
      +      }
      +      s = null;
      +      soundObjects[sID] = null;
      +      delete soundObjects[sID];
      +    }
      +
      +    public function _stop(sID:String, bStopAll: Boolean) : void {
      + +
    • + + +
    • +
      + +
      + +
      +

      stop this particular instance (or "all", based on parameter)

      + +
      + +
            if (bStopAll) {
      +        SoundMixer.stopAll();
      +      } else {
      +        var s: SoundManager2_SMSound_AS3 = soundObjects[sID];
      +        if (!s) return void;
      +        if (s.useNetstream && s.ns) {
      +          s.ns.pause();
      +        } else if (s.soundChannel) {
      +          s.soundChannel.stop();
      +        }
      +        s.paused = false;
      +      }
      +    }
      +
      +    public function _start(sID:String, nLoops: int, nMsecOffset: int, allowMultiShot: Boolean) : Boolean {
      +      var s: SoundManager2_SMSound_AS3 = soundObjects[sID];
      +      var result: Boolean;
      +      if (!s) return true;
      +      writeDebug('start (' + sID + '): ' + nMsecOffset + (nLoops > 1 ? ', loops: ' + nLoops : ''));
      +      s.lastValues.paused = false; // reset pause if applicable
      +      s.lastValues.loops = (nLoops || 1);
      +      if (!s.useNetstream) {
      +        s.lastValues.position = nMsecOffset;
      +      }
      +      s.handledDataError = false; // reset this flag
      +      try {
      +        result = s.start(nMsecOffset, nLoops, allowMultiShot);
      +      } catch(e: Error) {
      +        writeDebug('Could not start ' + sID + ': ' + e.toString());
      +      }
      +      try {
      +        registerOnComplete(sID);
      +      } catch(e: Error) {
      +        writeDebug('_start(): registerOnComplete failed');
      +      }
      +      return result;
      +    }
      +
      +    public function _pause(sID:String, allowMultiShot: Boolean) : void {
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('_pause(): ' + sID);

      + +
      + +
            var s: SoundManager2_SMSound_AS3 = soundObjects[sID];
      +      if (!s) return void;
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('s.paused: '+s.paused);

      + +
      + +
            if (!s.paused) {
      + +
    • + + +
    • +
      + +
      + +
      +

      reference current position, stop sound

      + +
      + +
              s.paused = true;
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('_pause(): position: '+s.lastValues.position);

      + +
      + +
              if (s.useNetstream) {
      +          if (s.ns) {
      +            s.lastValues.position = s.ns.time*1000;
      +            s.ns.pause();
      +          } else if (s.autoPlay) {
      +            s.setAutoPlay(false);
      +          }
      +        } else {
      +          if (s.soundChannel) {
      +            s.lastValues.position = s.soundChannel.position;
      +            s.soundChannel.stop();
      +          }
      +        }
      +      } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      resume playing from last position +writeDebug('resuming - playing at '+s.lastValues.position+', '+s.lastValues.loops+' times');

      + +
      + +
              s.paused = false;
      +        if (s.useNetstream) {
      +          s.ns.resume();
      +        } else {
      +          s.start(s.lastValues.position, s.lastValues.loops, allowMultiShot);
      +        }
      +        try {
      +          registerOnComplete(sID);
      +        } catch(e: Error) {
      +          writeDebug('_pause(): registerOnComplete() failed');
      +        }
      +      }
      +    }
      +
      +    public function _setPan(sID:String, nPan:Number) : void {
      +      if (soundObjects[sID]) {
      +        soundObjects[sID].setPan(nPan);
      +      }
      +    }
      +
      +    public function _setVolume(sID:String, nVol:Number) : void {
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('_setVolume: '+nVol);

      + +
      + +
            if (soundObjects[sID]) {
      +        soundObjects[sID].setVolume(nVol);
      +      }
      +    }
      +
      +    public function _setPolling(bPolling: Boolean = false, nTimerInterval: uint = 50) : void {
      +      pollingEnabled = bPolling;
      +      if (timer == null && pollingEnabled) {
      +        flashDebug('Enabling polling, ' + nTimerInterval + ' ms interval');
      +        timer = new Timer(nTimerInterval, 0);
      +        timer.addEventListener(TimerEvent.TIMER, function() : void {
      +          checkProgress();
      +        }); // direct reference eg. checkProgress doesn't work? .. odd.
      +        timer.start();
      +      } else if (timer && !pollingEnabled) {
      +        flashDebug('Disabling polling');
      + +
    • + + +
    • +
      + +
      + +
      +

      flash.utils.clearInterval(timer);

      + +
      + +
              timer.reset();
      +      }
      +    }
      +
      +    public function _getMemoryUse() : String {
      +      return System.totalMemory.toString();
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +
      +

      end methods

      + +
      + +
      +  }
      + +
    • + + +
    • +
      + +
      + +
      +

      package

      + +
      + +
      +}
      + +
    • + +
    +
    + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/SoundManager2_SMSound_AS3.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/SoundManager2_SMSound_AS3.html new file mode 100755 index 00000000..ff0ae3f4 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/SoundManager2_SMSound_AS3.html @@ -0,0 +1,1302 @@ + + + + + SoundManager2_SMSound_AS3.as + + + + + + +
    +
    + + + +
      + +
    • +
      +

      SoundManager2_SMSound_AS3.as

      +
      +
    • + + + +
    • +
      + +
      + +
      + +
      + +
      /**
      + * SoundManager 2: Javascript Sound for the Web
      + * ----------------------------------------------
      + * http://schillmania.com/projects/soundmanager2/
      + *
      + * Copyright (c) 2007, Scott Schiller. All rights reserved.
      + * Code licensed under the BSD License:
      + * http://www.schillmania.com/projects/soundmanager2/license.txt
      + *
      + * Flash 9 / ActionScript 3 version
      + */
      +
      +package {
      +
      +  import flash.external.*;
      +  import flash.events.*;
      +  import flash.media.Sound;
      +  import flash.media.SoundChannel;
      +  import flash.media.SoundLoaderContext;
      +  import flash.media.SoundTransform;
      +  import flash.media.SoundMixer;
      +  import flash.net.URLRequest;
      +  import flash.utils.ByteArray;
      +  import flash.utils.getTimer;
      +  import flash.net.NetConnection;
      +  import flash.net.NetStream;
      +  import flash.net.Responder;
      +
      +  public class SoundManager2_SMSound_AS3 extends Sound {
      +
      +    public var sm: SoundManager2_AS3 = null;
      + +
    • + + +
    • +
      + +
      + +
      +

      externalInterface references (for Javascript callbacks)

      + +
      + +
          public var baseJSController: String = "soundManager";
      +    public var baseJSObject: String = baseJSController + ".sounds";
      +    public var soundChannel: SoundChannel = new SoundChannel();
      +    public var urlRequest: URLRequest;
      +    public var soundLoaderContext: SoundLoaderContext;
      +    public var waveformData: ByteArray = new ByteArray();
      +    public var waveformDataArray: Array = [];
      +    public var eqData: ByteArray = new ByteArray();
      +    public var eqDataArray: Array = [];
      +    public var usePeakData: Boolean = false;
      +    public var useWaveformData: Boolean = false;
      +    public var useEQData: Boolean = false;
      +    public var sID: String;
      +    public var sURL: String;
      +    public var didFinish: Boolean;
      +    public var loaded: Boolean;
      +    public var connected: Boolean;
      +    public var failed: Boolean;
      +    public var paused: Boolean;
      +    public var finished: Boolean;
      +    public var duration: Number;
      +    public var handledDataError: Boolean = false;
      +    public var ignoreDataError: Boolean = false;
      +    public var autoPlay: Boolean = false;
      +    public var autoLoad: Boolean = false;
      +    public var pauseOnBufferFull: Boolean = false; // only applies to RTMP
      +    public var loops: Number = 1;
      +    public var lastValues: Object = {
      +      bytes: 0,
      +      position: 0,
      +      duration: 0,
      +      volume: 100,
      +      pan: 0,
      +      loops: 1,
      +      leftPeak: 0,
      +      rightPeak: 0,
      +      waveformDataArray: null,
      +      eqDataArray: null,
      +      isBuffering: null,
      +      bufferLength: 0
      +    };
      +    public var didLoad: Boolean = false;
      +    public var useEvents: Boolean = false;
      +    public var sound: Sound = new Sound();
      +
      +    public var cc: Object;
      +    public var nc: NetConnection;
      +    public var ns: NetStream = null;
      +    public var st: SoundTransform;
      +    public var useNetstream: Boolean;
      +    public var bufferTime: Number = 3; // previously 0.1
      +    public var lastNetStatus: String = null;
      +    public var serverUrl: String = null;
      +
      +    public var checkPolicyFile:Boolean = false;
      +
      +    public function SoundManager2_SMSound_AS3(oSoundManager: SoundManager2_AS3, sIDArg: String = null, sURLArg: String = null, usePeakData: Boolean = false, useWaveformData: Boolean = false, useEQData: Boolean = false, useNetstreamArg: Boolean = false, netStreamBufferTime: Number = 1, serverUrl: String = null, duration: Number = 0, autoPlay: Boolean = false, useEvents: Boolean = false, autoLoad: Boolean = false, checkPolicyFile: Boolean = false) {
      +      this.sm = oSoundManager;
      +      this.sID = sIDArg;
      +      this.sURL = sURLArg;
      +      this.usePeakData = usePeakData;
      +      this.useWaveformData = useWaveformData;
      +      this.useEQData = useEQData;
      +      this.urlRequest = new URLRequest(sURLArg);
      +      this.didFinish = false;
      +      this.loaded = false;
      +      this.connected = false;
      +      this.failed = false;
      +      this.finished = false;
      +      this.soundChannel = null;
      +      this.lastNetStatus = null;
      +      this.useNetstream = useNetstreamArg;
      +      this.serverUrl = serverUrl;
      +      this.duration = duration;
      +      this.useEvents = useEvents;
      +      this.autoLoad = autoLoad;
      +      if (netStreamBufferTime) {
      +        this.bufferTime = netStreamBufferTime;
      +      }
      +      this.checkPolicyFile = checkPolicyFile;
      +
      +      writeDebug('SoundManager2_SMSound_AS3: Got duration: '+duration+', autoPlay: '+autoPlay);
      +
      +      if (this.useNetstream) {
      + +
    • + + +
    • +
      + +
      + +
      +

      Pause on buffer full if auto-loading an RTMP stream

      + +
      + +
              if (this.serverUrl && this.autoLoad) {
      +          this.pauseOnBufferFull = true;
      +        }
      +
      +        this.cc = new Object();
      +        this.nc = new NetConnection();
      + +
    • + + +
    • + + +
              this.nc.client = this;
      + +
    • + + +
    • +
      + +
      + +
      +

      TODO: security/IO error handling +this.nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, doSecurityError);

      + +
      + +
              nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
      +
      +        if (this.serverUrl != null) {
      +          writeDebug('SoundManager2_SMSound_AS3: NetConnection: connecting to server ' + this.serverUrl + '...');
      +        }
      +        this.nc.connect(serverUrl);
      +      } else {
      +        this.connected = true;
      +      }
      +
      +    }
      +
      +    public function rtmpResponder(result:Object):void {
      + +
    • + + +
    • +
      + +
      + +
      +

      callback from Flash Media Server (RTMP) for 'getStreamLength' server-side method - result should be a floating-point. +http://help.adobe.com/en_US/FlashMediaServer/3.5_Deving/WS5b3ccc516d4fbf351e63e3d11a0773d117-7ffe.html

      + +
      + +
            writeDebug('RTMP server getStreamLength() response: ' + result);
      + +
    • + + +
    • +
      + +
      + +
      +

      we now know the duration. type cast to floating-point - this will update JS-land during whileloading() / whileplaying().

      + +
      + +
            this.duration = Number(result) * 1000;
      +    }
      +
      +    public function netStatusHandler(event:NetStatusEvent):void {
      +
      +      if (this.useEvents) {
      +        writeDebug('netStatusHandler: '+event.info.code);
      +      }
      +
      +      switch (event.info.code) {
      +
      +        case "NetConnection.Connect.Success":
      +          try {
      +            this.ns = new NetStream(this.nc);
      +            this.ns.checkPolicyFile = this.checkPolicyFile;
      + +
    • + + +
    • + + +
                  this.ns.bufferTime = this.bufferTime; // set to 0.1 or higher. 0 is reported to cause playback issues with static files.
      +            this.st = new SoundTransform();
      +            this.cc.onMetaData = this.onMetaData;
      +            this.cc.setCaption = this.captionHandler;
      +            this.ns.client = this.cc;
      +            this.ns.receiveAudio(true);
      +            this.addNetstreamEvents();
      +            this.connected = true;
      + +
    • + + +
    • +
      + +
      + +
      +

      RTMP-only

      + +
      + +
                  if (this.serverUrl && this.useEvents) {
      +              var responder:Responder = new Responder(rtmpResponder);
      + +
    • + + +
    • +
      + +
      + +
      +

      call a method on server to get the length of the stream (like onMetaData, but Flash Media Server-specific) +Red5 and other RTMP servers appear to provide duration via onMetaData event(s) in the stream. +http://help.adobe.com/en_US/FlashMediaServer/3.5_Deving/WS5b3ccc516d4fbf351e63e3d11a0773d117-7ffe.html

      + +
      + +
                    nc.call('getStreamLength', responder, this.sURL);
      +              writeDebug('NetConnection: connected');
      +              writeDebug('firing _onconnect for '+this.sID);
      +              ExternalInterface.call(this.sm.baseJSObject + "['" + this.sID + "']._onconnect", 1);
      +            }
      +          } catch(e: Error) {
      +            this.failed = true;
      +            writeDebug('netStream error: ' + e.toString());
      +            ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfailure", 'Connection failed!', event.info.level, event.info.code);
      +          }
      +          break;
      +
      +        case "NetStream.Play.StreamNotFound":
      +          this.failed = true;
      +          writeDebug("NetConnection: Stream not found!");
      +          ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfailure", 'Stream not found!', event.info.level, event.info.code);
      +          break;
      + +
    • + + +
    • +
      + +
      + +
      +

      This is triggered when the sound loses the connection with the server. +In some cases one could just try to reconnect to the server and resume playback. +However for streams protected by expiring tokens, I don't think that will work.

      +

      Flash says that this is not an error code, but a status code... +should this call the onFailure handler?

      + +
      + +
              case "NetConnection.Connect.Closed":
      +          this.failed = true;
      +          ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfailure", 'Connection closed!', event.info.level, event.info.code);
      +          writeDebug("NetConnection: Connection closed!");
      +          break;
      + +
    • + + +
    • +
      + +
      + +
      +

      Couldn't establish a connection with the server. Attempts to connect to the server +can also fail if the permissible number of socket connections on either the client +or the server computer is at its limit. This also happens when the internet +connection is lost.

      + +
      + +
              case "NetConnection.Connect.Failed":
      +          this.failed = true;
      +          writeDebug("NetConnection: Connection failed! Lost internet connection? Try again... Description: " + event.info.description);
      +          ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfailure", 'Connection failed!', event.info.level, event.info.code);
      +          break;
      + +
    • + + +
    • +
      + +
      + +
      +

      A change has occurred to the network status. This could mean that the network +connection is back, or it could mean that it has been lost...just try to resume +playback.

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      KJV: Can't use this yet because by the time you get your connection back the +song has reached it's maximum retries, so it doesn't retry again. We need +a new _ondisconnect handler. +case "NetConnection.Connect.NetworkChange": + this.failed = true; + writeDebug("NetConnection: Network connection status changed"); + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfailure", 'Reconnecting...'); + break;

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      Consider everything else a failure...

      + +
      + +
              default:
      +          this.failed = true;
      +          writeDebug("NetConnection: got unhandled code '" + event.info.code + "'! Description: " + event.info.description);
      +          ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfailure", '', event.info.level, event.info.code);
      +          break;
      +      }
      +
      +    }
      +
      +    public function writeDebug (s: String, logLevel: Number = 0) : Boolean {
      +      return this.sm.writeDebug (s,logLevel); // defined in main SM object
      +    }
      +
      +    public function onMetaData(infoObject: Object) : void {
      +      var prop:String;
      +      if (sm.debugEnabled) {
      +        var data:String = new String();
      +        for (prop in infoObject) {
      +          data += prop+': '+infoObject[prop]+' \n';
      +        }
      +        writeDebug('Metadata: '+data);
      +      }
      +      this.duration = infoObject.duration * 1000;
      +      if (!this.loaded) {
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('not loaded yet: '+this.ns.bytesLoaded+', '+this.ns.bytesTotal+', '+infoObject.duration1000); +TODO: investigate loaded/total values +ExternalInterface.call(baseJSObject + "['" + this.sID + "']._whileloading", this.ns.bytesLoaded, this.ns.bytesTotal, infoObject.duration1000);

      + +
      + +
              ExternalInterface.call(baseJSObject + "['" + this.sID + "']._whileloading", this.bytesLoaded, this.bytesTotal, (this.duration || infoObject.duration))
      +      }
      +      var metaData:Array = [];
      +      var metaDataProps:Array = [];
      +      for (prop in infoObject) {
      +        metaData.push(prop);
      +        metaDataProps.push(infoObject[prop]);
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      pass infoObject to _onmetadata, too

      + +
      + +
            ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onmetadata", metaData, metaDataProps);
      + +
    • + + +
    • +
      + +
      + +
      +

      this handler may fire multiple times, eg., when a song changes while playing an RTMP stream.

      + +
      + +
            if (!this.serverUrl) {
      + +
    • + + +
    • +
      + +
      + +
      +

      disconnect for non-RTMP cases, since multiple firings may mess up duration.

      + +
      + +
              this.cc.onMetaData = function(infoObject: Object) : void {}
      +      }
      +    }
      +
      +    public function captionHandler(infoObject: Object) : void {
      +
      +      if (sm.debugEnabled) {
      +        var data:String = new String();
      +        for (var prop:* in infoObject) {
      +          data += prop+': '+infoObject[prop]+' \n';
      +        }
      +        writeDebug('Caption: '+data);
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      null this out for the duration of this object's existence. +it may be called multiple times. +this.cc.setCaption = function(infoObject: Object) : void {}

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('Caption\n'+infoObject['dynamicMetadata']); +writeDebug('firing _oncaptiondata for '+this.sID);

      + +
      + +
      +      ExternalInterface.call(this.sm.baseJSObject + "['" + this.sID + "']._oncaptiondata", infoObject['dynamicMetadata']);
      +
      +    }
      +
      +    public function getWaveformData() : void {
      + +
    • + + +
    • + + +
            SoundMixer.computeSpectrum(this.waveformData, false, 0); // sample wave data at 44.1 KHz
      +      this.waveformDataArray = [];
      +      for (var i: int = 0, j: int = this.waveformData.length / 4; i < j; i++) { // get all 512 values (256 per channel)
      +        this.waveformDataArray.push(int(this.waveformData.readFloat() * 1000) / 1000);
      +      }
      +    }
      +
      +    public function getEQData() : void {
      + +
    • + + +
    • + + +
            SoundMixer.computeSpectrum(this.eqData, true, 0); // sample EQ data at 44.1 KHz
      +      this.eqDataArray = [];
      +      for (var i: int = 0, j: int = this.eqData.length / 4; i < j; i++) { // get all 512 values (256 per channel)
      +        this.eqDataArray.push(int(this.eqData.readFloat() * 1000) / 1000);
      +      }
      +    }
      +
      +    public function start(nMsecOffset: int, nLoops: int, allowMultiShot:Boolean) : Boolean {
      +
      +      this.useEvents = true;
      +
      +      if (this.useNetstream) {
      +
      +        writeDebug("SMSound::start nMsecOffset "+ nMsecOffset+ ' nLoops '+nLoops + ' current bufferTime '+this.ns.bufferTime+' current bufferLength '+this.ns.bufferLength+ ' this.lastValues.position '+this.lastValues.position);
      + +
    • + + +
    • +
      + +
      + +
      +

      mark for later Netstream.Play.Stop / sound completion

      + +
      + +
              this.finished = false;
      +
      +        this.cc.onMetaData = this.onMetaData;
      + +
    • + + +
    • +
      + +
      + +
      +

      Don't seek if we don't have to because it destroys the buffer

      + +
      + +
              var set_position:Boolean = this.lastValues.position != null && this.lastValues.position != nMsecOffset;
      +
      +        if (set_position) {
      + +
    • + + +
    • +
      + +
      + +
      +

      Minimize the buffer so playback starts ASAP

      + +
      + +
                this.ns.bufferTime = this.bufferTime;
      +        }
      +
      +        if (this.paused) {
      +          writeDebug('start: resuming from paused state');
      +          this.ns.resume(); // get the sound going again
      +          if (!this.didLoad) {
      +            this.didLoad = true;
      +          }
      +          this.paused = false;
      +        } else if (!this.didLoad) {
      +          writeDebug('start: !didLoad - playing '+this.sURL);
      +          this.ns.play(this.sURL);
      +          this.pauseOnBufferFull = false; // SAS: playing behaviour overrides buffering behaviour
      +          this.didLoad = true;
      +          this.paused = false;
      +        } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      previously loaded, perhaps stopped/finished. play again?

      + +
      + +
                writeDebug('playing again (not paused, didLoad = true)');
      +          this.pauseOnBufferFull = false;
      +          this.ns.play(this.sURL);
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      KJV seek after calling play otherwise some streams get a NetStream.Seek.Failed +Should only apply to the !didLoad case, but do it for all for simplicity. +nMsecOffset is in milliseconds for streams but in seconds for progressive +download.

      + +
      + +
              if (set_position) {
      +          this.ns.seek(this.serverUrl ? nMsecOffset / 1000 : nMsecOffset);
      +          this.lastValues.position = nMsecOffset; // https://gist.github.com/1de8a3113cf33d0cff67
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      this.ns.addEventListener(Event.SOUND_COMPLETE, _onfinish);

      + +
      + +
              this.applyTransform();
      +
      +      } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('start: seeking to '+nMsecOffset+', '+nLoops+(nLoops==1?' loop':' loops'));

      + +
      + +
              if (!this.soundChannel || allowMultiShot) {
      +          this.soundChannel = this.play(nMsecOffset, nLoops);
      +          this.addEventListener(Event.SOUND_COMPLETE, _onfinish);
      +          this.applyTransform();
      +        } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('start: was already playing, no-multishot case. Seeking to '+nMsecOffset+', '+nLoops+(nLoops==1?' loop':' loops')); +already playing and no multi-shot allowed, so re-start and set position

      + +
      + +
                if (this.soundChannel) {
      +            this.soundChannel.stop();
      +          }
      +          this.soundChannel = this.play(nMsecOffset, nLoops); // start playing at new position
      +          this.addEventListener(Event.SOUND_COMPLETE, _onfinish);
      +          this.applyTransform();
      +        }
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      if soundChannel is null (and not a netStream), there is no sound card (or 32-channel ceiling has been hit.) +http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html#play%28%29

      + +
      + +
            return (!this.useNetstream && this.soundChannel === null ? false : true);
      +
      +    }
      +
      +    private function _onfinish() : void {
      +      this.removeEventListener(Event.SOUND_COMPLETE, _onfinish);
      +    }
      +
      +    public function loadSound(sURL: String) : void {
      +      if (this.useNetstream) {
      +        this.useEvents = true;
      +        if (this.didLoad != true) {
      +          this.ns.play(this.sURL); // load streams by playing them
      +          if (!this.autoPlay) {
      +            this.pauseOnBufferFull = true;
      +          }
      +          this.paused = false;
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      this.addEventListener(Event.SOUND_COMPLETE, _onfinish);

      + +
      + +
              this.applyTransform();
      +      } else {
      +        try {
      +          this.didLoad = true;
      +          this.urlRequest = new URLRequest(sURL);
      +          this.soundLoaderContext = new SoundLoaderContext(1000, this.checkPolicyFile); // check for policy (crossdomain.xml) file on remote domains - http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/SoundLoaderContext.html
      +          this.load(this.urlRequest, this.soundLoaderContext);
      +        } catch(e: Error) {
      +          writeDebug('error during loadSound(): ' + e.toString());
      +        }
      +      }
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      Set the value of autoPlay

      + +
      + +
          public function setAutoPlay(autoPlay: Boolean) : void {
      +      if (!this.serverUrl) {
      +        this.autoPlay = autoPlay;
      +      } else {
      +        this.autoPlay = autoPlay;
      +        if (this.autoPlay) {
      +          this.pauseOnBufferFull = false;
      +        } else if (!this.autoPlay) {
      +          this.pauseOnBufferFull = true;
      +        }
      +      }
      +    }
      +
      +    public function setVolume(nVolume: Number) : void {
      +      this.lastValues.volume = nVolume / 100;
      +      this.applyTransform();
      +    }
      +
      +    public function setPan(nPan: Number) : void {
      +      this.lastValues.pan = nPan / 100;
      +      this.applyTransform();
      +    }
      +
      +    public function applyTransform() : void {
      +      var st: SoundTransform = new SoundTransform(this.lastValues.volume, this.lastValues.pan);
      +      if (this.useNetstream) {
      +        if (this.ns) {
      +          this.ns.soundTransform = st;
      +        } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('applyTransform(): Note: No active netStream');

      + +
      + +
              }
      +      } else if (this.soundChannel) {
      +        this.soundChannel.soundTransform = st; // new SoundTransform(this.lastValues.volume, this.lastValues.pan);
      +      }
      +    }
      + +
    • + + +
    • + + +
          public function onBWDone() : void {
      + +
    • + + +
    • +
      + +
      + +
      +

      writeDebug('onBWDone: called and ignored');

      + +
      + +
          }
      + +
    • + + +
    • +
      + +
      + +
      +

      NetStream client callback. Invoked when the song is complete.

      + +
      + +
          public function onPlayStatus(info:Object):void {
      +      writeDebug('onPlayStatus called with '+info);
      +      switch(info.code) {
      +        case "NetStream.Play.Complete":
      +          writeDebug('Song has finished!');
      +          break;
      +      }
      +    }
      +
      +    public function doIOError(e: IOErrorEvent) : void {
      +      ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onload", 0); // call onload, assume it failed.
      + +
    • + + +
    • +
      + +
      + +
      +

      there was a connection drop, a loss of internet connection, or something else wrong. 404 error too.

      + +
      + +
          }
      +
      +    public function doAsyncError(e: AsyncErrorEvent) : void {
      +      writeDebug('asyncError: ' + e.text);
      +    }
      +
      +    public function doNetStatus(e: NetStatusEvent) : void {
      + +
    • + + +
    • +
      + +
      + +
      +

      Handle failures

      + +
      + +
            if (e.info.code == "NetStream.Failed"
      +          || e.info.code == "NetStream.Play.FileStructureInvalid"
      +          || e.info.code == "NetStream.Play.StreamNotFound") {
      +
      +        this.lastNetStatus = e.info.code;
      +        writeDebug('netStatusEvent: ' + e.info.code);
      +        this.failed = true;
      +        ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfailure", '', e.info.level, e.info.code);
      +        return;
      +      }
      +
      +      writeDebug('netStatusEvent: ' + e.info.code);  // KJV we like to see all events
      + +
    • + + +
    • +
      + +
      + +
      +

      When streaming, Stop is called when buffering stops, not when the stream is actually finished. +@see http://www.actionscript.org/forums/archive/index.php3/t-159194.html

      + +
      + +
            if (e.info.code == "NetStream.Play.Stop") {
      +
      +        if (!this.finished && (!this.useNetstream || !this.serverUrl)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      finished playing, and not RTMP

      + +
      + +
                writeDebug('calling onfinish for a sound');
      + +
    • + + +
    • +
      + +
      + +
      +

      reset the sound? Move back to position 0?

      + +
      + +
                this.sm.checkProgress();
      +          this.finished = true; // will be reset via JS callback
      +          ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfinish");
      +
      +        }
      +
      +      } else if (e.info.code == "NetStream.Play.Start" || e.info.code == "NetStream.Buffer.Empty" || e.info.code == "NetStream.Buffer.Full") {
      + +
    • + + +
    • +
      + +
      + +
      +

      RTMP case.. +We wait for the buffer to fill up before pausing the just-loaded song because only if the +buffer is full will the song continue to buffer until the user hits play.

      + +
      + +
              if (this.serverUrl && e.info.code == "NetStream.Buffer.Full" && this.pauseOnBufferFull) {
      +          this.ns.pause();
      +          this.paused = true;
      +          this.pauseOnBufferFull = false;
      + +
    • + + +
    • +
      + +
      + +
      +

      Call pause in JS. This will call back to us to pause again, but +that should be harmless.

      + +
      + +
                writeDebug('Pausing on buffer full');
      +          ExternalInterface.call(baseJSObject + "['" + this.sID + "'].pause", false);
      +        }
      +
      +        var isNetstreamBuffering: Boolean = (e.info.code == "NetStream.Buffer.Empty" || e.info.code == "NetStream.Play.Start");
      + +
    • + + +
    • +
      + +
      + +
      +

      assume buffering when we start playing, eg. initial load.

      + +
      + +
              if (isNetstreamBuffering != this.lastValues.isBuffering) {
      +          this.lastValues.isBuffering = isNetstreamBuffering;
      +          ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onbufferchange", this.lastValues.isBuffering ? 1 : 0);
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      We can detect the end of the stream when Play.Stop is called followed by Buffer.Empty. +However, if you pause and let the whole song buffer, Buffer.Flush is called followed by +Buffer.Empty, so handle that case too.

      +

      Ignore this event if we are more than 3 seconds from the end of the song.

      + +
      + +
              if (e.info.code == "NetStream.Buffer.Empty" && (this.lastNetStatus == 'NetStream.Play.Stop' || this.lastNetStatus == 'NetStream.Buffer.Flush')) {
      +          if (this.duration && (this.ns.time * 1000) < (this.duration - 3000)) {
      +            writeDebug('Ignoring Buffer.Empty because this is too early to be the end of the stream! (sID: '+this.sID+', time: '+(this.ns.time*1000)+', duration: '+this.duration+')');
      +          } else if (!this.finished) {
      +            this.finished = true;
      +            writeDebug('calling onfinish for sound '+this.sID);
      +            this.sm.checkProgress();
      +            ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfinish");
      +          }
      +
      +        } else if (e.info.code == "NetStream.Buffer.Empty") {
      + +
    • + + +
    • +
      + +
      + +
      +

      The buffer is empty. Start from the smallest buffer again.

      + +
      + +
                this.ns.bufferTime = this.bufferTime;
      +        }
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      Remember the last NetStatus event

      + +
      + +
            this.lastNetStatus = e.info.code;
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      KJV The sound adds some of its own netstatus handlers so we don't need to do it here.

      + +
      + +
          public function addNetstreamEvents() : void {
      +      ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, doAsyncError);
      +      ns.addEventListener(NetStatusEvent.NET_STATUS, doNetStatus);
      +      ns.addEventListener(IOErrorEvent.IO_ERROR, doIOError);
      +    }
      +
      +    public function removeNetstreamEvents() : void {
      +      ns.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, doAsyncError);
      +      ns.removeEventListener(NetStatusEvent.NET_STATUS, doNetStatus);
      +      ns.addEventListener(NetStatusEvent.NET_STATUS, dummyNetStatusHandler);
      +      ns.removeEventListener(IOErrorEvent.IO_ERROR, doIOError);
      + +
    • + + +
    • +
      + +
      + +
      +

      KJV Stop listening for NetConnection events on the sound

      + +
      + +
            nc.removeEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      Prevents possible 'Unhandled NetStatusEvent' condition if a sound is being +destroyed and interacted with at the same time.

      + +
      + +
          public function dummyNetStatusHandler(e: NetStatusEvent) : void {
      + +
    • + + +
    • +
      + +
      + +
      +

      Don't do anything

      + +
      + +
          }
      +  }
      +}
      + +
    • + +
    +
    + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/docco.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/docco.css new file mode 100755 index 00000000..97efe8f2 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/docco.css @@ -0,0 +1,508 @@ +/*--------------------- Typography ----------------------------*/ + +@font-face { + font-family: 'aller-light'; + src: url('public/fonts/aller-light.eot'); + src: url('public/fonts/aller-light.eot?#iefix') format('embedded-opentype'), + url('public/fonts/aller-light.woff') format('woff'), + url('public/fonts/aller-light.ttf') format('truetype'); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: 'aller-bold'; + src: url('public/fonts/aller-bold.eot'); + src: url('public/fonts/aller-bold.eot?#iefix') format('embedded-opentype'), + url('public/fonts/aller-bold.woff') format('woff'), + url('public/fonts/aller-bold.ttf') format('truetype'); + font-weight: normal; + font-style: normal; +} + +@font-face { + font-family: 'novecento-bold'; + src: url('public/fonts/novecento-bold.eot'); + src: url('public/fonts/novecento-bold.eot?#iefix') format('embedded-opentype'), + url('public/fonts/novecento-bold.woff') format('woff'), + url('public/fonts/novecento-bold.ttf') format('truetype'); + font-weight: normal; + font-style: normal; +} + +/*--------------------- Layout ----------------------------*/ +html { height: 100%; } +body { + font-family: "aller-light"; + font-size: 14px; + line-height: 18px; + color: #30404f; + margin: 0; padding: 0; + height:100%; +} +#container { min-height: 100%; } + +a { + color: #000; +} + +b, strong { + font-weight: normal; + font-family: "aller-bold"; +} + +p { + margin: 15px 0 0px; +} + .annotation ul, .annotation ol { + margin: 25px 0; + } + .annotation ul li, .annotation ol li { + font-size: 14px; + line-height: 18px; + margin: 10px 0; + } + +h1, h2, h3, h4, h5, h6 { + color: #112233; + line-height: 1em; + font-weight: normal; + font-family: "novecento-bold"; + text-transform: uppercase; + margin: 30px 0 15px 0; +} + +h1 { + margin-top: 40px; +} + +hr { + border: 0; + background: 1px solid #ddd; + height: 1px; + margin: 20px 0; +} + +pre, tt, code { + font-size: 12px; line-height: 16px; + font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace; + margin: 0; padding: 0; +} + .annotation pre { + display: block; + margin: 0; + padding: 7px 10px; + background: #fcfcfc; + -moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.1); + -webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.1); + box-shadow: inset 0 0 10px rgba(0,0,0,0.1); + overflow-x: auto; + } + .annotation pre code { + border: 0; + padding: 0; + background: transparent; + } + + +blockquote { + border-left: 5px solid #ccc; + margin: 0; + padding: 1px 0 1px 1em; +} + .sections blockquote p { + font-family: Menlo, Consolas, Monaco, monospace; + font-size: 12px; line-height: 16px; + color: #999; + margin: 10px 0 0; + white-space: pre-wrap; + } + +ul.sections { + list-style: none; + padding:0 0 5px 0;; + margin:0; +} + +/* + Force border-box so that % widths fit the parent + container without overlap because of margin/padding. + + More Info : http://www.quirksmode.org/css/box.html +*/ +ul.sections > li > div { + -moz-box-sizing: border-box; /* firefox */ + -ms-box-sizing: border-box; /* ie */ + -webkit-box-sizing: border-box; /* webkit */ + -khtml-box-sizing: border-box; /* konqueror */ + box-sizing: border-box; /* css3 */ +} + + +/*---------------------- Jump Page -----------------------------*/ +#jump_to, #jump_page { + margin: 0; + background: white; + -webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777; + -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px; + font: 16px Arial; + cursor: pointer; + text-align: right; + list-style: none; +} + +#jump_to a { + text-decoration: none; +} + +#jump_to a.large { + display: none; +} +#jump_to a.small { + font-size: 22px; + font-weight: bold; + color: #676767; +} + +#jump_to, #jump_wrapper { + position: fixed; + right: 0; top: 0; + padding: 10px 15px; + margin:0; +} + +#jump_wrapper { + display: none; + padding:0; +} + +#jump_to:hover #jump_wrapper { + display: block; +} + +#jump_page { + padding: 5px 0 3px; + margin: 0 0 25px 25px; +} + +#jump_page .source { + display: block; + padding: 15px; + text-decoration: none; + border-top: 1px solid #eee; +} + +#jump_page .source:hover { + background: #F9FCFF; +} + +#jump_page .source:first-child { +} + +/*---------------------- Low resolutions (> 320px) ---------------------*/ +@media only screen and (min-width: 320px) { + .pilwrap { display: none; } + + ul.sections > li > div { + display: block; + padding:5px 10px 0 10px; + } + + ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol { + padding-left: 30px; + } + + ul.sections > li > div.content { + background: #F9FCFF; + overflow-x:auto; + -webkit-box-shadow: inset 0 0 5px #e5e5ee; + box-shadow: inset 0 0 5px #e5e5ee; + border: 1px solid #dedede; + margin:5px 10px 5px 10px; + padding-bottom: 5px; + } + + ul.sections > li > div.annotation pre { + margin: 7px 0 7px; + padding-left: 15px; + } + + ul.sections > li > div.annotation p tt, .annotation code { + background: #f8f8ff; + border: 1px solid #dedede; + font-size: 12px; + padding: 0 0.2em; + } +} + +/*---------------------- (> 481px) ---------------------*/ +@media only screen and (min-width: 481px) { + #container { + position: relative; + } + body { + background-color: #F9FCFF; + font-size: 15px; + line-height: 21px; + } + pre, tt, code { + line-height: 18px; + } + p, ul, ol { + margin: 0 0 15px; + } + + + #jump_to { + padding: 5px 10px; + } + #jump_wrapper { + padding: 0; + } + #jump_to, #jump_page { + font: 10px Arial; + text-transform: uppercase; + } + #jump_page .source { + padding: 5px 10px; + } + #jump_to a.large { + display: inline-block; + } + #jump_to a.small { + display: none; + } + + + + #background { + position: absolute; + top: 0; bottom: 0; + width: 350px; + background: #fff; + border-right: 1px solid #e5e5ee; + z-index: -1; + } + + ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol { + padding-left: 40px; + } + + ul.sections > li { + white-space: nowrap; + } + + ul.sections > li > div { + display: inline-block; + } + + ul.sections > li > div.annotation { + max-width: 350px; + min-width: 350px; + min-height: 5px; + padding: 13px; + overflow-x: hidden; + white-space: normal; + vertical-align: top; + text-align: left; + } + ul.sections > li > div.annotation pre { + margin: 15px 0 15px; + padding-left: 15px; + } + + ul.sections > li > div.content { + padding: 13px; + vertical-align: top; + background: #F9FCFF; + border: none; + -webkit-box-shadow: none; + box-shadow: none; + } + + .pilwrap { + position: relative; + display: inline; + } + + .pilcrow { + font: 12px Arial; + text-decoration: none; + color: #454545; + position: absolute; + top: 3px; left: -20px; + padding: 1px 2px; + opacity: 0; + -webkit-transition: opacity 0.2s linear; + } + .for-h1 .pilcrow { + top: 47px; + } + .for-h2 .pilcrow, .for-h3 .pilcrow, .for-h4 .pilcrow { + top: 35px; + } + + ul.sections > li > div.annotation:hover .pilcrow { + opacity: 1; + } +} + +/*---------------------- (> 1025px) ---------------------*/ +@media only screen and (min-width: 1025px) { + + body { + font-size: 16px; + line-height: 24px; + } + + #background { + width: 525px; + } + ul.sections > li > div.annotation { + max-width: 525px; + min-width: 525px; + padding: 10px 25px 1px 50px; + } + ul.sections > li > div.content { + padding: 9px 15px 16px 25px; + } +} + +/*---------------------- Syntax Highlighting -----------------------------*/ + +td.linenos { background-color: #f0f0f0; padding-right: 10px; } +span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; } +/* + +github.com style (c) Vasily Polovnyov + +*/ + +pre code { + display: block; padding: 0.5em; + color: #000; + background: #f8f8ff +} + +pre .comment, +pre .template_comment, +pre .diff .header, +pre .javadoc { + color: #408080; + font-style: italic +} + +pre .keyword, +pre .assignment, +pre .literal, +pre .css .rule .keyword, +pre .winutils, +pre .javascript .title, +pre .lisp .title, +pre .subst { + color: #954121; + /*font-weight: bold*/ +} + +pre .number, +pre .hexcolor { + color: #40a070 +} + +pre .string, +pre .tag .value, +pre .phpdoc, +pre .tex .formula { + color: #219161; +} + +pre .title, +pre .id { + color: #19469D; +} +pre .params { + color: #00F; +} + +pre .javascript .title, +pre .lisp .title, +pre .subst { + font-weight: normal +} + +pre .class .title, +pre .haskell .label, +pre .tex .command { + color: #458; + font-weight: bold +} + +pre .tag, +pre .tag .title, +pre .rules .property, +pre .django .tag .keyword { + color: #000080; + font-weight: normal +} + +pre .attribute, +pre .variable, +pre .instancevar, +pre .lisp .body { + color: #008080 +} + +pre .regexp { + color: #B68 +} + +pre .class { + color: #458; + font-weight: bold +} + +pre .symbol, +pre .ruby .symbol .string, +pre .ruby .symbol .keyword, +pre .ruby .symbol .keymethods, +pre .lisp .keyword, +pre .tex .special, +pre .input_number { + color: #990073 +} + +pre .builtin, +pre .constructor, +pre .built_in, +pre .lisp .title { + color: #0086b3 +} + +pre .preprocessor, +pre .pi, +pre .doctype, +pre .shebang, +pre .cdata { + color: #999; + font-weight: bold +} + +pre .deletion { + background: #fdd +} + +pre .addition { + background: #dfd +} + +pre .diff .change { + background: #0086b3 +} + +pre .chunk { + color: #aaa +} + +pre .tex .formula { + opacity: 0.5; +} diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-bold.eot b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-bold.eot new file mode 100755 index 00000000..1b32532a Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-bold.eot differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-bold.ttf b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-bold.ttf new file mode 100755 index 00000000..dc4cc9c2 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-bold.ttf differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-bold.woff b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-bold.woff new file mode 100755 index 00000000..fa16fd0a Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-bold.woff differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-light.eot b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-light.eot new file mode 100755 index 00000000..40bd654b Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-light.eot differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-light.ttf b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-light.ttf new file mode 100755 index 00000000..c2c72902 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-light.ttf differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-light.woff b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-light.woff new file mode 100755 index 00000000..81a09d18 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/aller-light.woff differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/novecento-bold.eot b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/novecento-bold.eot new file mode 100755 index 00000000..98a9a7fb Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/novecento-bold.eot differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/novecento-bold.ttf b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/novecento-bold.ttf new file mode 100755 index 00000000..2af39b08 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/novecento-bold.ttf differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/novecento-bold.woff b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/novecento-bold.woff new file mode 100755 index 00000000..de558b5a Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/fonts/novecento-bold.woff differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/stylesheets/normalize.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/stylesheets/normalize.css new file mode 100755 index 00000000..73abb76f --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/public/stylesheets/normalize.css @@ -0,0 +1,375 @@ +/*! normalize.css v2.0.1 | MIT License | git.io/normalize */ + +/* ========================================================================== + HTML5 display definitions + ========================================================================== */ + +/* + * Corrects `block` display not defined in IE 8/9. + */ + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +nav, +section, +summary { + display: block; +} + +/* + * Corrects `inline-block` display not defined in IE 8/9. + */ + +audio, +canvas, +video { + display: inline-block; +} + +/* + * Prevents modern browsers from displaying `audio` without controls. + * Remove excess height in iOS 5 devices. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/* + * Addresses styling for `hidden` attribute not present in IE 8/9. + */ + +[hidden] { + display: none; +} + +/* ========================================================================== + Base + ========================================================================== */ + +/* + * 1. Sets default font family to sans-serif. + * 2. Prevents iOS text size adjust after orientation change, without disabling + * user zoom. + */ + +html { + font-family: sans-serif; /* 1 */ + -webkit-text-size-adjust: 100%; /* 2 */ + -ms-text-size-adjust: 100%; /* 2 */ +} + +/* + * Removes default margin. + */ + +body { + margin: 0; +} + +/* ========================================================================== + Links + ========================================================================== */ + +/* + * Addresses `outline` inconsistency between Chrome and other browsers. + */ + +a:focus { + outline: thin dotted; +} + +/* + * Improves readability when focused and also mouse hovered in all browsers. + */ + +a:active, +a:hover { + outline: 0; +} + +/* ========================================================================== + Typography + ========================================================================== */ + +/* + * Addresses `h1` font sizes within `section` and `article` in Firefox 4+, + * Safari 5, and Chrome. + */ + +h1 { + font-size: 2em; +} + +/* + * Addresses styling not present in IE 8/9, Safari 5, and Chrome. + */ + +abbr[title] { + border-bottom: 1px dotted; +} + +/* + * Addresses style set to `bolder` in Firefox 4+, Safari 5, and Chrome. + */ + +b, +strong { + font-weight: bold; +} + +/* + * Addresses styling not present in Safari 5 and Chrome. + */ + +dfn { + font-style: italic; +} + +/* + * Addresses styling not present in IE 8/9. + */ + +mark { + background: #ff0; + color: #000; +} + + +/* + * Corrects font family set oddly in Safari 5 and Chrome. + */ + +code, +kbd, +pre, +samp { + font-family: monospace, serif; + font-size: 1em; +} + +/* + * Improves readability of pre-formatted text in all browsers. + */ + +pre { + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; +} + +/* + * Sets consistent quote types. + */ + +q { + quotes: "\201C" "\201D" "\2018" "\2019"; +} + +/* + * Addresses inconsistent and variable font size in all browsers. + */ + +small { + font-size: 80%; +} + +/* + * Prevents `sub` and `sup` affecting `line-height` in all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* ========================================================================== + Embedded content + ========================================================================== */ + +/* + * Removes border when inside `a` element in IE 8/9. + */ + +img { + border: 0; +} + +/* + * Corrects overflow displayed oddly in IE 9. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* ========================================================================== + Figures + ========================================================================== */ + +/* + * Addresses margin not present in IE 8/9 and Safari 5. + */ + +figure { + margin: 0; +} + +/* ========================================================================== + Forms + ========================================================================== */ + +/* + * Define consistent border, margin, and padding. + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/* + * 1. Corrects color not being inherited in IE 8/9. + * 2. Remove padding so people aren't caught out if they zero out fieldsets. + */ + +legend { + border: 0; /* 1 */ + padding: 0; /* 2 */ +} + +/* + * 1. Corrects font family not being inherited in all browsers. + * 2. Corrects font size not being inherited in all browsers. + * 3. Addresses margins set differently in Firefox 4+, Safari 5, and Chrome + */ + +button, +input, +select, +textarea { + font-family: inherit; /* 1 */ + font-size: 100%; /* 2 */ + margin: 0; /* 3 */ +} + +/* + * Addresses Firefox 4+ setting `line-height` on `input` using `!important` in + * the UA stylesheet. + */ + +button, +input { + line-height: normal; +} + +/* + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Corrects inability to style clickable `input` types in iOS. + * 3. Improves usability and consistency of cursor style between image-type + * `input` and others. + */ + +button, +html input[type="button"], /* 1 */ +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; /* 2 */ + cursor: pointer; /* 3 */ +} + +/* + * Re-set default cursor for disabled elements. + */ + +button[disabled], +input[disabled] { + cursor: default; +} + +/* + * 1. Addresses box sizing set to `content-box` in IE 8/9. + * 2. Removes excess padding in IE 8/9. + */ + +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/* + * 1. Addresses `appearance` set to `searchfield` in Safari 5 and Chrome. + * 2. Addresses `box-sizing` set to `border-box` in Safari 5 and Chrome + * (include `-moz` to future-proof). + */ + +input[type="search"] { + -webkit-appearance: textfield; /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; /* 2 */ + box-sizing: content-box; +} + +/* + * Removes inner padding and search cancel button in Safari 5 and Chrome + * on OS X. + */ + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/* + * Removes inner padding and border in Firefox 4+. + */ + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/* + * 1. Removes default vertical scrollbar in IE 8/9. + * 2. Improves readability and alignment in all browsers. + */ + +textarea { + overflow: auto; /* 1 */ + vertical-align: top; /* 2 */ +} + +/* ========================================================================== + Tables + ========================================================================== */ + +/* + * Remove most spacing between table cells. + */ + +table { + border-collapse: collapse; + border-spacing: 0; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/soundmanager2.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/soundmanager2.html new file mode 100755 index 00000000..12064399 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/generated/soundmanager2.html @@ -0,0 +1,11613 @@ + + + + + soundmanager2.js + + + + + + +
    +
    + + + +
      + +
    • +
      +

      soundmanager2.js

      +
      +
    • + + + +
    • +
      + +
      + +
      + +
      + +
      /** @license
      + *
      + * SoundManager 2: JavaScript Sound for the Web
      + * ----------------------------------------------
      + * http://schillmania.com/projects/soundmanager2/
      + *
      + * Copyright (c) 2007, Scott Schiller. All rights reserved.
      + * Code provided under the BSD License:
      + * http://schillmania.com/projects/soundmanager2/license.txt
      + *
      + * V2.97a.20131201
      + */
      +
      +/*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio, opera */
      +/*jslint regexp: true, sloppy: true, white: true, nomen: true, plusplus: true, todo: true */
      +
      +/**
      + * About this file
      + * -------------------------------------------------------------------------------------
      + * This is the fully-commented source version of the SoundManager 2 API,
      + * recommended for use during development and testing.
      + *
      + * See soundmanager2-nodebug-jsmin.js for an optimized build (~11KB with gzip.)
      + * http://schillmania.com/projects/soundmanager2/doc/getstarted/#basic-inclusion
      + * Alternately, serve this file with gzip for 75% compression savings (~30KB over HTTP.)
      + *
      + * You may notice <d> and </d> comments in this source; these are delimiters for
      + * debug blocks which are removed in the -nodebug builds, further optimizing code size.
      + *
      + * Also, as you may note: Whoa, reliable cross-platform/device audio support is hard! ;)
      + */
      +
      +(function(window, _undefined) {
      +
      +"use strict";
      +
      +var soundManager = null;
      +
      +/**
      + * The SoundManager constructor.
      + *
      + * @constructor
      + * @param {string} smURL Optional: Path to SWF files
      + * @param {string} smID Optional: The ID to use for the SWF container element
      + * @this {SoundManager}
      + * @return {SoundManager} The new SoundManager instance
      + */
      +
      +function SoundManager(smURL, smID) {
      +
      +  /**
      +   * soundManager configuration options list
      +   * defines top-level configuration properties to be applied to the soundManager instance (eg. soundManager.flashVersion)
      +   * to set these properties, use the setup() method - eg., soundManager.setup({url: '/swf/', flashVersion: 9})
      +   */
      +
      +  this.setupOptions = {
      +
      +    'url': (smURL || null),             // path (directory) where SoundManager 2 SWFs exist, eg., /path/to/swfs/
      +    'flashVersion': 8,                  // flash build to use (8 or 9.) Some API features require 9.
      +    'debugMode': true,                  // enable debugging output (console.log() with HTML fallback)
      +    'debugFlash': false,                // enable debugging output inside SWF, troubleshoot Flash/browser issues
      +    'useConsole': true,                 // use console.log() if available (otherwise, writes to #soundmanager-debug element)
      +    'consoleOnly': true,                // if console is being used, do not create/write to #soundmanager-debug
      +    'waitForWindowLoad': false,         // force SM2 to wait for window.onload() before trying to call soundManager.onload()
      +    'bgColor': '#ffffff',               // SWF background color. N/A when wmode = 'transparent'
      +    'useHighPerformance': false,        // position:fixed flash movie can help increase js/flash speed, minimize lag
      +    'flashPollingInterval': null,       // msec affecting whileplaying/loading callback frequency. If null, default of 50 msec is used.
      +    'html5PollingInterval': null,       // msec affecting whileplaying() for HTML5 audio, excluding mobile devices. If null, native HTML5 update events are used.
      +    'flashLoadTimeout': 1000,           // msec to wait for flash movie to load before failing (0 = infinity)
      +    'wmode': null,                      // flash rendering mode - null, 'transparent', or 'opaque' (last two allow z-index to work)
      +    'allowScriptAccess': 'always',      // for scripting the SWF (object/embed property), 'always' or 'sameDomain'
      +    'useFlashBlock': false,             // *requires flashblock.css, see demos* - allow recovery from flash blockers. Wait indefinitely and apply timeout CSS to SWF, if applicable.
      +    'useHTML5Audio': true,              // use HTML5 Audio() where API is supported (most Safari, Chrome versions), Firefox (no MP3/MP4.) Ideally, transparent vs. Flash API where possible.
      +    'html5Test': /^(probably|maybe)$/i, // HTML5 Audio() format support test. Use /^probably$/i; if you want to be more conservative.
      +    'preferFlash': false,               // overrides useHTML5audio, will use Flash for MP3/MP4/AAC if present. Potential option if HTML5 playback with these formats is quirky.
      +    'noSWFCache': false,                // if true, appends ?ts={date} to break aggressive SWF caching.
      +    'idPrefix': 'sound'                 // if an id is not provided to createSound(), this prefix is used for generated IDs - 'sound0', 'sound1' etc.
      +
      +  };
      +
      +  this.defaultOptions = {
      +
      +    /**
      +     * the default configuration for sound objects made with createSound() and related methods
      +     * eg., volume, auto-load behaviour and so forth
      +     */
      +
      +    'autoLoad': false,        // enable automatic loading (otherwise .load() will be called on demand with .play(), the latter being nicer on bandwidth - if you want to .load yourself, you also can)
      +    'autoPlay': false,        // enable playing of file as soon as possible (much faster if "stream" is true)
      +    'from': null,             // position to start playback within a sound (msec), default = beginning
      +    'loops': 1,               // how many times to repeat the sound (position will wrap around to 0, setPosition() will break out of loop when >0)
      +    'onid3': null,            // callback function for "ID3 data is added/available"
      +    'onload': null,           // callback function for "load finished"
      +    'whileloading': null,     // callback function for "download progress update" (X of Y bytes received)
      +    'onplay': null,           // callback for "play" start
      +    'onpause': null,          // callback for "pause"
      +    'onresume': null,         // callback for "resume" (pause toggle)
      +    'whileplaying': null,     // callback during play (position update)
      +    'onposition': null,       // object containing times and function callbacks for positions of interest
      +    'onstop': null,           // callback for "user stop"
      +    'onfailure': null,        // callback function for when playing fails
      +    'onfinish': null,         // callback function for "sound finished playing"
      +    'multiShot': true,        // let sounds "restart" or layer on top of each other when played multiple times, rather than one-shot/one at a time
      +    'multiShotEvents': false, // fire multiple sound events (currently onfinish() only) when multiShot is enabled
      +    'position': null,         // offset (milliseconds) to seek to within loaded sound data.
      +    'pan': 0,                 // "pan" settings, left-to-right, -100 to 100
      +    'stream': true,           // allows playing before entire file has loaded (recommended)
      +    'to': null,               // position to end playback within a sound (msec), default = end
      +    'type': null,             // MIME-like hint for file pattern / canPlay() tests, eg. audio/mp3
      +    'usePolicyFile': false,   // enable crossdomain.xml request for audio on remote domains (for ID3/waveform access)
      +    'volume': 100             // self-explanatory. 0-100, the latter being the max.
      +
      +  };
      +
      +  this.flash9Options = {
      +
      +    /**
      +     * flash 9-only options,
      +     * merged into defaultOptions if flash 9 is being used
      +     */
      +
      +    'isMovieStar': null,      // "MovieStar" MPEG4 audio mode. Null (default) = auto detect MP4, AAC etc. based on URL. true = force on, ignore URL
      +    'usePeakData': false,     // enable left/right channel peak (level) data
      +    'useWaveformData': false, // enable sound spectrum (raw waveform data) - NOTE: May increase CPU load.
      +    'useEQData': false,       // enable sound EQ (frequency spectrum data) - NOTE: May increase CPU load.
      +    'onbufferchange': null,   // callback for "isBuffering" property change
      +    'ondataerror': null       // callback for waveform/eq data access error (flash playing audio in other tabs/domains)
      +
      +  };
      +
      +  this.movieStarOptions = {
      +
      +    /**
      +     * flash 9.0r115+ MPEG4 audio options,
      +     * merged into defaultOptions if flash 9+movieStar mode is enabled
      +     */
      +
      +    'bufferTime': 3,          // seconds of data to buffer before playback begins (null = flash default of 0.1 seconds - if AAC playback is gappy, try increasing.)
      +    'serverURL': null,        // rtmp: FMS or FMIS server to connect to, required when requesting media via RTMP or one of its variants
      +    'onconnect': null,        // rtmp: callback for connection to flash media server
      +    'duration': null          // rtmp: song duration (msec)
      +
      +  };
      +
      +  this.audioFormats = {
      +
      +    /**
      +     * determines HTML5 support + flash requirements.
      +     * if no support (via flash and/or HTML5) for a "required" format, SM2 will fail to start.
      +     * flash fallback is used for MP3 or MP4 if HTML5 can't play it (or if preferFlash = true)
      +     */
      +
      +    'mp3': {
      +      'type': ['audio/mpeg; codecs="mp3"', 'audio/mpeg', 'audio/mp3', 'audio/MPA', 'audio/mpa-robust'],
      +      'required': true
      +    },
      +
      +    'mp4': {
      +      'related': ['aac','m4a','m4b'], // additional formats under the MP4 container
      +      'type': ['audio/mp4; codecs="mp4a.40.2"', 'audio/aac', 'audio/x-m4a', 'audio/MP4A-LATM', 'audio/mpeg4-generic'],
      +      'required': false
      +    },
      +
      +    'ogg': {
      +      'type': ['audio/ogg; codecs=vorbis'],
      +      'required': false
      +    },
      +
      +    'opus': {
      +      'type': ['audio/ogg; codecs=opus', 'audio/opus'],
      +      'required': false
      +    },
      +
      +    'wav': {
      +      'type': ['audio/wav; codecs="1"', 'audio/wav', 'audio/wave', 'audio/x-wav'],
      +      'required': false
      +    }
      +
      +  };
      + +
    • + + +
    • +
      + +
      + +
      +

      HTML attributes (id + class names) for the SWF container

      + +
      + +
      +  this.movieID = 'sm2-container';
      +  this.id = (smID || 'sm2movie');
      +
      +  this.debugID = 'soundmanager-debug';
      +  this.debugURLParam = /([#?&])debug=1/i;
      + +
    • + + +
    • +
      + +
      + +
      +

      dynamic attributes

      + +
      + +
      +  this.versionNumber = 'V2.97a.20131201';
      +  this.version = null;
      +  this.movieURL = null;
      +  this.altURL = null;
      +  this.swfLoaded = false;
      +  this.enabled = false;
      +  this.oMC = null;
      +  this.sounds = {};
      +  this.soundIDs = [];
      +  this.muted = false;
      +  this.didFlashBlock = false;
      +  this.filePattern = null;
      +
      +  this.filePatterns = {
      +
      +    'flash8': /\.mp3(\?.*)?$/i,
      +    'flash9': /\.mp3(\?.*)?$/i
      +
      +  };
      + +
    • + + +
    • +
      + +
      + +
      +

      support indicators, set at init

      + +
      + +
      +  this.features = {
      +
      +    'buffering': false,
      +    'peakData': false,
      +    'waveformData': false,
      +    'eqData': false,
      +    'movieStar': false
      +
      +  };
      + +
    • + + +
    • +
      + +
      + +
      +

      flash sandbox info, used primarily in troubleshooting

      + +
      + +
      +  this.sandbox = {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
          'type': null,
      +    'types': {
      +      'remote': 'remote (domain-based) rules',
      +      'localWithFile': 'local with file access (no internet access)',
      +      'localWithNetwork': 'local with network (internet access only, no local access)',
      +      'localTrusted': 'local, trusted (local+internet access)'
      +    },
      +    'description': null,
      +    'noRemote': null,
      +    'noLocal': null
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +  };
      +
      +  /**
      +   * format support (html5/flash)
      +   * stores canPlayType() results based on audioFormats.
      +   * eg. { mp3: boolean, mp4: boolean }
      +   * treat as read-only.
      +   */
      +
      +  this.html5 = {
      +    'usingFlash': null // set if/when flash fallback is needed
      +  };
      + +
    • + + +
    • +
      + +
      + +
      +

      file type support hash

      + +
      + +
        this.flash = {};
      + +
    • + + +
    • +
      + +
      + +
      +

      determined at init time

      + +
      + +
        this.html5Only = false;
      + +
    • + + +
    • +
      + +
      + +
      +

      used for special cases (eg. iPad/iPhone/palm OS?)

      + +
      + +
        this.ignoreFlash = false;
      +
      +  /**
      +   * a few private internals (OK, a lot. :D)
      +   */
      +
      +  var SMSound,
      +  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, preInit, domContentLoaded, winOnLoad, didDCLoaded, getDocument, createMovie, catchError, setPolling, initDebug, debugLevels = ['log', 'info', 'warn', 'error'], defaultFlashVersion = 8, disableObject, failSafely, normalizeMovieURL, oRemoved = null, oRemovedHTML = null, str, flashBlockHandler, getSWFCSS, swfCSS, toggleDebug, loopFix, policyFix, complain, idCheck, waitingForEI = false, initPending = false, startTimer, stopTimer, timerExecute, h5TimerCount = 0, h5IntervalTimer = null, parseURL, messages = [],
      +  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,
      +  is_iDevice = ua.match(/(ipad|iphone|ipod)/i), isAndroid = ua.match(/android/i), isIE = ua.match(/msie/i), isWebkit = ua.match(/webkit/i), isSafari = (ua.match(/safari/i) && !ua.match(/chrome/i)), isOpera = (ua.match(/opera/i)),
      +  mobileHTML5 = (ua.match(/(mobile|pre\/|xoom)/i) || is_iDevice || isAndroid),
      +  isBadSafari = (!wl.match(/usehtml5audio/i) && !wl.match(/sm2\-ignorebadua/i) && isSafari && !ua.match(/silk/i) && ua.match(/OS X 10_6_([3-7])/i)), // Safari 4 and 5 (excluding Kindle Fire, "Silk") occasionally fail to load/play HTML5 audio on Snow Leopard 10.6.3 through 10.6.7 due to bug(s) in QuickTime X and/or other underlying frameworks. :/ Confirmed bug. https://bugs.webkit.org/show_bug.cgi?id=32159
      +  hasConsole = (window.console !== _undefined && console.log !== _undefined), isFocused = (doc.hasFocus !== _undefined?doc.hasFocus():null), tryInitOnFocus = (isSafari && (doc.hasFocus === _undefined || !doc.hasFocus())), okToDisable = !tryInitOnFocus, flashMIME = /(mp3|mp4|mpa|m4a|m4b)/i, msecScale = 1000,
      +  emptyURL = 'about:blank', // safe URL to unload, or load nothing from (flash 8 + most HTML5 UAs)
      +  emptyWAV = 'data:audio/wave;base64,/UklGRiYAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQIAAAD//w==', // tiny WAV for HTML5 unloading
      +  overHTTP = (doc.location?doc.location.protocol.match(/http/i):null),
      +  http = (!overHTTP ? 'http:/'+'/' : ''),
      + +
    • + + +
    • +
      + +
      + +
      +

      mp3, mp4, aac etc.

      + +
      + +
        netStreamMimeTypes = /^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i,
      + +
    • + + +
    • +
      + +
      + +
      +

      Flash v9.0r115+ "moviestar" formats

      + +
      + +
        netStreamTypes = ['mpeg4', 'aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', 'm4b', 'mp4v', '3gp', '3g2'],
      +  netStreamPattern = new RegExp('\\.(' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i');
      +
      +  this.mimePattern = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i; // default mp3 set
      + +
    • + + +
    • +
      + +
      + +
      +

      use altURL if not "online"

      + +
      + +
        this.useAltURL = !overHTTP;
      +
      +  swfCSS = {
      +
      +    'swfBox': 'sm2-object-box',
      +    'swfDefault': 'movieContainer',
      +    'swfError': 'swf_error', // SWF loaded, but SM2 couldn't start (other error)
      +    'swfTimedout': 'swf_timedout',
      +    'swfLoaded': 'swf_loaded',
      +    'swfUnblocked': 'swf_unblocked', // or loaded OK
      +    'sm2Debug': 'sm2_debug',
      +    'highPerf': 'high_performance',
      +    'flashDebug': 'flash_debug'
      +
      +  };
      +
      +  /**
      +   * basic HTML5 Audio() support test
      +   * try...catch because of IE 9 "not implemented" nonsense
      +   * https://github.com/Modernizr/Modernizr/issues/224
      +   */
      +
      +  this.hasHTML5 = (function() {
      +    try {
      + +
    • + + +
    • +
      + +
      + +
      +

      new Audio(null) for stupid Opera 9.64 case, which throws not_enough_arguments exception otherwise.

      + +
      + +
            return (Audio !== _undefined && (isOpera && opera !== _undefined && opera.version() < 10 ? new Audio(null) : new Audio()).canPlayType !== _undefined);
      +    } catch(e) {
      +      return false;
      +    }
      +  }());
      +
      +  /**
      +   * Public SoundManager API
      +   * -----------------------
      +   */
      +
      +  /**
      +   * Configures top-level soundManager properties.
      +   *
      +   * @param {object} options Option parameters, eg. { flashVersion: 9, url: '/path/to/swfs/' }
      +   * onready and ontimeout are also accepted parameters. call soundManager.setup() to see the full list.
      +   */
      +
      +  this.setup = function(options) {
      +
      +    var noURL = (!sm2.url);
      + +
    • + + +
    • +
      + +
      + +
      +

      warn if flash options have already been applied

      + +
      + +
      +    if (options !== _undefined && didInit && needsFlash && sm2.ok() && (options.flashVersion !== _undefined || options.url !== _undefined || options.html5Test !== _undefined)) {
      +      complain(str('setupLate'));
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      TODO: defer: true?

      + +
      + +
      +    assign(options);
      + +
    • + + +
    • +
      + +
      + +
      +

      special case 1: "Late setup". SM2 loaded normally, but user didn't assign flash URL eg., setup({url:...}) before SM2 init. Treat as delayed init.

      + +
      + +
      +    if (options) {
      +
      +      if (noURL && didDCLoaded && options.url !== _undefined) {
      +        sm2.beginDelayedInit();
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      special case 2: If lazy-loading SM2 (DOMContentLoaded has already happened) and user calls setup() with url: parameter, try to init ASAP.

      + +
      + +
      +      if (!didDCLoaded && options.url !== _undefined && doc.readyState === 'complete') {
      +        setTimeout(domContentLoaded, 1);
      +      }
      +
      +    }
      +
      +    return sm2;
      +
      +  };
      +
      +  this.ok = function() {
      +
      +    return (needsFlash ? (didInit && !disabled) : (sm2.useHTML5Audio && sm2.hasHTML5));
      +
      +  };
      +
      +  this.supported = this.ok; // legacy
      +
      +  this.getMovie = function(smID) {
      + +
    • + + +
    • +
      + +
      + +
      +

      safety net: some old browsers differ on SWF references, possibly related to ExternalInterface / flash version

      + +
      + +
          return id(smID) || doc[smID] || window[smID];
      +
      +  };
      +
      +  /**
      +   * Creates a SMSound sound object instance.
      +   *
      +   * @param {object} oOptions Sound options (at minimum, id and url parameters are required.)
      +   * @return {object} SMSound The new SMSound object.
      +   */
      +
      +  this.createSound = function(oOptions, _url) {
      +
      +    var cs, cs_string, options, oSound = null;
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
          cs = sm + '.createSound(): ';
      +    cs_string = cs + str(!didInit?'notReady':'notOK');
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +    if (!didInit || !sm2.ok()) {
      +      complain(cs_string);
      +      return false;
      +    }
      +
      +    if (_url !== _undefined) {
      + +
    • + + +
    • +
      + +
      + +
      +

      function overloading in JS! :) ..assume simple createSound(id, url) use case

      + +
      + +
            oOptions = {
      +        'id': oOptions,
      +        'url': _url
      +      };
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      inherit from defaultOptions

      + +
      + +
          options = mixin(oOptions);
      +
      +    options.url = parseURL(options.url);
      + +
    • + + +
    • +
      + +
      + +
      +

      generate an id, if needed.

      + +
      + +
          if (options.id === undefined) {
      +      options.id = sm2.setupOptions.idPrefix + (idCounter++);
      +    }
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
          if (options.id.toString().charAt(0).match(/^[0-9]$/)) {
      +      sm2._wD(cs + str('badID', options.id), 2);
      +    }
      +
      +    sm2._wD(cs + options.id + (options.url ? ' (' + options.url + ')' : ''), 1);
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +    if (idCheck(options.id, true)) {
      +      sm2._wD(cs + options.id + ' exists', 1);
      +      return sm2.sounds[options.id];
      +    }
      +
      +    function make() {
      +
      +      options = loopFix(options);
      +      sm2.sounds[options.id] = new SMSound(options);
      +      sm2.soundIDs.push(options.id);
      +      return sm2.sounds[options.id];
      +
      +    }
      +
      +    if (html5OK(options)) {
      +
      +      oSound = make();
      +      sm2._wD(options.id + ': Using HTML5');
      +      oSound._setup_html5(options);
      +
      +    } else {
      +
      +      if (sm2.html5Only) {
      +        sm2._wD(options.id + ': No HTML5 support for this sound, and no Flash. Exiting.');
      +        return make();
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      TODO: Move HTML5/flash checks into generic URL parsing/handling function.

      + +
      + +
      +      if (sm2.html5.usingFlash && options.url && options.url.match(/data\:/i)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      data: URIs not supported by Flash, either.

      + +
      + +
              sm2._wD(options.id + ': data: URIs not supported via Flash. Exiting.');
      +        return make();
      +      }
      +
      +      if (fV > 8) {
      +        if (options.isMovieStar === null) {
      + +
    • + + +
    • +
      + +
      + +
      +

      attempt to detect MPEG-4 formats

      + +
      + +
                options.isMovieStar = !!(options.serverURL || (options.type ? options.type.match(netStreamMimeTypes) : false) || (options.url && options.url.match(netStreamPattern)));
      +        }
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
              if (options.isMovieStar) {
      +          sm2._wD(cs + 'using MovieStar handling');
      +          if (options.loops > 1) {
      +            _wDS('noNSLoop');
      +          }
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
            }
      +
      +      options = policyFix(options, cs);
      +      oSound = make();
      +
      +      if (fV === 8) {
      +        flash._createSound(options.id, options.loops||1, options.usePolicyFile);
      +      } else {
      +        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);
      +        if (!options.serverURL) {
      + +
    • + + +
    • +
      + +
      + +
      +

      We are connected immediately

      + +
      + +
                oSound.connected = true;
      +          if (options.onconnect) {
      +            options.onconnect.apply(oSound);
      +          }
      +        }
      +      }
      +
      +      if (!options.serverURL && (options.autoLoad || options.autoPlay)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      call load for non-rtmp streams

      + +
      + +
              oSound.load(options);
      +      }
      +
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      rtmp will play in onconnect

      + +
      + +
          if (!options.serverURL && options.autoPlay) {
      +      oSound.play();
      +    }
      +
      +    return oSound;
      +
      +  };
      +
      +  /**
      +   * Destroys a SMSound sound object instance.
      +   *
      +   * @param {string} sID The ID of the sound to destroy
      +   */
      +
      +  this.destroySound = function(sID, _bFromSound) {
      + +
    • + + +
    • +
      + +
      + +
      +

      explicitly destroy a sound before normal page unload, etc.

      + +
      + +
      +    if (!idCheck(sID)) {
      +      return false;
      +    }
      +
      +    var oS = sm2.sounds[sID], i;
      + +
    • + + +
    • +
      + +
      + +
      +

      Disable all callbacks while the sound is being destroyed

      + +
      + +
          oS._iO = {};
      +
      +    oS.stop();
      +    oS.unload();
      +
      +    for (i = 0; i < sm2.soundIDs.length; i++) {
      +      if (sm2.soundIDs[i] === sID) {
      +        sm2.soundIDs.splice(i, 1);
      +        break;
      +      }
      +    }
      +
      +    if (!_bFromSound) {
      + +
    • + + +
    • +
      + +
      + +
      +

      ignore if being called from SMSound instance

      + +
      + +
            oS.destruct(true);
      +    }
      +
      +    oS = null;
      +    delete sm2.sounds[sID];
      +
      +    return true;
      +
      +  };
      +
      +  /**
      +   * Calls the load() method of a SMSound object by ID.
      +   *
      +   * @param {string} sID The ID of the sound
      +   * @param {object} oOptions Optional: Sound options
      +   */
      +
      +  this.load = function(sID, oOptions) {
      +
      +    if (!idCheck(sID)) {
      +      return false;
      +    }
      +    return sm2.sounds[sID].load(oOptions);
      +
      +  };
      +
      +  /**
      +   * Calls the unload() method of a SMSound object by ID.
      +   *
      +   * @param {string} sID The ID of the sound
      +   */
      +
      +  this.unload = function(sID) {
      +
      +    if (!idCheck(sID)) {
      +      return false;
      +    }
      +    return sm2.sounds[sID].unload();
      +
      +  };
      +
      +  /**
      +   * Calls the onPosition() method of a SMSound object by ID.
      +   *
      +   * @param {string} sID The ID of the sound
      +   * @param {number} nPosition The position to watch for
      +   * @param {function} oMethod The relevant callback to fire
      +   * @param {object} oScope Optional: The scope to apply the callback to
      +   * @return {SMSound} The SMSound object
      +   */
      +
      +  this.onPosition = function(sID, nPosition, oMethod, oScope) {
      +
      +    if (!idCheck(sID)) {
      +      return false;
      +    }
      +    return sm2.sounds[sID].onposition(nPosition, oMethod, oScope);
      +
      +  };
      + +
    • + + +
    • +
      + +
      + +
      +

      legacy/backwards-compability: lower-case method name

      + +
      + +
        this.onposition = this.onPosition;
      +
      +  /**
      +   * Calls the clearOnPosition() method of a SMSound object by ID.
      +   *
      +   * @param {string} sID The ID of the sound
      +   * @param {number} nPosition The position to watch for
      +   * @param {function} oMethod Optional: The relevant callback to fire
      +   * @return {SMSound} The SMSound object
      +   */
      +
      +  this.clearOnPosition = function(sID, nPosition, oMethod) {
      +
      +    if (!idCheck(sID)) {
      +      return false;
      +    }
      +    return sm2.sounds[sID].clearOnPosition(nPosition, oMethod);
      +
      +  };
      +
      +  /**
      +   * Calls the play() method of a SMSound object by ID.
      +   *
      +   * @param {string} sID The ID of the sound
      +   * @param {object} oOptions Optional: Sound options
      +   * @return {SMSound} The SMSound object
      +   */
      +
      +  this.play = function(sID, oOptions) {
      +
      +    var result = null,
      + +
    • + + +
    • +
      + +
      + +
      +

      legacy function-overloading use case: play('mySound', '/path/to/some.mp3');

      + +
      + +
              overloaded = (oOptions && !(oOptions instanceof Object));
      +
      +    if (!didInit || !sm2.ok()) {
      +      complain(sm + '.play(): ' + str(!didInit?'notReady':'notOK'));
      +      return false;
      +    }
      +
      +    if (!idCheck(sID, overloaded)) {
      +
      +      if (!overloaded) {
      + +
    • + + +
    • +
      + +
      + +
      +

      no sound found for the given ID. Bail.

      + +
      + +
              return false;
      +      }
      +
      +      if (overloaded) {
      +        oOptions = {
      +          url: oOptions
      +        };
      +      }
      +
      +      if (oOptions && oOptions.url) {
      + +
    • + + +
    • +
      + +
      + +
      +

      overloading use case, create+play: .play('someID', {url:'/path/to.mp3'});

      + +
      + +
              sm2._wD(sm + '.play(): Attempting to create "' + sID + '"', 1);
      +        oOptions.id = sID;
      +        result = sm2.createSound(oOptions).play();
      +      }
      +
      +    } else if (overloaded) {
      + +
    • + + +
    • +
      + +
      + +
      +

      existing sound object case

      + +
      + +
            oOptions = {
      +        url: oOptions
      +      };
      +
      +    }
      +
      +    if (result === null) {
      + +
    • + + +
    • +
      + +
      + +
      +

      default case

      + +
      + +
            result = sm2.sounds[sID].play(oOptions);
      +    }
      +
      +    return result;
      +
      +  };
      +
      +  this.start = this.play; // just for convenience
      +
      +  /**
      +   * Calls the setPosition() method of a SMSound object by ID.
      +   *
      +   * @param {string} sID The ID of the sound
      +   * @param {number} nMsecOffset Position (milliseconds)
      +   * @return {SMSound} The SMSound object
      +   */
      +
      +  this.setPosition = function(sID, nMsecOffset) {
      +
      +    if (!idCheck(sID)) {
      +      return false;
      +    }
      +    return sm2.sounds[sID].setPosition(nMsecOffset);
      +
      +  };
      +
      +  /**
      +   * Calls the stop() method of a SMSound object by ID.
      +   *
      +   * @param {string} sID The ID of the sound
      +   * @return {SMSound} The SMSound object
      +   */
      +
      +  this.stop = function(sID) {
      +
      +    if (!idCheck(sID)) {
      +      return false;
      +    }
      +
      +    sm2._wD(sm + '.stop(' + sID + ')', 1);
      +    return sm2.sounds[sID].stop();
      +
      +  };
      +
      +  /**
      +   * Stops all currently-playing sounds.
      +   */
      +
      +  this.stopAll = function() {
      +
      +    var oSound;
      +    sm2._wD(sm + '.stopAll()', 1);
      +
      +    for (oSound in sm2.sounds) {
      +      if (sm2.sounds.hasOwnProperty(oSound)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      apply only to sound objects

      + +
      + +
              sm2.sounds[oSound].stop();
      +      }
      +    }
      +
      +  };
      +
      +  /**
      +   * Calls the pause() method of a SMSound object by ID.
      +   *
      +   * @param {string} sID The ID of the sound
      +   * @return {SMSound} The SMSound object
      +   */
      +
      +  this.pause = function(sID) {
      +
      +    if (!idCheck(sID)) {
      +      return false;
      +    }
      +    return sm2.sounds[sID].pause();
      +
      +  };
      +
      +  /**
      +   * Pauses all currently-playing sounds.
      +   */
      +
      +  this.pauseAll = function() {
      +
      +    var i;
      +    for (i = sm2.soundIDs.length-1; i >= 0; i--) {
      +      sm2.sounds[sm2.soundIDs[i]].pause();
      +    }
      +
      +  };
      +
      +  /**
      +   * Calls the resume() method of a SMSound object by ID.
      +   *
      +   * @param {string} sID The ID of the sound
      +   * @return {SMSound} The SMSound object
      +   */
      +
      +  this.resume = function(sID) {
      +
      +    if (!idCheck(sID)) {
      +      return false;
      +    }
      +    return sm2.sounds[sID].resume();
      +
      +  };
      +
      +  /**
      +   * Resumes all currently-paused sounds.
      +   */
      +
      +  this.resumeAll = function() {
      +
      +    var i;
      +    for (i = sm2.soundIDs.length-1; i >= 0; i--) {
      +      sm2.sounds[sm2.soundIDs[i]].resume();
      +    }
      +
      +  };
      +
      +  /**
      +   * Calls the togglePause() method of a SMSound object by ID.
      +   *
      +   * @param {string} sID The ID of the sound
      +   * @return {SMSound} The SMSound object
      +   */
      +
      +  this.togglePause = function(sID) {
      +
      +    if (!idCheck(sID)) {
      +      return false;
      +    }
      +    return sm2.sounds[sID].togglePause();
      +
      +  };
      +
      +  /**
      +   * Calls the setPan() method of a SMSound object by ID.
      +   *
      +   * @param {string} sID The ID of the sound
      +   * @param {number} nPan The pan value (-100 to 100)
      +   * @return {SMSound} The SMSound object
      +   */
      +
      +  this.setPan = function(sID, nPan) {
      +
      +    if (!idCheck(sID)) {
      +      return false;
      +    }
      +    return sm2.sounds[sID].setPan(nPan);
      +
      +  };
      +
      +  /**
      +   * Calls the setVolume() method of a SMSound object by ID.
      +   *
      +   * @param {string} sID The ID of the sound
      +   * @param {number} nVol The volume value (0 to 100)
      +   * @return {SMSound} The SMSound object
      +   */
      +
      +  this.setVolume = function(sID, nVol) {
      +
      +    if (!idCheck(sID)) {
      +      return false;
      +    }
      +    return sm2.sounds[sID].setVolume(nVol);
      +
      +  };
      +
      +  /**
      +   * Calls the mute() method of either a single SMSound object by ID, or all sound objects.
      +   *
      +   * @param {string} sID Optional: The ID of the sound (if omitted, all sounds will be used.)
      +   */
      +
      +  this.mute = function(sID) {
      +
      +    var i = 0;
      +
      +    if (sID instanceof String) {
      +      sID = null;
      +    }
      +
      +    if (!sID) {
      +
      +      sm2._wD(sm + '.mute(): Muting all sounds');
      +      for (i = sm2.soundIDs.length-1; i >= 0; i--) {
      +        sm2.sounds[sm2.soundIDs[i]].mute();
      +      }
      +      sm2.muted = true;
      +
      +    } else {
      +
      +      if (!idCheck(sID)) {
      +        return false;
      +      }
      +      sm2._wD(sm + '.mute(): Muting "' + sID + '"');
      +      return sm2.sounds[sID].mute();
      +
      +    }
      +
      +    return true;
      +
      +  };
      +
      +  /**
      +   * Mutes all sounds.
      +   */
      +
      +  this.muteAll = function() {
      +
      +    sm2.mute();
      +
      +  };
      +
      +  /**
      +   * Calls the unmute() method of either a single SMSound object by ID, or all sound objects.
      +   *
      +   * @param {string} sID Optional: The ID of the sound (if omitted, all sounds will be used.)
      +   */
      +
      +  this.unmute = function(sID) {
      +
      +    var i;
      +
      +    if (sID instanceof String) {
      +      sID = null;
      +    }
      +
      +    if (!sID) {
      +
      +      sm2._wD(sm + '.unmute(): Unmuting all sounds');
      +      for (i = sm2.soundIDs.length-1; i >= 0; i--) {
      +        sm2.sounds[sm2.soundIDs[i]].unmute();
      +      }
      +      sm2.muted = false;
      +
      +    } else {
      +
      +      if (!idCheck(sID)) {
      +        return false;
      +      }
      +      sm2._wD(sm + '.unmute(): Unmuting "' + sID + '"');
      +      return sm2.sounds[sID].unmute();
      +
      +    }
      +
      +    return true;
      +
      +  };
      +
      +  /**
      +   * Unmutes all sounds.
      +   */
      +
      +  this.unmuteAll = function() {
      +
      +    sm2.unmute();
      +
      +  };
      +
      +  /**
      +   * Calls the toggleMute() method of a SMSound object by ID.
      +   *
      +   * @param {string} sID The ID of the sound
      +   * @return {SMSound} The SMSound object
      +   */
      +
      +  this.toggleMute = function(sID) {
      +
      +    if (!idCheck(sID)) {
      +      return false;
      +    }
      +    return sm2.sounds[sID].toggleMute();
      +
      +  };
      +
      +  /**
      +   * Retrieves the memory used by the flash plugin.
      +   *
      +   * @return {number} The amount of memory in use
      +   */
      +
      +  this.getMemoryUse = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      flash-only

      + +
      + +
          var ram = 0;
      +
      +    if (flash && fV !== 8) {
      +      ram = parseInt(flash._getMemoryUse(), 10);
      +    }
      +
      +    return ram;
      +
      +  };
      +
      +  /**
      +   * Undocumented: NOPs soundManager and all SMSound objects.
      +   */
      +
      +  this.disable = function(bNoDisable) {
      + +
    • + + +
    • +
      + +
      + +
      +

      destroy all functions

      + +
      + +
          var i;
      +
      +    if (bNoDisable === _undefined) {
      +      bNoDisable = false;
      +    }
      +
      +    if (disabled) {
      +      return false;
      +    }
      +
      +    disabled = true;
      +    _wDS('shutdown', 1);
      +
      +    for (i = sm2.soundIDs.length-1; i >= 0; i--) {
      +      disableObject(sm2.sounds[sm2.soundIDs[i]]);
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      fire "complete", despite fail

      + +
      + +
          initComplete(bNoDisable);
      +    event.remove(window, 'load', initUserOnload);
      +
      +    return true;
      +
      +  };
      +
      +  /**
      +   * Determines playability of a MIME type, eg. 'audio/mp3'.
      +   */
      +
      +  this.canPlayMIME = function(sMIME) {
      +
      +    var result;
      +
      +    if (sm2.hasHTML5) {
      +      result = html5CanPlay({type:sMIME});
      +    }
      +
      +    if (!result && needsFlash) {
      + +
    • + + +
    • +
      + +
      + +
      +

      if flash 9, test netStream (movieStar) types as well.

      + +
      + +
            result = (sMIME && sm2.ok() ? !!((fV > 8 ? sMIME.match(netStreamMimeTypes) : null) || sMIME.match(sm2.mimePattern)) : null); // TODO: make less "weird" (per JSLint)
      +    }
      +
      +    return result;
      +
      +  };
      +
      +  /**
      +   * Determines playability of a URL based on audio support.
      +   *
      +   * @param {string} sURL The URL to test
      +   * @return {boolean} URL playability
      +   */
      +
      +  this.canPlayURL = function(sURL) {
      +
      +    var result;
      +
      +    if (sm2.hasHTML5) {
      +      result = html5CanPlay({url: sURL});
      +    }
      +
      +    if (!result && needsFlash) {
      +      result = (sURL && sm2.ok() ? !!(sURL.match(sm2.filePattern)) : null);
      +    }
      +
      +    return result;
      +
      +  };
      +
      +  /**
      +   * Determines playability of an HTML DOM &lt;a&gt; object (or similar object literal) based on audio support.
      +   *
      +   * @param {object} oLink an HTML DOM &lt;a&gt; object or object literal including href and/or type attributes
      +   * @return {boolean} URL playability
      +   */
      +
      +  this.canPlayLink = function(oLink) {
      +
      +    if (oLink.type !== _undefined && oLink.type) {
      +      if (sm2.canPlayMIME(oLink.type)) {
      +        return true;
      +      }
      +    }
      +
      +    return sm2.canPlayURL(oLink.href);
      +
      +  };
      +
      +  /**
      +   * Retrieves a SMSound object by ID.
      +   *
      +   * @param {string} sID The ID of the sound
      +   * @return {SMSound} The SMSound object
      +   */
      +
      +  this.getSoundById = function(sID, _suppressDebug) {
      +
      +    if (!sID) {
      +      return null;
      +    }
      +
      +    var result = sm2.sounds[sID];
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
          if (!result && !_suppressDebug) {
      +      sm2._wD(sm + '.getSoundById(): Sound "' + sID + '" not found.', 2);
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +    return result;
      +
      +  };
      +
      +  /**
      +   * Queues a callback for execution when SoundManager has successfully initialized.
      +   *
      +   * @param {function} oMethod The callback method to fire
      +   * @param {object} oScope Optional: The scope to apply to the callback
      +   */
      +
      +  this.onready = function(oMethod, oScope) {
      +
      +    var sType = 'onready',
      +        result = false;
      +
      +    if (typeof oMethod === 'function') {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            if (didInit) {
      +        sm2._wD(str('queue', sType));
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +      if (!oScope) {
      +        oScope = window;
      +      }
      +
      +      addOnEvent(sType, oMethod, oScope);
      +      processOnEvents();
      +
      +      result = true;
      +
      +    } else {
      +
      +      throw str('needFunction', sType);
      +
      +    }
      +
      +    return result;
      +
      +  };
      +
      +  /**
      +   * Queues a callback for execution when SoundManager has failed to initialize.
      +   *
      +   * @param {function} oMethod The callback method to fire
      +   * @param {object} oScope Optional: The scope to apply to the callback
      +   */
      +
      +  this.ontimeout = function(oMethod, oScope) {
      +
      +    var sType = 'ontimeout',
      +        result = false;
      +
      +    if (typeof oMethod === 'function') {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            if (didInit) {
      +        sm2._wD(str('queue', sType));
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +      if (!oScope) {
      +        oScope = window;
      +      }
      +
      +      addOnEvent(sType, oMethod, oScope);
      +      processOnEvents({type:sType});
      +
      +      result = true;
      +
      +    } else {
      +
      +      throw str('needFunction', sType);
      +
      +    }
      +
      +    return result;
      +
      +  };
      +
      +  /**
      +   * Writes console.log()-style debug output to a console or in-browser element.
      +   * Applies when debugMode = true
      +   *
      +   * @param {string} sText The console message
      +   * @param {object} nType Optional log level (number), or object. Number case: Log type/style where 0 = 'info', 1 = 'warn', 2 = 'error'. Object case: Object to be dumped.
      +   */
      +
      +  this._writeDebug = function(sText, sTypeOrObject) {
      + +
    • + + +
    • +
      + +
      + +
      +

      pseudo-private console.log()-style output

      + + +
      + +
      +    var sDID = 'soundmanager-debug', o, oItem;
      +
      +    if (!sm2.debugMode) {
      +      return false;
      +    }
      +
      +    if (hasConsole && sm2.useConsole) {
      +      if (sTypeOrObject && typeof sTypeOrObject === 'object') {
      + +
    • + + +
    • +
      + +
      + +
      +

      object passed; dump to console.

      + +
      + +
              console.log(sText, sTypeOrObject);
      +      } else if (debugLevels[sTypeOrObject] !== _undefined) {
      +        console[debugLevels[sTypeOrObject]](sText);
      +      } else {
      +        console.log(sText);
      +      }
      +      if (sm2.consoleOnly) {
      +        return true;
      +      }
      +    }
      +
      +    o = id(sDID);
      +
      +    if (!o) {
      +      return false;
      +    }
      +
      +    oItem = doc.createElement('div');
      +
      +    if (++wdCount % 2 === 0) {
      +      oItem.className = 'sm2-alt';
      +    }
      +
      +    if (sTypeOrObject === _undefined) {
      +      sTypeOrObject = 0;
      +    } else {
      +      sTypeOrObject = parseInt(sTypeOrObject, 10);
      +    }
      +
      +    oItem.appendChild(doc.createTextNode(sText));
      +
      +    if (sTypeOrObject) {
      +      if (sTypeOrObject >= 2) {
      +        oItem.style.fontWeight = 'bold';
      +      }
      +      if (sTypeOrObject === 3) {
      +        oItem.style.color = '#ff3333';
      +      }
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      top-to-bottom +o.appendChild(oItem);

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      bottom-to-top

      + +
      + +
          o.insertBefore(oItem, o.firstChild);
      +
      +    o = null;
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +    return true;
      +
      +  };
      + +
    • + + +
    • +
      + +
      + +
      +

      +last-resort debugging option

      + +
      + +
        if (wl.indexOf('sm2-debug=alert') !== -1) {
      +    this._writeDebug = function(sText) {
      +      window.alert(sText);
      +    };
      +  }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      alias

      + +
      + +
        this._wD = this._writeDebug;
      +
      +  /**
      +   * Provides debug / state information on all SMSound objects.
      +   */
      +
      +  this._debug = function() {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
          var i, j;
      +    _wDS('currentObj', 1);
      +
      +    for (i = 0, j = sm2.soundIDs.length; i < j; i++) {
      +      sm2.sounds[sm2.soundIDs[i]]._debug();
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +  };
      +
      +  /**
      +   * Restarts and re-initializes the SoundManager instance.
      +   *
      +   * @param {boolean} resetEvents Optional: When true, removes all registered onready and ontimeout event callbacks.
      +   * @param {boolean} excludeInit Options: When true, does not call beginDelayedInit() (which would restart SM2).
      +   * @return {object} soundManager The soundManager instance.
      +   */
      +
      +  this.reboot = function(resetEvents, excludeInit) {
      + +
    • + + +
    • +
      + +
      + +
      +

      reset some (or all) state, and re-init unless otherwise specified.

      + +
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
          if (sm2.soundIDs.length) {
      +      sm2._wD('Destroying ' + sm2.soundIDs.length + ' SMSound object' + (sm2.soundIDs.length !== 1 ? 's' : '') + '...');
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +    var i, j, k;
      +
      +    for (i = sm2.soundIDs.length-1; i >= 0; i--) {
      +      sm2.sounds[sm2.soundIDs[i]].destruct();
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      trash ze flash (remove from the DOM)

      + +
      + +
      +    if (flash) {
      +
      +      try {
      +
      +        if (isIE) {
      +          oRemovedHTML = flash.innerHTML;
      +        }
      +
      +        oRemoved = flash.parentNode.removeChild(flash);
      +
      +      } catch(e) {
      + +
    • + + +
    • +
      + +
      + +
      +

      Remove failed? May be due to flash blockers silently removing the SWF object/embed node from the DOM. Warn and continue.

      + +
      + +
      +        _wDS('badRemove', 2);
      +
      +      }
      +
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      actually, force recreate of movie.

      + +
      + +
      +    oRemovedHTML = oRemoved = needsFlash = flash = null;
      +
      +    sm2.enabled = didDCLoaded = didInit = waitingForEI = initPending = didAppend = appendSuccess = disabled = useGlobalHTML5Audio = sm2.swfLoaded = false;
      +
      +    sm2.soundIDs = [];
      +    sm2.sounds = {};
      +
      +    idCounter = 0;
      +
      +    if (!resetEvents) {
      + +
    • + + +
    • +
      + +
      + +
      +

      reset callbacks for onready, ontimeout etc. so that they will fire again on re-init

      + +
      + +
            for (i in on_queue) {
      +        if (on_queue.hasOwnProperty(i)) {
      +          for (j = 0, k = on_queue[i].length; j < k; j++) {
      +            on_queue[i][j].fired = false;
      +          }
      +        }
      +      }
      +    } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      remove all callbacks entirely

      + +
      + +
            on_queue = [];
      +    }
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
          if (!excludeInit) {
      +      sm2._wD(sm + ': Rebooting...');
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      reset HTML5 and flash canPlay test results

      + +
      + +
      +    sm2.html5 = {
      +      'usingFlash': null
      +    };
      +
      +    sm2.flash = {};
      + +
    • + + +
    • +
      + +
      + +
      +

      reset device-specific HTML/flash mode switches

      + +
      + +
      +    sm2.html5Only = false;
      +    sm2.ignoreFlash = false;
      +
      +    window.setTimeout(function() {
      +
      +      preInit();
      + +
    • + + +
    • +
      + +
      + +
      +

      by default, re-init

      + +
      + +
      +      if (!excludeInit) {
      +        sm2.beginDelayedInit();
      +      }
      +
      +    }, 20);
      +
      +    return sm2;
      +
      +  };
      +
      +  this.reset = function() {
      +
      +    /**
      +     * Shuts down and restores the SoundManager instance to its original loaded state, without an explicit reboot. All onready/ontimeout handlers are removed.
      +     * After this call, SM2 may be re-initialized via soundManager.beginDelayedInit().
      +     * @return {object} soundManager The soundManager instance.
      +     */
      +
      +    _wDS('reset');
      +    return sm2.reboot(true, true);
      +
      +  };
      +
      +  /**
      +   * Undocumented: Determines the SM2 flash movie's load progress.
      +   *
      +   * @return {number or null} Percent loaded, or if invalid/unsupported, null.
      +   */
      +
      +  this.getMoviePercent = function() {
      +
      +    /**
      +     * Interesting syntax notes...
      +     * Flash/ExternalInterface (ActiveX/NPAPI) bridge methods are not typeof "function" nor instanceof Function, but are still valid.
      +     * Additionally, JSLint dislikes ('PercentLoaded' in flash)-style syntax and recommends hasOwnProperty(), which does not work in this case.
      +     * Furthermore, using (flash && flash.PercentLoaded) causes IE to throw "object doesn't support this property or method".
      +     * Thus, 'in' syntax must be used.
      +     */
      +
      +    return (flash && 'PercentLoaded' in flash ? flash.PercentLoaded() : null); // Yes, JSLint. See nearby comment in source for explanation.
      +
      +  };
      +
      +  /**
      +   * Additional helper for manually invoking SM2's init process after DOM Ready / window.onload().
      +   */
      +
      +  this.beginDelayedInit = function() {
      +
      +    windowLoaded = true;
      +    domContentLoaded();
      +
      +    setTimeout(function() {
      +
      +      if (initPending) {
      +        return false;
      +      }
      +
      +      createMovie();
      +      initMovie();
      +      initPending = true;
      +
      +      return true;
      +
      +    }, 20);
      +
      +    delayWaitForEI();
      +
      +  };
      +
      +  /**
      +   * Destroys the SoundManager instance and all SMSound instances.
      +   */
      +
      +  this.destruct = function() {
      +
      +    sm2._wD(sm + '.destruct()');
      +    sm2.disable(true);
      +
      +  };
      +
      +  /**
      +   * SMSound() (sound object) constructor
      +   * ------------------------------------
      +   *
      +   * @param {object} oOptions Sound options (id and url are required attributes)
      +   * @return {SMSound} The new SMSound object
      +   */
      +
      +  SMSound = function(oOptions) {
      +
      +    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;
      +
      +    lastHTML5State = {
      + +
    • + + +
    • +
      + +
      + +
      +

      tracks duration + position (time)

      + +
      + +
            duration: null,
      +      time: null
      +    };
      +
      +    this.id = oOptions.id;
      + +
    • + + +
    • +
      + +
      + +
      +

      legacy

      + +
      + +
          this.sID = this.id;
      +
      +    this.url = oOptions.url;
      +    this.options = mixin(oOptions);
      + +
    • + + +
    • +
      + +
      + +
      +

      per-play-instance-specific options

      + +
      + +
          this.instanceOptions = this.options;
      + +
    • + + +
    • +
      + +
      + +
      +

      short alias

      + +
      + +
          this._iO = this.instanceOptions;
      + +
    • + + +
    • +
      + +
      + +
      +

      assign property defaults

      + +
      + +
          this.pan = this.options.pan;
      +    this.volume = this.options.volume;
      + +
    • + + +
    • +
      + +
      + +
      +

      whether or not this object is using HTML5

      + +
      + +
          this.isHTML5 = false;
      + +
    • + + +
    • +
      + +
      + +
      +

      internal HTML5 Audio() object reference

      + +
      + +
          this._a = null;
      + +
    • + + +
    • +
      + +
      + +
      +

      for flash 8 special-case createSound() without url, followed by load/play with url case

      + +
      + +
          urlOmitted = (this.url ? false : true);
      +
      +    /**
      +     * SMSound() public methods
      +     * ------------------------
      +     */
      +
      +    this.id3 = {};
      +
      +    /**
      +     * Writes SMSound object parameters to debug console
      +     */
      +
      +    this._debug = function() {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            sm2._wD(s.id + ': Merged options:', s.options);
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +    };
      +
      +    /**
      +     * Begins loading a sound per its *url*.
      +     *
      +     * @param {object} oOptions Optional: Sound options
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    this.load = function(oOptions) {
      +
      +      var oSound = null, instanceOptions;
      +
      +      if (oOptions !== _undefined) {
      +        s._iO = mixin(oOptions, s.options);
      +      } else {
      +        oOptions = s.options;
      +        s._iO = oOptions;
      +        if (lastURL && lastURL !== s.url) {
      +          _wDS('manURL');
      +          s._iO.url = s.url;
      +          s.url = null;
      +        }
      +      }
      +
      +      if (!s._iO.url) {
      +        s._iO.url = s.url;
      +      }
      +
      +      s._iO.url = parseURL(s._iO.url);
      + +
    • + + +
    • +
      + +
      + +
      +

      ensure we're in sync

      + +
      + +
            s.instanceOptions = s._iO;
      + +
    • + + +
    • +
      + +
      + +
      +

      local shortcut

      + +
      + +
            instanceOptions = s._iO;
      +
      +      sm2._wD(s.id + ': load (' + instanceOptions.url + ')');
      +
      +      if (!instanceOptions.url && !s.url) {
      +        sm2._wD(s.id + ': load(): url is unassigned. Exiting.', 2);
      +        return s;
      +      }
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            if (!s.isHTML5 && fV === 8 && !s.url && !instanceOptions.autoPlay) {
      + +
    • + + +
    • +
      + +
      + +
      +

      flash 8 load() -> play() won't work before onload has fired.

      + +
      + +
              sm2._wD(s.id + ': Flash 8 load() limitation: Wait for onload() before calling play().', 1);
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +      if (instanceOptions.url === s.url && s.readyState !== 0 && s.readyState !== 2) {
      +        _wDS('onURL', 1);
      + +
    • + + +
    • +
      + +
      + +
      +

      if loaded and an onload() exists, fire immediately.

      + +
      + +
              if (s.readyState === 3 && instanceOptions.onload) {
      + +
    • + + +
    • +
      + +
      + +
      +

      assume success based on truthy duration.

      + +
      + +
                wrapCallback(s, function() {
      +            instanceOptions.onload.apply(s, [(!!s.duration)]);
      +          });
      +        }
      +        return s;
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      reset a few state properties

      + +
      + +
      +      s.loaded = false;
      +      s.readyState = 1;
      +      s.playState = 0;
      +      s.id3 = {};
      + +
    • + + +
    • +
      + +
      + +
      +

      TODO: If switching from HTML5 -> flash (or vice versa), stop currently-playing audio.

      + +
      + +
      +      if (html5OK(instanceOptions)) {
      +
      +        oSound = s._setup_html5(instanceOptions);
      +
      +        if (!oSound._called_load) {
      +
      +          s._html5_canplay = false;
      + +
    • + + +
    • +
      + +
      + +
      +

      TODO: review called_load / html5_canplay logic

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      if url provided directly to load(), assign it here.

      + +
      + +
      +          if (s.url !== instanceOptions.url) {
      +
      +            sm2._wD(_wDS('manURL') + ': ' + instanceOptions.url);
      +
      +            s._a.src = instanceOptions.url;
      + +
    • + + +
    • +
      + +
      + +
      +

      TODO: review / re-apply all relevant options (volume, loop, onposition etc.)

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      reset position for new URL

      + +
      + +
                  s.setPosition(0);
      +
      +          }
      + +
    • + + +
    • +
      + +
      + +
      +

      given explicit load call, try to preload.

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      early HTML5 implementation (non-standard)

      + +
      + +
                s._a.autobuffer = 'auto';
      + +
    • + + +
    • +
      + +
      + +
      +

      standard property, values: none / metadata / auto +reference: http://msdn.microsoft.com/en-us/library/ie/ff974759%28v=vs.85%29.aspx

      + +
      + +
                s._a.preload = 'auto';
      +
      +          s._a._called_load = true;
      +
      +        } else {
      +
      +          sm2._wD(s.id + ': Ignoring request to load again');
      +
      +        }
      +
      +      } else {
      +
      +        if (sm2.html5Only) {
      +          sm2._wD(s.id + ': No flash support. Exiting.');
      +          return s;
      +        }
      +
      +        if (s._iO.url && s._iO.url.match(/data\:/i)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      data: URIs not supported by Flash, either.

      + +
      + +
                sm2._wD(s.id + ': data: URIs not supported via Flash. Exiting.');
      +          return s;
      +        }
      +
      +        try {
      +          s.isHTML5 = false;
      +          s._iO = policyFix(loopFix(instanceOptions));
      + +
    • + + +
    • +
      + +
      + +
      +

      re-assign local shortcut

      + +
      + +
                instanceOptions = s._iO;
      +          if (fV === 8) {
      +            flash._load(s.id, instanceOptions.url, instanceOptions.stream, instanceOptions.autoPlay, instanceOptions.usePolicyFile);
      +          } else {
      +            flash._load(s.id, instanceOptions.url, !!(instanceOptions.stream), !!(instanceOptions.autoPlay), instanceOptions.loops||1, !!(instanceOptions.autoLoad), instanceOptions.usePolicyFile);
      +          }
      +        } catch(e) {
      +          _wDS('smError', 2);
      +          debugTS('onload', false);
      +          catchError({type:'SMSOUND_LOAD_JS_EXCEPTION', fatal:true});
      +        }
      +
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      after all of this, ensure sound url is up to date.

      + +
      + +
            s.url = instanceOptions.url;
      +
      +      return s;
      +
      +    };
      +
      +    /**
      +     * Unloads a sound, canceling any open HTTP requests.
      +     *
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    this.unload = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      Flash 8/AS2 can't "close" a stream - fake it by loading an empty URL +Flash 9/AS3: Close stream, preventing further load +HTML5: Most UAs will use empty URL

      + +
      + +
      +      if (s.readyState !== 0) {
      +
      +        sm2._wD(s.id + ': unload()');
      +
      +        if (!s.isHTML5) {
      +
      +          if (fV === 8) {
      +            flash._unload(s.id, emptyURL);
      +          } else {
      +            flash._unload(s.id);
      +          }
      +
      +        } else {
      +
      +          stop_html5_timer();
      +
      +          if (s._a) {
      +
      +            s._a.pause();
      + +
    • + + +
    • +
      + +
      + +
      +

      update empty URL, too

      + +
      + +
                  lastURL = html5Unload(s._a);
      +
      +          }
      +
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      reset load/status flags

      + +
      + +
              resetProperties();
      +
      +      }
      +
      +      return s;
      +
      +    };
      +
      +    /**
      +     * Unloads and destroys a sound.
      +     */
      +
      +    this.destruct = function(_bFromSM) {
      +
      +      sm2._wD(s.id + ': Destruct');
      +
      +      if (!s.isHTML5) {
      + +
    • + + +
    • +
      + +
      + +
      +

      kill sound within Flash +Disable the onfailure handler

      + +
      + +
              s._iO.onfailure = null;
      +        flash._destroySound(s.id);
      +
      +      } else {
      +
      +        stop_html5_timer();
      +
      +        if (s._a) {
      +          s._a.pause();
      +          html5Unload(s._a);
      +          if (!useGlobalHTML5Audio) {
      +            remove_html5_events();
      +          }
      + +
    • + + +
    • +
      + +
      + +
      +

      break obvious circular reference

      + +
      + +
                s._a._s = null;
      +          s._a = null;
      +        }
      +
      +      }
      +
      +      if (!_bFromSM) {
      + +
    • + + +
    • +
      + +
      + +
      +

      ensure deletion from controller

      + +
      + +
              sm2.destroySound(s.id, true);
      +      }
      +
      +    };
      +
      +    /**
      +     * Begins playing a sound.
      +     *
      +     * @param {object} oOptions Optional: Sound options
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    this.play = function(oOptions, _updatePlayState) {
      +
      +      var fN, allowMulti, a, onready,
      +          audioClone, onended, oncanplay,
      +          startOK = true,
      +          exit = null;
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            fN = s.id + ': play(): ';
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      default to true

      + +
      + +
            _updatePlayState = (_updatePlayState === _undefined ? true : _updatePlayState);
      +
      +      if (!oOptions) {
      +        oOptions = {};
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      first, use local URL (if specified)

      + +
      + +
            if (s.url) {
      +        s._iO.url = s.url;
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      mix in any options defined at createSound()

      + +
      + +
            s._iO = mixin(s._iO, s.options);
      + +
    • + + +
    • +
      + +
      + +
      +

      mix in any options specific to this method

      + +
      + +
            s._iO = mixin(oOptions, s._iO);
      +
      +      s._iO.url = parseURL(s._iO.url);
      +
      +      s.instanceOptions = s._iO;
      + +
    • + + +
    • +
      + +
      + +
      +

      RTMP-only

      + +
      + +
            if (!s.isHTML5 && s._iO.serverURL && !s.connected) {
      +        if (!s.getAutoPlay()) {
      +          sm2._wD(fN +' Netstream not connected yet - setting autoPlay');
      +          s.setAutoPlay(true);
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      play will be called in onconnect()

      + +
      + +
              return s;
      +      }
      +
      +      if (html5OK(s._iO)) {
      +        s._setup_html5(s._iO);
      +        start_html5_timer();
      +      }
      +
      +      if (s.playState === 1 && !s.paused) {
      +        allowMulti = s._iO.multiShot;
      +        if (!allowMulti) {
      +          sm2._wD(fN + 'Already playing (one-shot)', 1);
      +          if (s.isHTML5) {
      + +
    • + + +
    • +
      + +
      + +
      +

      go back to original position.

      + +
      + +
                  s.setPosition(s._iO.position);
      +          }
      +          exit = s;
      +        } else {
      +          sm2._wD(fN + 'Already playing (multi-shot)', 1);
      +        }
      +      }
      +
      +      if (exit !== null) {
      +        return exit;
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      edge case: play() with explicit URL parameter

      + +
      + +
            if (oOptions.url && oOptions.url !== s.url) {
      + +
    • + + +
    • +
      + +
      + +
      +

      special case for createSound() followed by load() / play() with url; avoid double-load case.

      + +
      + +
              if (!s.readyState && !s.isHTML5 && fV === 8 && urlOmitted) {
      +
      +          urlOmitted = false;
      +
      +        } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      load using merged options

      + +
      + +
                s.load(s._iO);
      +
      +        }
      +
      +      }
      +
      +      if (!s.loaded) {
      +
      +        if (s.readyState === 0) {
      +
      +          sm2._wD(fN + 'Attempting to load');
      + +
    • + + +
    • +
      + +
      + +
      +

      try to get this sound playing ASAP

      + +
      + +
                if (!s.isHTML5 && !sm2.html5Only) {
      + +
    • + + +
    • +
      + +
      + +
      +

      flash: assign directly because setAutoPlay() increments the instanceCount

      + +
      + +
                  s._iO.autoPlay = true;
      +            s.load(s._iO);
      +
      +          } else if (s.isHTML5) {
      + +
    • + + +
    • +
      + +
      + +
      +

      iOS needs this when recycling sounds, loading a new URL on an existing object.

      + +
      + +
                  s.load(s._iO);
      +
      +          } else {
      +
      +            sm2._wD(fN + 'Unsupported type. Exiting.');
      +            exit = s;
      +
      +          }
      + +
    • + + +
    • +
      + +
      + +
      +

      HTML5 hack - re-set instanceOptions?

      + +
      + +
                s.instanceOptions = s._iO;
      +
      +        } else if (s.readyState === 2) {
      +
      +          sm2._wD(fN + 'Could not load - exiting', 2);
      +          exit = s;
      +
      +        } else {
      +
      +          sm2._wD(fN + 'Loading - attempting to play...');
      +
      +        }
      +
      +      } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      "play()"

      + +
      + +
              sm2._wD(fN.substr(0, fN.lastIndexOf(':')));
      +
      +      }
      +
      +      if (exit !== null) {
      +        return exit;
      +      }
      +
      +      if (!s.isHTML5 && fV === 9 && s.position > 0 && s.position === s.duration) {
      + +
    • + + +
    • +
      + +
      + +
      +

      flash 9 needs a position reset if play() is called while at the end of a sound.

      + +
      + +
              sm2._wD(fN + 'Sound at end, resetting to position:0');
      +        oOptions.position = 0;
      +      }
      +
      +      /**
      +       * Streams will pause when their buffer is full if they are being loaded.
      +       * In this case paused is true, but the song hasn't started playing yet.
      +       * If we just call resume() the onplay() callback will never be called.
      +       * So only call resume() if the position is > 0.
      +       * Another reason is because options like volume won't have been applied yet.
      +       * For normal sounds, just resume.
      +       */
      +
      +      if (s.paused && s.position >= 0 && (!s._iO.serverURL || s.position > 0)) {
      + +
    • + + +
    • + + +
              sm2._wD(fN + 'Resuming from paused state', 1);
      +        s.resume();
      +
      +      } else {
      +
      +        s._iO = mixin(oOptions, s._iO);
      + +
    • + + +
    • +
      + +
      + +
      +

      apply from/to parameters, if they exist (and not using RTMP)

      + +
      + +
              if (s._iO.from !== null && s._iO.to !== null && s.instanceCount === 0 && s.playState === 0 && !s._iO.serverURL) {
      +
      +          onready = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      sound "canplay" or onload() +re-apply from/to to instance options, and start playback

      + +
      + +
                  s._iO = mixin(oOptions, s._iO);
      +            s.play(s._iO);
      +          };
      + +
    • + + +
    • +
      + +
      + +
      +

      HTML5 needs to at least have "canplay" fired before seeking.

      + +
      + +
                if (s.isHTML5 && !s._html5_canplay) {
      + +
    • + + +
    • +
      + +
      + +
      +

      this hasn't been loaded yet. load it first, and then do this again.

      + +
      + +
                  sm2._wD(fN + 'Beginning load for from/to case');
      +
      +            s.load({
      + +
    • + + +
    • +
      + +
      + +
      +

      note: custom HTML5-only event added for from/to implementation.

      + +
      + +
                    _oncanplay: onready
      +            });
      +
      +            exit = false;
      +
      +          } else if (!s.isHTML5 && !s.loaded && (!s.readyState || s.readyState !== 2)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      to be safe, preload the whole thing in Flash.

      + +
      + +
      +            sm2._wD(fN + 'Preloading for from/to case');
      +
      +            s.load({
      +              onload: onready
      +            });
      +
      +            exit = false;
      +
      +          }
      +
      +          if (exit !== null) {
      +            return exit;
      +          }
      + +
    • + + +
    • +
      + +
      + +
      +

      otherwise, we're ready to go. re-apply local options, and continue

      + +
      + +
      +          s._iO = applyFromTo();
      +
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      sm2._wD(fN + 'Starting to play');

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      increment instance counter, where enabled + supported

      + +
      + +
              if (!s.instanceCount || s._iO.multiShotEvents || (s.isHTML5 && s._iO.multiShot && !useGlobalHTML5Audio) || (!s.isHTML5 && fV > 8 && !s.getAutoPlay())) {
      +          s.instanceCount++;
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      if first play and onposition parameters exist, apply them now

      + +
      + +
              if (s._iO.onposition && s.playState === 0) {
      +          attachOnPosition(s);
      +        }
      +
      +        s.playState = 1;
      +        s.paused = false;
      +
      +        s.position = (s._iO.position !== _undefined && !isNaN(s._iO.position) ? s._iO.position : 0);
      +
      +        if (!s.isHTML5) {
      +          s._iO = policyFix(loopFix(s._iO));
      +        }
      +
      +        if (s._iO.onplay && _updatePlayState) {
      +          s._iO.onplay.apply(s);
      +          onplay_called = true;
      +        }
      +
      +        s.setVolume(s._iO.volume, true);
      +        s.setPan(s._iO.pan, true);
      +
      +        if (!s.isHTML5) {
      +
      +          startOK = flash._start(s.id, s._iO.loops || 1, (fV === 9 ? s.position : s.position / msecScale), s._iO.multiShot || false);
      +
      +          if (fV === 9 && !startOK) {
      + +
    • + + +
    • +
      + +
      + +
      +

      edge case: no sound hardware, or 32-channel flash ceiling hit. +applies only to Flash 9, non-NetStream/MovieStar sounds. +http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html#play%28%29

      + +
      + +
                  sm2._wD(fN + 'No sound hardware, or 32-sound ceiling hit', 2);
      +            if (s._iO.onplayerror) {
      +              s._iO.onplayerror.apply(s);
      +            }
      +
      +          }
      +
      +        } else {
      +
      +          if (s.instanceCount < 2) {
      + +
    • + + +
    • +
      + +
      + +
      +

      HTML5 single-instance case

      + +
      + +
      +            start_html5_timer();
      +
      +            a = s._setup_html5();
      +
      +            s.setPosition(s._iO.position);
      +
      +            a.play();
      +
      +          } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      HTML5 multi-shot case

      + +
      + +
      +            sm2._wD(s.id + ': Cloning Audio() for instance #' + s.instanceCount + '...');
      +
      +            audioClone = new Audio(s._iO.url);
      +
      +            onended = function() {
      +              event.remove(audioClone, 'ended', onended);
      +              s._onfinish(s);
      + +
    • + + +
    • +
      + +
      + +
      +

      cleanup

      + +
      + +
                    html5Unload(audioClone);
      +              audioClone = null;
      +            };
      +
      +            oncanplay = function() {
      +              event.remove(audioClone, 'canplay', oncanplay);
      +              try {
      +                audioClone.currentTime = s._iO.position/msecScale;
      +              } catch(err) {
      +                complain(s.id + ': multiShot play() failed to apply position of ' + (s._iO.position/msecScale));
      +              }
      +              audioClone.play();
      +            };
      +
      +            event.add(audioClone, 'ended', onended);
      + +
    • + + +
    • +
      + +
      + +
      +

      apply volume to clones, too

      + +
      + +
                  if (s._iO.volume !== undefined) {
      +              audioClone.volume = Math.max(0, Math.min(1, s._iO.volume/100));
      +            }
      + +
    • + + +
    • +
      + +
      + +
      +

      playing multiple muted sounds? if you do this, you're weird ;) - but let's cover it.

      + +
      + +
                  if (s.muted) {
      +              audioClone.muted = true;
      +            }
      +
      +            if (s._iO.position) {
      + +
    • + + +
    • +
      + +
      + +
      +

      HTML5 audio can't seek before onplay() event has fired. +wait for canplay, then seek to position and start playback.

      + +
      + +
                    event.add(audioClone, 'canplay', oncanplay);
      +            } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      begin playback at currentTime: 0

      + +
      + +
                    audioClone.play();
      +            }
      +
      +          }
      +
      +        }
      +
      +      }
      +
      +      return s;
      +
      +    };
      + +
    • + + +
    • +
      + +
      + +
      +

      just for convenience

      + +
      + +
          this.start = this.play;
      +
      +    /**
      +     * Stops playing a sound (and optionally, all sounds)
      +     *
      +     * @param {boolean} bAll Optional: Whether to stop all sounds
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    this.stop = function(bAll) {
      +
      +      var instanceOptions = s._iO,
      +          originalPosition;
      +
      +      if (s.playState === 1) {
      +
      +        sm2._wD(s.id + ': stop()');
      +
      +        s._onbufferchange(0);
      +        s._resetOnPosition(0);
      +        s.paused = false;
      +
      +        if (!s.isHTML5) {
      +          s.playState = 0;
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      remove onPosition listeners, if any

      + +
      + +
              detachOnPosition();
      + +
    • + + +
    • +
      + +
      + +
      +

      and "to" position, if set

      + +
      + +
              if (instanceOptions.to) {
      +          s.clearOnPosition(instanceOptions.to);
      +        }
      +
      +        if (!s.isHTML5) {
      +
      +          flash._stop(s.id, bAll);
      + +
    • + + +
    • +
      + +
      + +
      +

      hack for netStream: just unload

      + +
      + +
                if (instanceOptions.serverURL) {
      +            s.unload();
      +          }
      +
      +        } else {
      +
      +          if (s._a) {
      +
      +            originalPosition = s.position;
      + +
    • + + +
    • +
      + +
      + +
      +

      act like Flash, though

      + +
      + +
                  s.setPosition(0);
      + +
    • + + +
    • +
      + +
      + +
      +

      hack: reflect old position for onstop() (also like Flash)

      + +
      + +
                  s.position = originalPosition;
      + +
    • + + +
    • +
      + +
      + +
      +

      html5 has no stop() +NOTE: pausing means iOS requires interaction to resume.

      + +
      + +
                  s._a.pause();
      +
      +            s.playState = 0;
      + +
    • + + +
    • +
      + +
      + +
      +

      and update UI

      + +
      + +
                  s._onTimer();
      +
      +            stop_html5_timer();
      +
      +          }
      +
      +        }
      +
      +        s.instanceCount = 0;
      +        s._iO = {};
      +
      +        if (instanceOptions.onstop) {
      +          instanceOptions.onstop.apply(s);
      +        }
      +
      +      }
      +
      +      return s;
      +
      +    };
      +
      +    /**
      +     * Undocumented/internal: Sets autoPlay for RTMP.
      +     *
      +     * @param {boolean} autoPlay state
      +     */
      +
      +    this.setAutoPlay = function(autoPlay) {
      +
      +      sm2._wD(s.id + ': Autoplay turned ' + (autoPlay ? 'on' : 'off'));
      +      s._iO.autoPlay = autoPlay;
      +
      +      if (!s.isHTML5) {
      +        flash._setAutoPlay(s.id, autoPlay);
      +        if (autoPlay) {
      + +
    • + + +
    • +
      + +
      + +
      +

      only increment the instanceCount if the sound isn't loaded (TODO: verify RTMP)

      + +
      + +
                if (!s.instanceCount && s.readyState === 1) {
      +            s.instanceCount++;
      +            sm2._wD(s.id + ': Incremented instance count to '+s.instanceCount);
      +          }
      +        }
      +      }
      +
      +    };
      +
      +    /**
      +     * Undocumented/internal: Returns the autoPlay boolean.
      +     *
      +     * @return {boolean} The current autoPlay value
      +     */
      +
      +    this.getAutoPlay = function() {
      +
      +      return s._iO.autoPlay;
      +
      +    };
      +
      +    /**
      +     * Sets the position of a sound.
      +     *
      +     * @param {number} nMsecOffset Position (milliseconds)
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    this.setPosition = function(nMsecOffset) {
      +
      +      if (nMsecOffset === _undefined) {
      +        nMsecOffset = 0;
      +      }
      +
      +      var position, position1K,
      + +
    • + + +
    • +
      + +
      + +
      +

      Use the duration from the instance options, if we don't have a track duration yet. +position >= 0 and <= current available (loaded) duration

      + +
      + +
                offset = (s.isHTML5 ? Math.max(nMsecOffset, 0) : Math.min(s.duration || s._iO.duration, Math.max(nMsecOffset, 0)));
      +
      +      s.position = offset;
      +      position1K = s.position/msecScale;
      +      s._resetOnPosition(s.position);
      +      s._iO.position = offset;
      +
      +      if (!s.isHTML5) {
      +
      +        position = (fV === 9 ? s.position : position1K);
      +
      +        if (s.readyState && s.readyState !== 2) {
      + +
    • + + +
    • +
      + +
      + +
      +

      if paused or not playing, will not resume (by playing)

      + +
      + +
                flash._setPosition(s.id, position, (s.paused || !s.playState), s._iO.multiShot);
      +        }
      +
      +      } else if (s._a) {
      + +
    • + + +
    • +
      + +
      + +
      +

      Set the position in the canplay handler if the sound is not ready yet

      + +
      + +
              if (s._html5_canplay) {
      +
      +          if (s._a.currentTime !== position1K) {
      +
      +            /**
      +             * DOM/JS errors/exceptions to watch out for:
      +             * if seek is beyond (loaded?) position, "DOM exception 11"
      +             * "INDEX_SIZE_ERR": DOM exception 1
      +             */
      +            sm2._wD(s.id + ': setPosition('+position1K+')');
      +
      +            try {
      +              s._a.currentTime = position1K;
      +              if (s.playState === 0 || s.paused) {
      + +
    • + + +
    • +
      + +
      + +
      +

      allow seek without auto-play/resume

      + +
      + +
                      s._a.pause();
      +              }
      +            } catch(e) {
      +              sm2._wD(s.id + ': setPosition(' + position1K + ') failed: ' + e.message, 2);
      +            }
      +
      +          }
      +
      +        } else if (position1K) {
      + +
    • + + +
    • +
      + +
      + +
      +

      warn on non-zero seek attempts

      + +
      + +
                sm2._wD(s.id + ': setPosition(' + position1K + '): Cannot seek yet, sound not ready', 2);
      +          return s;
      +
      +        }
      +
      +        if (s.paused) {
      + +
    • + + +
    • +
      + +
      + +
      +

      if paused, refresh UI right away +force update

      + +
      + +
                s._onTimer(true);
      +
      +        }
      +
      +      }
      +
      +      return s;
      +
      +    };
      +
      +    /**
      +     * Pauses sound playback.
      +     *
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    this.pause = function(_bCallFlash) {
      +
      +      if (s.paused || (s.playState === 0 && s.readyState !== 1)) {
      +        return s;
      +      }
      +
      +      sm2._wD(s.id + ': pause()');
      +      s.paused = true;
      +
      +      if (!s.isHTML5) {
      +        if (_bCallFlash || _bCallFlash === _undefined) {
      +          flash._pause(s.id, s._iO.multiShot);
      +        }
      +      } else {
      +        s._setup_html5().pause();
      +        stop_html5_timer();
      +      }
      +
      +      if (s._iO.onpause) {
      +        s._iO.onpause.apply(s);
      +      }
      +
      +      return s;
      +
      +    };
      +
      +    /**
      +     * Resumes sound playback.
      +     *
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    /**
      +     * When auto-loaded streams pause on buffer full they have a playState of 0.
      +     * We need to make sure that the playState is set to 1 when these streams "resume".
      +     * When a paused stream is resumed, we need to trigger the onplay() callback if it
      +     * hasn't been called already. In this case since the sound is being played for the
      +     * first time, I think it's more appropriate to call onplay() rather than onresume().
      +     */
      +
      +    this.resume = function() {
      +
      +      var instanceOptions = s._iO;
      +
      +      if (!s.paused) {
      +        return s;
      +      }
      +
      +      sm2._wD(s.id + ': resume()');
      +      s.paused = false;
      +      s.playState = 1;
      +
      +      if (!s.isHTML5) {
      +        if (instanceOptions.isMovieStar && !instanceOptions.serverURL) {
      + +
    • + + +
    • +
      + +
      + +
      +

      Bizarre Webkit bug (Chrome reported via 8tracks.com dudes): AAC content paused for 30+ seconds(?) will not resume without a reposition.

      + +
      + +
                s.setPosition(s.position);
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      flash method is toggle-based (pause/resume)

      + +
      + +
              flash._pause(s.id, instanceOptions.multiShot);
      +      } else {
      +        s._setup_html5().play();
      +        start_html5_timer();
      +      }
      +
      +      if (!onplay_called && instanceOptions.onplay) {
      +        instanceOptions.onplay.apply(s);
      +        onplay_called = true;
      +      } else if (instanceOptions.onresume) {
      +        instanceOptions.onresume.apply(s);
      +      }
      +
      +      return s;
      +
      +    };
      +
      +    /**
      +     * Toggles sound playback.
      +     *
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    this.togglePause = function() {
      +
      +      sm2._wD(s.id + ': togglePause()');
      +
      +      if (s.playState === 0) {
      +        s.play({
      +          position: (fV === 9 && !s.isHTML5 ? s.position : s.position / msecScale)
      +        });
      +        return s;
      +      }
      +
      +      if (s.paused) {
      +        s.resume();
      +      } else {
      +        s.pause();
      +      }
      +
      +      return s;
      +
      +    };
      +
      +    /**
      +     * Sets the panning (L-R) effect.
      +     *
      +     * @param {number} nPan The pan value (-100 to 100)
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    this.setPan = function(nPan, bInstanceOnly) {
      +
      +      if (nPan === _undefined) {
      +        nPan = 0;
      +      }
      +
      +      if (bInstanceOnly === _undefined) {
      +        bInstanceOnly = false;
      +      }
      +
      +      if (!s.isHTML5) {
      +        flash._setPan(s.id, nPan);
      +      } // else { no HTML5 pan? }
      +
      +      s._iO.pan = nPan;
      +
      +      if (!bInstanceOnly) {
      +        s.pan = nPan;
      +        s.options.pan = nPan;
      +      }
      +
      +      return s;
      +
      +    };
      +
      +    /**
      +     * Sets the volume.
      +     *
      +     * @param {number} nVol The volume value (0 to 100)
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    this.setVolume = function(nVol, _bInstanceOnly) {
      +
      +      /**
      +       * Note: Setting volume has no effect on iOS "special snowflake" devices.
      +       * Hardware volume control overrides software, and volume
      +       * will always return 1 per Apple docs. (iOS 4 + 5.)
      +       * http://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/AddingSoundtoCanvasAnimations/AddingSoundtoCanvasAnimations.html
      +       */
      +
      +      if (nVol === _undefined) {
      +        nVol = 100;
      +      }
      +
      +      if (_bInstanceOnly === _undefined) {
      +        _bInstanceOnly = false;
      +      }
      +
      +      if (!s.isHTML5) {
      +        flash._setVolume(s.id, (sm2.muted && !s.muted) || s.muted?0:nVol);
      +      } else if (s._a) {
      +        if (sm2.muted && !s.muted) {
      +          s.muted = true;
      +          s._a.muted = true;
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      valid range: 0-1

      + +
      + +
              s._a.volume = Math.max(0, Math.min(1, nVol/100));
      +      }
      +
      +      s._iO.volume = nVol;
      +
      +      if (!_bInstanceOnly) {
      +        s.volume = nVol;
      +        s.options.volume = nVol;
      +      }
      +
      +      return s;
      +
      +    };
      +
      +    /**
      +     * Mutes the sound.
      +     *
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    this.mute = function() {
      +
      +      s.muted = true;
      +
      +      if (!s.isHTML5) {
      +        flash._setVolume(s.id, 0);
      +      } else if (s._a) {
      +        s._a.muted = true;
      +      }
      +
      +      return s;
      +
      +    };
      +
      +    /**
      +     * Unmutes the sound.
      +     *
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    this.unmute = function() {
      +
      +      s.muted = false;
      +      var hasIO = (s._iO.volume !== _undefined);
      +
      +      if (!s.isHTML5) {
      +        flash._setVolume(s.id, hasIO?s._iO.volume:s.options.volume);
      +      } else if (s._a) {
      +        s._a.muted = false;
      +      }
      +
      +      return s;
      +
      +    };
      +
      +    /**
      +     * Toggles the muted state of a sound.
      +     *
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    this.toggleMute = function() {
      +
      +      return (s.muted?s.unmute():s.mute());
      +
      +    };
      +
      +    /**
      +     * Registers a callback to be fired when a sound reaches a given position during playback.
      +     *
      +     * @param {number} nPosition The position to watch for
      +     * @param {function} oMethod The relevant callback to fire
      +     * @param {object} oScope Optional: The scope to apply the callback to
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    this.onPosition = function(nPosition, oMethod, oScope) {
      + +
    • + + +
    • +
      + +
      + +
      +

      TODO: basic dupe checking?

      + +
      + +
      +      onPositionItems.push({
      +        position: parseInt(nPosition, 10),
      +        method: oMethod,
      +        scope: (oScope !== _undefined ? oScope : s),
      +        fired: false
      +      });
      +
      +      return s;
      +
      +    };
      + +
    • + + +
    • +
      + +
      + +
      +

      legacy/backwards-compability: lower-case method name

      + +
      + +
          this.onposition = this.onPosition;
      +
      +    /**
      +     * Removes registered callback(s) from a sound, by position and/or callback.
      +     *
      +     * @param {number} nPosition The position to clear callback(s) for
      +     * @param {function} oMethod Optional: Identify one callback to be removed when multiple listeners exist for one position
      +     * @return {SMSound} The SMSound object
      +     */
      +
      +    this.clearOnPosition = function(nPosition, oMethod) {
      +
      +      var i;
      +
      +      nPosition = parseInt(nPosition, 10);
      +
      +      if (isNaN(nPosition)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      safety check

      + +
      + +
              return false;
      +      }
      +
      +      for (i=0; i < onPositionItems.length; i++) {
      +
      +        if (nPosition === onPositionItems[i].position) {
      + +
    • + + +
    • +
      + +
      + +
      +

      remove this item if no method was specified, or, if the method matches

      + +
      + +
                if (!oMethod || (oMethod === onPositionItems[i].method)) {
      +            if (onPositionItems[i].fired) {
      + +
    • + + +
    • +
      + +
      + +
      +

      decrement "fired" counter, too

      + +
      + +
                    onPositionFired--;
      +            }
      +            onPositionItems.splice(i, 1);
      +          }
      +        }
      +
      +      }
      +
      +    };
      +
      +    this._processOnPosition = function() {
      +
      +      var i, item, j = onPositionItems.length;
      +		
      +      if (!j || !s.playState || onPositionFired >= j) {
      +        return false;
      +      }
      +
      +      for (i=j-1; i >= 0; i--) {
      +        item = onPositionItems[i];
      +        if (!item.fired && s.position >= item.position) {
      +          item.fired = true;
      +          onPositionFired++;
      +          item.method.apply(item.scope, [item.position]);
      +		  j = onPositionItems.length; //  reset j -- onPositionItems.length can be changed in the item callback above... occasionally breaking the loop.
      +        }
      +      }
      +	
      +      return true;
      +
      +    };
      +
      +    this._resetOnPosition = function(nPosition) {
      + +
    • + + +
    • +
      + +
      + +
      +

      reset "fired" for items interested in this position

      + +
      + +
            var i, item, j = onPositionItems.length;
      +
      +      if (!j) {
      +        return false;
      +      }
      +
      +      for (i=j-1; i >= 0; i--) {
      +        item = onPositionItems[i];
      +        if (item.fired && nPosition <= item.position) {
      +          item.fired = false;
      +          onPositionFired--;
      +        }
      +      }
      +
      +      return true;
      +
      +    };
      +
      +    /**
      +     * SMSound() private internals
      +     * --------------------------------
      +     */
      +
      +    applyFromTo = function() {
      +
      +      var instanceOptions = s._iO,
      +          f = instanceOptions.from,
      +          t = instanceOptions.to,
      +          start, end;
      +
      +      end = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      end has been reached.

      + +
      + +
              sm2._wD(s.id + ': "To" time of ' + t + ' reached.');
      + +
    • + + +
    • +
      + +
      + +
      +

      detach listener

      + +
      + +
              s.clearOnPosition(t, end);
      + +
    • + + +
    • +
      + +
      + +
      +

      stop should clear this, too

      + +
      + +
              s.stop();
      +
      +      };
      +
      +      start = function() {
      +
      +        sm2._wD(s.id + ': Playing "from" ' + f);
      + +
    • + + +
    • +
      + +
      + +
      +

      add listener for end

      + +
      + +
              if (t !== null && !isNaN(t)) {
      +          s.onPosition(t, end);
      +        }
      +
      +      };
      +
      +      if (f !== null && !isNaN(f)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      apply to instance options, guaranteeing correct start position.

      + +
      + +
              instanceOptions.position = f;
      + +
    • + + +
    • +
      + +
      + +
      +

      multiShot timing can't be tracked, so prevent that.

      + +
      + +
              instanceOptions.multiShot = false;
      +
      +        start();
      +
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      return updated instanceOptions including starting position

      + +
      + +
            return instanceOptions;
      +
      +    };
      +
      +    attachOnPosition = function() {
      +
      +      var item,
      +          op = s._iO.onposition;
      + +
    • + + +
    • +
      + +
      + +
      +

      attach onposition things, if any, now.

      + +
      + +
      +      if (op) {
      +
      +        for (item in op) {
      +          if (op.hasOwnProperty(item)) {
      +            s.onPosition(parseInt(item, 10), op[item]);
      +          }
      +        }
      +
      +      }
      +
      +    };
      +
      +    detachOnPosition = function() {
      +
      +      var item,
      +          op = s._iO.onposition;
      + +
    • + + +
    • +
      + +
      + +
      +

      detach any onposition()-style listeners.

      + +
      + +
      +      if (op) {
      +
      +        for (item in op) {
      +          if (op.hasOwnProperty(item)) {
      +            s.clearOnPosition(parseInt(item, 10));
      +          }
      +        }
      +
      +      }
      +
      +    };
      +
      +    start_html5_timer = function() {
      +
      +      if (s.isHTML5) {
      +        startTimer(s);
      +      }
      +
      +    };
      +
      +    stop_html5_timer = function() {
      +
      +      if (s.isHTML5) {
      +        stopTimer(s);
      +      }
      +
      +    };
      +
      +    resetProperties = function(retainPosition) {
      +
      +      if (!retainPosition) {
      +        onPositionItems = [];
      +        onPositionFired = 0;
      +      }
      +
      +      onplay_called = false;
      +
      +      s._hasTimer = null;
      +      s._a = null;
      +      s._html5_canplay = false;
      +      s.bytesLoaded = null;
      +      s.bytesTotal = null;
      +      s.duration = (s._iO && s._iO.duration ? s._iO.duration : null);
      +      s.durationEstimate = null;
      +      s.buffered = [];
      + +
    • + + +
    • +
      + +
      + +
      +

      legacy: 1D array

      + +
      + +
            s.eqData = [];
      +
      +      s.eqData.left = [];
      +      s.eqData.right = [];
      +
      +      s.failures = 0;
      +      s.isBuffering = false;
      +      s.instanceOptions = {};
      +      s.instanceCount = 0;
      +      s.loaded = false;
      +      s.metadata = {};
      + +
    • + + +
    • +
      + +
      + +
      +

      0 = uninitialised, 1 = loading, 2 = failed/error, 3 = loaded/success

      + +
      + +
            s.readyState = 0;
      +
      +      s.muted = false;
      +      s.paused = false;
      +
      +      s.peakData = {
      +        left: 0,
      +        right: 0
      +      };
      +
      +      s.waveformData = {
      +        left: [],
      +        right: []
      +      };
      +
      +      s.playState = 0;
      +      s.position = null;
      +
      +      s.id3 = {};
      +
      +    };
      +
      +    resetProperties();
      +
      +    /**
      +     * Pseudo-private SMSound internals
      +     * --------------------------------
      +     */
      +
      +    this._onTimer = function(bForce) {
      +
      +      /**
      +       * HTML5-only _whileplaying() etc.
      +       * called from both HTML5 native events, and polling/interval-based timers
      +       * mimics flash and fires only when time/duration change, so as to be polling-friendly
      +       */
      +
      +      var duration, isNew = false, time, x = {};
      +
      +      if (s._hasTimer || bForce) {
      + +
    • + + +
    • +
      + +
      + +
      +

      TODO: May not need to track readyState (1 = loading)

      + +
      + +
      +        if (s._a && (bForce || ((s.playState > 0 || s.readyState === 1) && !s.paused))) {
      +
      +          duration = s._get_html5_duration();
      +
      +          if (duration !== lastHTML5State.duration) {
      +
      +            lastHTML5State.duration = duration;
      +            s.duration = duration;
      +            isNew = true;
      +
      +          }
      + +
    • + + +
    • +
      + +
      + +
      +

      TODO: investigate why this goes wack if not set/re-set each time.

      + +
      + +
                s.durationEstimate = s.duration;
      +
      +          time = (s._a.currentTime * msecScale || 0);
      +
      +          if (time !== lastHTML5State.time) {
      +
      +            lastHTML5State.time = time;
      +            isNew = true;
      +
      +          }
      +
      +          if (isNew || bForce) {
      +
      +            s._whileplaying(time,x,x,x,x);
      +
      +          }
      +
      +        }/* else {
      + +
    • + + +
    • +
      + +
      + +
      +

      sm2._wD('_onTimer: Warn for "'+s.id+'": '+(!s._a?'Could not find element. ':'')+(s.playState === 0?'playState bad, 0?':'playState = '+s.playState+', OK'));

      + +
      + +
      +          return false;
      +
      +        }*/
      +
      +        return isNew;
      +
      +      }
      +
      +    };
      +
      +    this._get_html5_duration = function() {
      +
      +      var instanceOptions = s._iO,
      + +
    • + + +
    • +
      + +
      + +
      +

      if audio object exists, use its duration - else, instance option duration (if provided - it's a hack, really, and should be retired) OR null

      + +
      + +
                d = (s._a && s._a.duration ? s._a.duration*msecScale : (instanceOptions && instanceOptions.duration ? instanceOptions.duration : null)),
      +          result = (d && !isNaN(d) && d !== Infinity ? d : null);
      +
      +      return result;
      +
      +    };
      +
      +    this._apply_loop = function(a, nLoops) {
      +
      +      /**
      +       * boolean instead of "loop", for webkit? - spec says string. http://www.w3.org/TR/html-markup/audio.html#audio.attrs.loop
      +       * note that loop is either off or infinite under HTML5, unlike Flash which allows arbitrary loop counts to be specified.
      +       */
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            if (!a.loop && nLoops > 1) {
      +        sm2._wD('Note: Native HTML5 looping is infinite.', 1);
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +      a.loop = (nLoops > 1 ? 'loop' : '');
      +
      +    };
      +
      +    this._setup_html5 = function(oOptions) {
      +
      +      var instanceOptions = mixin(s._iO, oOptions),
      +          a = useGlobalHTML5Audio ? globalHTML5Audio : s._a,
      +          dURL = decodeURI(instanceOptions.url),
      +          sameURL;
      +
      +      /**
      +       * "First things first, I, Poppa..." (reset the previous state of the old sound, if playing)
      +       * Fixes case with devices that can only play one sound at a time
      +       * Otherwise, other sounds in mid-play will be terminated without warning and in a stuck state
      +       */
      +
      +      if (useGlobalHTML5Audio) {
      +
      +        if (dURL === decodeURI(lastGlobalHTML5URL)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      global HTML5 audio: re-use of URL

      + +
      + +
                sameURL = true;
      +        }
      +
      +      } else if (dURL === decodeURI(lastURL)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      options URL is the same as the "last" URL, and we used (loaded) it

      + +
      + +
              sameURL = true;
      +
      +      }
      +
      +      if (a) {
      +
      +        if (a._s) {
      +
      +          if (useGlobalHTML5Audio) {
      +
      +            if (a._s && a._s.playState && !sameURL) {
      + +
    • + + +
    • +
      + +
      + +
      +

      global HTML5 audio case, and loading a new URL. stop the currently-playing one.

      + +
      + +
                    a._s.stop();
      +
      +            }
      +
      +          } else if (!useGlobalHTML5Audio && dURL === decodeURI(lastURL)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      non-global HTML5 reuse case: same url, ignore request

      + +
      + +
                  s._apply_loop(a, instanceOptions.loops);
      +
      +            return a;
      +
      +          }
      +
      +        }
      +
      +        if (!sameURL) {
      + +
    • + + +
    • +
      + +
      + +
      +

      don't retain onPosition() stuff with new URLs.

      + +
      + +
      +          if (lastURL) {
      +            resetProperties(false);
      +          }
      + +
    • + + +
    • +
      + +
      + +
      +

      assign new HTML5 URL

      + +
      + +
      +          a.src = instanceOptions.url;
      +
      +          s.url = instanceOptions.url;
      +
      +          lastURL = instanceOptions.url;
      +
      +          lastGlobalHTML5URL = instanceOptions.url;
      +
      +          a._called_load = false;
      +
      +        }
      +
      +      } else {
      +
      +        if (instanceOptions.autoLoad || instanceOptions.autoPlay) {
      +
      +          s._a = new Audio(instanceOptions.url);
      +          s._a.load();
      +
      +        } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      null for stupid Opera 9.64 case

      + +
      + +
                s._a = (isOpera && opera.version() < 10 ? new Audio(null) : new Audio());
      +
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      assign local reference

      + +
      + +
              a = s._a;
      +
      +        a._called_load = false;
      +
      +        if (useGlobalHTML5Audio) {
      +
      +          globalHTML5Audio = a;
      +
      +        }
      +
      +      }
      +
      +      s.isHTML5 = true;
      + +
    • + + +
    • +
      + +
      + +
      +

      store a ref on the track

      + +
      + +
            s._a = a;
      + +
    • + + +
    • +
      + +
      + +
      +

      store a ref on the audio

      + +
      + +
            a._s = s;
      +
      +      add_html5_events();
      +
      +      s._apply_loop(a, instanceOptions.loops);
      +
      +      if (instanceOptions.autoLoad || instanceOptions.autoPlay) {
      +
      +        s.load();
      +
      +      } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      early HTML5 implementation (non-standard)

      + +
      + +
              a.autobuffer = false;
      + +
    • + + +
    • +
      + +
      + +
      +

      standard ('none' is also an option.)

      + +
      + +
              a.preload = 'auto';
      +
      +      }
      +
      +      return a;
      +
      +    };
      +
      +    add_html5_events = function() {
      +
      +      if (s._a._added_events) {
      +        return false;
      +      }
      +
      +      var f;
      +
      +      function add(oEvt, oFn, bCapture) {
      +        return s._a ? s._a.addEventListener(oEvt, oFn, bCapture||false) : null;
      +      }
      +
      +      s._a._added_events = true;
      +
      +      for (f in html5_events) {
      +        if (html5_events.hasOwnProperty(f)) {
      +          add(f, html5_events[f]);
      +        }
      +      }
      +
      +      return true;
      +
      +    };
      +
      +    remove_html5_events = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      Remove event listeners

      + +
      + +
      +      var f;
      +
      +      function remove(oEvt, oFn, bCapture) {
      +        return (s._a ? s._a.removeEventListener(oEvt, oFn, bCapture||false) : null);
      +      }
      +
      +      sm2._wD(s.id + ': Removing event listeners');
      +      s._a._added_events = false;
      +
      +      for (f in html5_events) {
      +        if (html5_events.hasOwnProperty(f)) {
      +          remove(f, html5_events[f]);
      +        }
      +      }
      +
      +    };
      +
      +    /**
      +     * Pseudo-private event internals
      +     * ------------------------------
      +     */
      +
      +    this._onload = function(nSuccess) {
      +
      +      var fN,
      + +
    • + + +
    • +
      + +
      + +
      +

      check for duration to prevent false positives from flash 8 when loading from cache.

      + +
      + +
                loadOK = !!nSuccess || (!s.isHTML5 && fV === 8 && s.duration);
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            fN = s.id + ': ';
      +      sm2._wD(fN + (loadOK ? 'onload()' : 'Failed to load / invalid sound?' + (!s.duration ? ' Zero-length duration reported.' : ' -') + ' (' + s.url + ')'), (loadOK ? 1 : 2));
      +      if (!loadOK && !s.isHTML5) {
      +        if (sm2.sandbox.noRemote === true) {
      +          sm2._wD(fN + str('noNet'), 1);
      +        }
      +        if (sm2.sandbox.noLocal === true) {
      +          sm2._wD(fN + str('noLocal'), 1);
      +        }
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +      s.loaded = loadOK;
      +      s.readyState = loadOK?3:2;
      +      s._onbufferchange(0);
      +
      +      if (s._iO.onload) {
      +        wrapCallback(s, function() {
      +          s._iO.onload.apply(s, [loadOK]);
      +        });
      +      }
      +
      +      return true;
      +
      +    };
      +
      +    this._onbufferchange = function(nIsBuffering) {
      +
      +      if (s.playState === 0) {
      + +
    • + + +
    • +
      + +
      + +
      +

      ignore if not playing

      + +
      + +
              return false;
      +      }
      +
      +      if ((nIsBuffering && s.isBuffering) || (!nIsBuffering && !s.isBuffering)) {
      +        return false;
      +      }
      +
      +      s.isBuffering = (nIsBuffering === 1);
      +      if (s._iO.onbufferchange) {
      +        sm2._wD(s.id + ': Buffer state change: ' + nIsBuffering);
      +        s._iO.onbufferchange.apply(s);
      +      }
      +
      +      return true;
      +
      +    };
      +
      +    /**
      +     * Playback may have stopped due to buffering, or related reason.
      +     * This state can be encountered on iOS < 6 when auto-play is blocked.
      +     */
      +
      +    this._onsuspend = function() {
      +
      +      if (s._iO.onsuspend) {
      +        sm2._wD(s.id + ': Playback suspended');
      +        s._iO.onsuspend.apply(s);
      +      }
      +
      +      return true;
      +
      +    };
      +
      +    /**
      +     * flash 9/movieStar + RTMP-only method, should fire only once at most
      +     * at this point we just recreate failed sounds rather than trying to reconnect
      +     */
      +
      +    this._onfailure = function(msg, level, code) {
      +
      +      s.failures++;
      +      sm2._wD(s.id + ': Failures = ' + s.failures);
      +
      +      if (s._iO.onfailure && s.failures === 1) {
      +        s._iO.onfailure(s, msg, level, code);
      +      } else {
      +        sm2._wD(s.id + ': Ignoring failure');
      +      }
      +
      +    };
      +
      +    this._onfinish = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      store local copy before it gets trashed...

      + +
      + +
            var io_onfinish = s._iO.onfinish;
      +
      +      s._onbufferchange(0);
      +      s._resetOnPosition(0);
      + +
    • + + +
    • +
      + +
      + +
      +

      reset some state items

      + +
      + +
            if (s.instanceCount) {
      +
      +        s.instanceCount--;
      +
      +        if (!s.instanceCount) {
      + +
    • + + +
    • +
      + +
      + +
      +

      remove onPosition listeners, if any

      + +
      + +
                detachOnPosition();
      + +
    • + + +
    • +
      + +
      + +
      +

      reset instance options

      + +
      + +
                s.playState = 0;
      +          s.paused = false;
      +          s.instanceCount = 0;
      +          s.instanceOptions = {};
      +          s._iO = {};
      +          stop_html5_timer();
      + +
    • + + +
    • +
      + +
      + +
      +

      reset position, too

      + +
      + +
                if (s.isHTML5) {
      +            s.position = 0;
      +          }
      +
      +        }
      +
      +        if (!s.instanceCount || s._iO.multiShotEvents) {
      + +
    • + + +
    • +
      + +
      + +
      +

      fire onfinish for last, or every instance

      + +
      + +
                if (io_onfinish) {
      +            sm2._wD(s.id + ': onfinish()');
      +            wrapCallback(s, function() {
      +              io_onfinish.apply(s);
      +            });
      +          }
      +        }
      +
      +      }
      +
      +    };
      +
      +    this._whileloading = function(nBytesLoaded, nBytesTotal, nDuration, nBufferLength) {
      +
      +      var instanceOptions = s._iO;
      +
      +      s.bytesLoaded = nBytesLoaded;
      +      s.bytesTotal = nBytesTotal;
      +      s.duration = Math.floor(nDuration);
      +      s.bufferLength = nBufferLength;
      +
      +      if (!s.isHTML5 && !instanceOptions.isMovieStar) {
      +
      +        if (instanceOptions.duration) {
      + +
    • + + +
    • +
      + +
      + +
      +

      use duration from options, if specified and larger. nobody should be specifying duration in options, actually, and it should be retired.

      + +
      + +
                s.durationEstimate = (s.duration > instanceOptions.duration) ? s.duration : instanceOptions.duration;
      +        } else {
      +          s.durationEstimate = parseInt((s.bytesTotal / s.bytesLoaded) * s.duration, 10);
      +        }
      +
      +      } else {
      +
      +        s.durationEstimate = s.duration;
      +
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      for flash, reflect sequential-load-style buffering

      + +
      + +
            if (!s.isHTML5) {
      +        s.buffered = [{
      +          'start': 0,
      +          'end': s.duration
      +        }];
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      allow whileloading to fire even if "load" fired under HTML5, due to HTTP range/partials

      + +
      + +
            if ((s.readyState !== 3 || s.isHTML5) && instanceOptions.whileloading) {
      +        instanceOptions.whileloading.apply(s);
      +      }
      +
      +    };
      +
      +    this._whileplaying = function(nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) {
      +
      +      var instanceOptions = s._iO,
      +          eqLeft;
      +
      +      if (isNaN(nPosition) || nPosition === null) {
      + +
    • + + +
    • +
      + +
      + +
      +

      flash safety net

      + +
      + +
              return false;
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      Safari HTML5 play() may return small -ve values when starting from position: 0, eg. -50.120396875. Unexpected/invalid per W3, I think. Normalize to 0.

      + +
      + +
            s.position = Math.max(0, nPosition);
      +
      +      s._processOnPosition();
      +
      +      if (!s.isHTML5 && fV > 8) {
      +
      +        if (instanceOptions.usePeakData && oPeakData !== _undefined && oPeakData) {
      +          s.peakData = {
      +            left: oPeakData.leftPeak,
      +            right: oPeakData.rightPeak
      +          };
      +        }
      +
      +        if (instanceOptions.useWaveformData && oWaveformDataLeft !== _undefined && oWaveformDataLeft) {
      +          s.waveformData = {
      +            left: oWaveformDataLeft.split(','),
      +            right: oWaveformDataRight.split(',')
      +          };
      +        }
      +
      +        if (instanceOptions.useEQData) {
      +          if (oEQData !== _undefined && oEQData && oEQData.leftEQ) {
      +            eqLeft = oEQData.leftEQ.split(',');
      +            s.eqData = eqLeft;
      +            s.eqData.left = eqLeft;
      +            if (oEQData.rightEQ !== _undefined && oEQData.rightEQ) {
      +              s.eqData.right = oEQData.rightEQ.split(',');
      +            }
      +          }
      +        }
      +
      +      }
      +
      +      if (s.playState === 1) {
      + +
    • + + +
    • +
      + +
      + +
      +

      special case/hack: ensure buffering is false if loading from cache (and not yet started)

      + +
      + +
              if (!s.isHTML5 && fV === 8 && !s.position && s.isBuffering) {
      +          s._onbufferchange(0);
      +        }
      +
      +        if (instanceOptions.whileplaying) {
      + +
    • + + +
    • +
      + +
      + +
      +

      flash may call after actual finish

      + +
      + +
                instanceOptions.whileplaying.apply(s);
      +        }
      +
      +      }
      +
      +      return true;
      +
      +    };
      +
      +    this._oncaptiondata = function(oData) {
      +
      +      /**
      +       * internal: flash 9 + NetStream (MovieStar/RTMP-only) feature
      +       *
      +       * @param {object} oData
      +       */
      +
      +      sm2._wD(s.id + ': Caption data received.');
      +
      +      s.captiondata = oData;
      +
      +      if (s._iO.oncaptiondata) {
      +        s._iO.oncaptiondata.apply(s, [oData]);
      +      }
      +
      +    };
      +
      +    this._onmetadata = function(oMDProps, oMDData) {
      +
      +      /**
      +       * internal: flash 9 + NetStream (MovieStar/RTMP-only) feature
      +       * RTMP may include song title, MovieStar content may include encoding info
      +       *
      +       * @param {array} oMDProps (names)
      +       * @param {array} oMDData (values)
      +       */
      +
      +      sm2._wD(s.id + ': Metadata received.');
      +
      +      var oData = {}, i, j;
      +
      +      for (i = 0, j = oMDProps.length; i < j; i++) {
      +        oData[oMDProps[i]] = oMDData[i];
      +      }
      +      s.metadata = oData;
      +
      +      if (s._iO.onmetadata) {
      +        s._iO.onmetadata.apply(s);
      +      }
      +
      +    };
      +
      +    this._onid3 = function(oID3Props, oID3Data) {
      +
      +      /**
      +       * internal: flash 8 + flash 9 ID3 feature
      +       * may include artist, song title etc.
      +       *
      +       * @param {array} oID3Props (names)
      +       * @param {array} oID3Data (values)
      +       */
      +
      +      sm2._wD(s.id + ': ID3 data received.');
      +
      +      var oData = [], i, j;
      +
      +      for (i = 0, j = oID3Props.length; i < j; i++) {
      +        oData[oID3Props[i]] = oID3Data[i];
      +      }
      +      s.id3 = mixin(s.id3, oData);
      +
      +      if (s._iO.onid3) {
      +        s._iO.onid3.apply(s);
      +      }
      +
      +    };
      + +
    • + + +
    • +
      + +
      + +
      +

      flash/RTMP-only

      + +
      + +
      +    this._onconnect = function(bSuccess) {
      +
      +      bSuccess = (bSuccess === 1);
      +      sm2._wD(s.id + ': ' + (bSuccess ? 'Connected.' : 'Failed to connect? - ' + s.url), (bSuccess ? 1 : 2));
      +      s.connected = bSuccess;
      +
      +      if (bSuccess) {
      +
      +        s.failures = 0;
      +
      +        if (idCheck(s.id)) {
      +          if (s.getAutoPlay()) {
      + +
    • + + +
    • +
      + +
      + +
      +

      only update the play state if auto playing

      + +
      + +
                  s.play(_undefined, s.getAutoPlay());
      +          } else if (s._iO.autoLoad) {
      +            s.load();
      +          }
      +        }
      +
      +        if (s._iO.onconnect) {
      +          s._iO.onconnect.apply(s, [bSuccess]);
      +        }
      +
      +      }
      +
      +    };
      +
      +    this._ondataerror = function(sError) {
      + +
    • + + +
    • +
      + +
      + +
      +

      flash 9 wave/eq data handler +hack: called at start, and end from flash at/after onfinish()

      + +
      + +
            if (s.playState > 0) {
      +        sm2._wD(s.id + ': Data error: ' + sError);
      +        if (s._iO.ondataerror) {
      +          s._iO.ondataerror.apply(s);
      +        }
      +      }
      +
      +    };
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
          this._debug();
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +  }; // SMSound()
      +
      +  /**
      +   * Private SoundManager internals
      +   * ------------------------------
      +   */
      +
      +  getDocument = function() {
      +
      +    return (doc.body || doc.getElementsByTagName('div')[0]);
      +
      +  };
      +
      +  id = function(sID) {
      +
      +    return doc.getElementById(sID);
      +
      +  };
      +
      +  mixin = function(oMain, oAdd) {
      + +
    • + + +
    • +
      + +
      + +
      +

      non-destructive merge

      + +
      + +
          var o1 = (oMain || {}), o2, o;
      + +
    • + + +
    • +
      + +
      + +
      +

      if unspecified, o2 is the default options object

      + +
      + +
          o2 = (oAdd === _undefined ? sm2.defaultOptions : oAdd);
      +
      +    for (o in o2) {
      +
      +      if (o2.hasOwnProperty(o) && o1[o] === _undefined) {
      +
      +        if (typeof o2[o] !== 'object' || o2[o] === null) {
      + +
    • + + +
    • +
      + +
      + +
      +

      assign directly

      + +
      + +
                o1[o] = o2[o];
      +
      +        } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      recurse through o2

      + +
      + +
                o1[o] = mixin(o1[o], o2[o]);
      +
      +        }
      +
      +      }
      +
      +    }
      +
      +    return o1;
      +
      +  };
      +
      +  wrapCallback = function(oSound, callback) {
      +
      +    /**
      +     * 03/03/2013: Fix for Flash Player 11.6.602.171 + Flash 8 (flashVersion = 8) SWF issue
      +     * setTimeout() fix for certain SMSound callbacks like onload() and onfinish(), where subsequent calls like play() and load() fail when Flash Player 11.6.602.171 is installed, and using soundManager with flashVersion = 8 (which is the default).
      +     * Not sure of exact cause. Suspect race condition and/or invalid (NaN-style) position argument trickling down to the next JS -> Flash _start() call, in the play() case.
      +     * Fix: setTimeout() to yield, plus safer null / NaN checking on position argument provided to Flash.
      +     * https://getsatisfaction.com/schillmania/topics/recent_chrome_update_seems_to_have_broken_my_sm2_audio_player
      +     */
      +    if (!oSound.isHTML5 && fV === 8) {
      +      window.setTimeout(callback, 0);
      +    } else {
      +      callback();
      +    }
      +
      +  };
      + +
    • + + +
    • +
      + +
      + +
      +

      additional soundManager properties that soundManager.setup() will accept

      + +
      + +
      +  extraOptions = {
      +    'onready': 1,
      +    'ontimeout': 1,
      +    'defaultOptions': 1,
      +    'flash9Options': 1,
      +    'movieStarOptions': 1
      +  };
      +
      +  assign = function(o, oParent) {
      +
      +    /**
      +     * recursive assignment of properties, soundManager.setup() helper
      +     * allows property assignment based on whitelist
      +     */
      +
      +    var i,
      +        result = true,
      +        hasParent = (oParent !== _undefined),
      +        setupOptions = sm2.setupOptions,
      +        bonusOptions = extraOptions;
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
    • + + +
    • +
      + +
      + +
      +

      if soundManager.setup() called, show accepted parameters.

      + +
      + +
      +    if (o === _undefined) {
      +
      +      result = [];
      +
      +      for (i in setupOptions) {
      +
      +        if (setupOptions.hasOwnProperty(i)) {
      +          result.push(i);
      +        }
      +
      +      }
      +
      +      for (i in bonusOptions) {
      +
      +        if (bonusOptions.hasOwnProperty(i)) {
      +
      +          if (typeof sm2[i] === 'object') {
      +
      +            result.push(i+': {...}');
      +
      +          } else if (sm2[i] instanceof Function) {
      +
      +            result.push(i+': function() {...}');
      +
      +          } else {
      +
      +            result.push(i);
      +
      +          }
      +
      +        }
      +
      +      }
      +
      +      sm2._wD(str('setup', result.join(', ')));
      +
      +      return false;
      +
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +    for (i in o) {
      +
      +      if (o.hasOwnProperty(i)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      if not an {object} we want to recurse through...

      + +
      + +
      +        if (typeof o[i] !== 'object' || o[i] === null || o[i] instanceof Array || o[i] instanceof RegExp) {
      + +
    • + + +
    • +
      + +
      + +
      +

      check "allowed" options

      + +
      + +
      +          if (hasParent && bonusOptions[oParent] !== _undefined) {
      + +
    • + + +
    • +
      + +
      + +
      +

      valid recursive / nested object option, eg., { defaultOptions: { volume: 50 } }

      + +
      + +
                  sm2[oParent][i] = o[i];
      +
      +          } else if (setupOptions[i] !== _undefined) {
      + +
    • + + +
    • +
      + +
      + +
      +

      special case: assign to setupOptions object, which soundManager property references

      + +
      + +
                  sm2.setupOptions[i] = o[i];
      + +
    • + + +
    • +
      + +
      + +
      +

      assign directly to soundManager, too

      + +
      + +
                  sm2[i] = o[i];
      +
      +          } else if (bonusOptions[i] === _undefined) {
      + +
    • + + +
    • +
      + +
      + +
      +

      invalid or disallowed parameter. complain.

      + +
      + +
                  complain(str((sm2[i] === _undefined ? 'setupUndef' : 'setupError'), i), 2);
      +
      +            result = false;
      +
      +          } else {
      +
      +            /**
      +             * valid extraOptions (bonusOptions) parameter.
      +             * is it a method, like onready/ontimeout? call it.
      +             * multiple parameters should be in an array, eg. soundManager.setup({onready: [myHandler, myScope]});
      +             */
      +
      +            if (sm2[i] instanceof Function) {
      +
      +              sm2[i].apply(sm2, (o[i] instanceof Array? o[i] : [o[i]]));
      +
      +            } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      good old-fashioned direct assignment

      + +
      + +
                    sm2[i] = o[i];
      +
      +            }
      +
      +          }
      +
      +        } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      recursion case, eg., { defaultOptions: { ... } }

      + +
      + +
      +          if (bonusOptions[i] === _undefined) {
      + +
    • + + +
    • +
      + +
      + +
      +

      invalid or disallowed parameter. complain.

      + +
      + +
                  complain(str((sm2[i] === _undefined ? 'setupUndef' : 'setupError'), i), 2);
      +
      +            result = false;
      +
      +          } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      recurse through object

      + +
      + +
                  return assign(o[i], i);
      +
      +          }
      +
      +        }
      +
      +      }
      +
      +    }
      +
      +    return result;
      +
      +  };
      +
      +  function preferFlashCheck(kind) {
      + +
    • + + +
    • +
      + +
      + +
      +

      whether flash should play a given type

      + +
      + +
          return (sm2.preferFlash && hasFlash && !sm2.ignoreFlash && (sm2.flash[kind] !== _undefined && sm2.flash[kind]));
      +
      +  }
      +
      +  /**
      +   * Internal DOM2-level event helpers
      +   * ---------------------------------
      +   */
      +
      +  event = (function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      normalize event methods

      + +
      + +
          var old = (window.attachEvent),
      +    evt = {
      +      add: (old?'attachEvent':'addEventListener'),
      +      remove: (old?'detachEvent':'removeEventListener')
      +    };
      + +
    • + + +
    • +
      + +
      + +
      +

      normalize "on" event prefix, optional capture argument

      + +
      + +
          function getArgs(oArgs) {
      +
      +      var args = slice.call(oArgs),
      +          len = args.length;
      +
      +      if (old) {
      + +
    • + + +
    • +
      + +
      + +
      +

      prefix

      + +
      + +
              args[1] = 'on' + args[1];
      +        if (len > 3) {
      + +
    • + + +
    • +
      + +
      + +
      +

      no capture

      + +
      + +
                args.pop();
      +        }
      +      } else if (len === 3) {
      +        args.push(false);
      +      }
      +
      +      return args;
      +
      +    }
      +
      +    function apply(args, sType) {
      + +
    • + + +
    • +
      + +
      + +
      +

      normalize and call the event method, with the proper arguments

      + +
      + +
            var element = args.shift(),
      +          method = [evt[sType]];
      +
      +      if (old) {
      + +
    • + + +
    • +
      + +
      + +
      +

      old IE can't do apply().

      + +
      + +
              element[method](args[0], args[1]);
      +      } else {
      +        element[method].apply(element, args);
      +      }
      +
      +    }
      +
      +    function add() {
      +
      +      apply(getArgs(arguments), 'add');
      +
      +    }
      +
      +    function remove() {
      +
      +      apply(getArgs(arguments), 'remove');
      +
      +    }
      +
      +    return {
      +      'add': add,
      +      'remove': remove
      +    };
      +
      +  }());
      +
      +  /**
      +   * Internal HTML5 event handling
      +   * -----------------------------
      +   */
      +
      +  function html5_event(oFn) {
      + +
    • + + +
    • +
      + +
      + +
      +

      wrap html5 event handlers so we don't call them on destroyed and/or unloaded sounds

      + +
      + +
      +    return function(e) {
      +
      +      var s = this._s,
      +          result;
      +
      +      if (!s || !s._a) {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
              if (s && s.id) {
      +          sm2._wD(s.id + ': Ignoring ' + e.type);
      +        } else {
      +          sm2._wD(h5 + 'Ignoring ' + e.type);
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
              result = null;
      +      } else {
      +        result = oFn.call(this, e);
      +      }
      +
      +      return result;
      +
      +    };
      +
      +  }
      +
      +  html5_events = {
      + +
    • + + +
    • +
      + +
      + +
      +

      HTML5 event-name-to-handler map

      + +
      + +
      +    abort: html5_event(function() {
      +
      +      sm2._wD(this._s.id + ': abort');
      +
      +    }),
      + +
    • + + +
    • +
      + +
      + +
      +

      enough has loaded to play

      + +
      + +
      +    canplay: html5_event(function() {
      +
      +      var s = this._s,
      +          position1K;
      +
      +      if (s._html5_canplay) {
      + +
    • + + +
    • +
      + +
      + +
      +

      this event has already fired. ignore.

      + +
      + +
              return true;
      +      }
      +
      +      s._html5_canplay = true;
      +      sm2._wD(s.id + ': canplay');
      +      s._onbufferchange(0);
      + +
    • + + +
    • +
      + +
      + +
      +

      position according to instance options

      + +
      + +
            position1K = (s._iO.position !== _undefined && !isNaN(s._iO.position)?s._iO.position/msecScale:null);
      + +
    • + + +
    • +
      + +
      + +
      +

      set the position if position was set before the sound loaded

      + +
      + +
            if (s.position && this.currentTime !== position1K) {
      +        sm2._wD(s.id + ': canplay: Setting position to ' + position1K);
      +        try {
      +          this.currentTime = position1K;
      +        } catch(ee) {
      +          sm2._wD(s.id + ': canplay: Setting position of ' + position1K + ' failed: ' + ee.message, 2);
      +        }
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      hack for HTML5 from/to case

      + +
      + +
            if (s._iO._oncanplay) {
      +        s._iO._oncanplay();
      +      }
      +
      +    }),
      +
      +    canplaythrough: html5_event(function() {
      +
      +      var s = this._s;
      +
      +      if (!s.loaded) {
      +        s._onbufferchange(0);
      +        s._whileloading(s.bytesLoaded, s.bytesTotal, s._get_html5_duration());
      +        s._onload(true);
      +      }
      +
      +    }),
      + +
    • + + +
    • +
      + +
      + +
      +

      TODO: Reserved for potential use

      + +
      + +
          /*
      +    emptied: html5_event(function() {
      +
      +      sm2._wD(this._s.id + ': emptied');
      +
      +    }),
      +    */
      +
      +    ended: html5_event(function() {
      +
      +      var s = this._s;
      +
      +      sm2._wD(s.id + ': ended');
      +
      +      s._onfinish();
      +
      +    }),
      +
      +    error: html5_event(function() {
      +
      +      sm2._wD(this._s.id + ': HTML5 error, code ' + this.error.code);
      +      /**
      +       * HTML5 error codes, per W3C
      +       * Error 1: Client aborted download at user's request.
      +       * Error 2: Network error after load started.
      +       * Error 3: Decoding issue.
      +       * Error 4: Media (audio file) not supported.
      +       * Reference: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#error-codes
      +       */
      + +
    • + + +
    • +
      + +
      + +
      +

      call load with error state?

      + +
      + +
            this._s._onload(false);
      +
      +    }),
      +
      +    loadeddata: html5_event(function() {
      +
      +      var s = this._s;
      +
      +      sm2._wD(s.id + ': loadeddata');
      + +
    • + + +
    • +
      + +
      + +
      +

      safari seems to nicely report progress events, eventually totalling 100%

      + +
      + +
            if (!s._loaded && !isSafari) {
      +        s.duration = s._get_html5_duration();
      +      }
      +
      +    }),
      +
      +    loadedmetadata: html5_event(function() {
      +
      +      sm2._wD(this._s.id + ': loadedmetadata');
      +
      +    }),
      +
      +    loadstart: html5_event(function() {
      +
      +      sm2._wD(this._s.id + ': loadstart');
      + +
    • + + +
    • +
      + +
      + +
      +

      assume buffering at first

      + +
      + +
            this._s._onbufferchange(1);
      +
      +    }),
      +
      +    play: html5_event(function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      sm2._wD(this._s.id + ': play()'); +once play starts, no buffering

      + +
      + +
            this._s._onbufferchange(0);
      +
      +    }),
      +
      +    playing: html5_event(function() {
      +
      +      sm2._wD(this._s.id + ': playing');
      + +
    • + + +
    • +
      + +
      + +
      +

      once play starts, no buffering

      + +
      + +
            this._s._onbufferchange(0);
      +
      +    }),
      +
      +    progress: html5_event(function(e) {
      + +
    • + + +
    • +
      + +
      + +
      +

      note: can fire repeatedly after "loaded" event, due to use of HTTP range/partials

      + +
      + +
      +      var s = this._s,
      +          i, j, progStr, buffered = 0,
      +          isProgress = (e.type === 'progress'),
      +          ranges = e.target.buffered,
      + +
    • + + +
    • +
      + +
      + +
      +

      firefox 3.6 implements e.loaded/total (bytes)

      + +
      + +
                loaded = (e.loaded||0),
      +          total = (e.total||1);
      + +
    • + + +
    • +
      + +
      + +
      +

      reset the "buffered" (loaded byte ranges) array

      + +
      + +
            s.buffered = [];
      +
      +      if (ranges && ranges.length) {
      + +
    • + + +
    • +
      + +
      + +
      +

      if loaded is 0, try TimeRanges implementation as % of load +https://developer.mozilla.org/en/DOM/TimeRanges

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      re-build "buffered" array +HTML5 returns seconds. SM2 API uses msec for setPosition() etc., whether Flash or HTML5.

      + +
      + +
              for (i=0, j=ranges.length; i<j; i++) {
      +          s.buffered.push({
      +            'start': ranges.start(i) * msecScale,
      +            'end': ranges.end(i) * msecScale
      +          });
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      use the last value locally

      + +
      + +
              buffered = (ranges.end(0) - ranges.start(0)) * msecScale;
      + +
    • + + +
    • +
      + +
      + +
      +

      linear case, buffer sum; does not account for seeking and HTTP partials / byte ranges

      + +
      + +
              loaded = Math.min(1, buffered/(e.target.duration*msecScale));
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
              if (isProgress && ranges.length > 1) {
      +          progStr = [];
      +          j = ranges.length;
      +          for (i=0; i<j; i++) {
      +            progStr.push(e.target.buffered.start(i)*msecScale +'-'+ e.target.buffered.end(i)*msecScale);
      +          }
      +          sm2._wD(this._s.id + ': progress, timeRanges: ' + progStr.join(', '));
      +        }
      +
      +        if (isProgress && !isNaN(loaded)) {
      +          sm2._wD(this._s.id + ': progress, ' + Math.floor(loaded*100) + '% loaded');
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +      }
      +
      +      if (!isNaN(loaded)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      if progress, likely not buffering

      + +
      + +
              s._onbufferchange(0);
      + +
    • + + +
    • +
      + +
      + +
      +

      TODO: prevent calls with duplicate values.

      + +
      + +
              s._whileloading(loaded, total, s._get_html5_duration());
      +        if (loaded && total && loaded === total) {
      + +
    • + + +
    • +
      + +
      + +
      +

      in case "onload" doesn't fire (eg. gecko 1.9.2)

      + +
      + +
                html5_events.canplaythrough.call(this, e);
      +        }
      +
      +      }
      +
      +    }),
      +
      +    ratechange: html5_event(function() {
      +
      +      sm2._wD(this._s.id + ': ratechange');
      +
      +    }),
      +
      +    suspend: html5_event(function(e) {
      + +
    • + + +
    • +
      + +
      + +
      +

      download paused/stopped, may have finished (eg. onload)

      + +
      + +
            var s = this._s;
      +
      +      sm2._wD(this._s.id + ': suspend');
      +      html5_events.progress.call(this, e);
      +      s._onsuspend();
      +
      +    }),
      +
      +    stalled: html5_event(function() {
      +
      +      sm2._wD(this._s.id + ': stalled');
      +
      +    }),
      +
      +    timeupdate: html5_event(function() {
      +
      +      this._s._onTimer();
      +
      +    }),
      +
      +    waiting: html5_event(function() {
      +
      +      var s = this._s;
      + +
    • + + +
    • +
      + +
      + +
      +

      see also: seeking

      + +
      + +
            sm2._wD(this._s.id + ': waiting');
      + +
    • + + +
    • +
      + +
      + +
      +

      playback faster than download rate, etc.

      + +
      + +
            s._onbufferchange(1);
      +
      +    })
      +
      +  };
      +
      +  html5OK = function(iO) {
      + +
    • + + +
    • +
      + +
      + +
      +

      playability test based on URL or MIME type

      + +
      + +
      +    var result;
      +
      +    if (!iO || (!iO.type && !iO.url && !iO.serverURL)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      nothing to check

      + +
      + +
            result = false;
      +
      +    } else if (iO.serverURL || (iO.type && preferFlashCheck(iO.type))) {
      + +
    • + + +
    • +
      + +
      + +
      +

      RTMP, or preferring flash

      + +
      + +
            result = false;
      +
      +    } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      Use type, if specified. Pass data: URIs to HTML5. If HTML5-only mode, no other options, so just give 'er

      + +
      + +
            result = ((iO.type ? html5CanPlay({type:iO.type}) : html5CanPlay({url:iO.url}) || sm2.html5Only || iO.url.match(/data\:/i)));
      +
      +    }
      +
      +    return result;
      +
      +  };
      +
      +  html5Unload = function(oAudio) {
      +
      +    /**
      +     * Internal method: Unload media, and cancel any current/pending network requests.
      +     * Firefox can load an empty URL, which allegedly destroys the decoder and stops the download.
      +     * https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox#Stopping_the_download_of_media
      +     * However, Firefox has been seen loading a relative URL from '' and thus requesting the hosting page on unload.
      +     * Other UA behaviour is unclear, so everyone else gets an about:blank-style URL.
      +     */
      +
      +    var url;
      +
      +    if (oAudio) {
      + +
    • + + +
    • +
      + +
      + +
      +

      Firefox and Chrome accept short WAVe data: URIs. Chome dislikes audio/wav, but accepts audio/wav for data: MIME. +Desktop Safari complains / fails on data: URI, so it gets about:blank.

      + +
      + +
            url = (isSafari ? emptyURL : (sm2.html5.canPlayType('audio/wav') ? emptyWAV : emptyURL));
      +
      +      oAudio.src = url;
      + +
    • + + +
    • +
      + +
      + +
      +

      reset some state, too

      + +
      + +
            if (oAudio._called_unload !== undefined) {
      +        oAudio._called_load = false;
      +      }
      +
      +    }
      +
      +    if (useGlobalHTML5Audio) {
      + +
    • + + +
    • +
      + +
      + +
      +

      ensure URL state is trashed, also

      + +
      + +
            lastGlobalHTML5URL = null;
      +
      +    }
      +
      +    return url;
      +
      +  };
      +
      +  html5CanPlay = function(o) {
      +
      +    /**
      +     * Try to find MIME, test and return truthiness
      +     * o = {
      +     *  url: '/path/to/an.mp3',
      +     *  type: 'audio/mp3'
      +     * }
      +     */
      +
      +    if (!sm2.useHTML5Audio || !sm2.hasHTML5) {
      +      return false;
      +    }
      +
      +    var url = (o.url || null),
      +        mime = (o.type || null),
      +        aF = sm2.audioFormats,
      +        result,
      +        offset,
      +        fileExt,
      +        item;
      + +
    • + + +
    • +
      + +
      + +
      +

      account for known cases like audio/mp3

      + +
      + +
      +    if (mime && sm2.html5[mime] !== _undefined) {
      +      return (sm2.html5[mime] && !preferFlashCheck(mime));
      +    }
      +
      +    if (!html5Ext) {
      +      html5Ext = [];
      +      for (item in aF) {
      +        if (aF.hasOwnProperty(item)) {
      +          html5Ext.push(item);
      +          if (aF[item].related) {
      +            html5Ext = html5Ext.concat(aF[item].related);
      +          }
      +        }
      +      }
      +      html5Ext = new RegExp('\\.('+html5Ext.join('|')+')(\\?.*)?$','i');
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      TODO: Strip URL queries, etc.

      + +
      + +
          fileExt = (url ? url.toLowerCase().match(html5Ext) : null);
      +
      +    if (!fileExt || !fileExt.length) {
      +      if (!mime) {
      +        result = false;
      +      } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      audio/mp3 -> mp3, result should be known

      + +
      + +
              offset = mime.indexOf(';');
      + +
    • + + +
    • +
      + +
      + +
      +

      strip "audio/X; codecs..."

      + +
      + +
              fileExt = (offset !== -1?mime.substr(0,offset):mime).substr(6);
      +      }
      +    } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      match the raw extension name - "mp3", for example

      + +
      + +
            fileExt = fileExt[1];
      +    }
      +
      +    if (fileExt && sm2.html5[fileExt] !== _undefined) {
      + +
    • + + +
    • +
      + +
      + +
      +

      result known

      + +
      + +
            result = (sm2.html5[fileExt] && !preferFlashCheck(fileExt));
      +    } else {
      +      mime = 'audio/'+fileExt;
      +      result = sm2.html5.canPlayType({type:mime});
      +      sm2.html5[fileExt] = result;
      + +
    • + + +
    • +
      + +
      + +
      +

      sm2._wD('canPlayType, found result: ' + result);

      + +
      + +
            result = (result && sm2.html5[mime] && !preferFlashCheck(mime));
      +    }
      +
      +    return result;
      +
      +  };
      +
      +  testHTML5 = function() {
      +
      +    /**
      +     * Internal: Iterates over audioFormats, determining support eg. audio/mp3, audio/mpeg and so on
      +     * assigns results to html5[] and flash[].
      +     */
      +
      +    if (!sm2.useHTML5Audio || !sm2.hasHTML5) {
      + +
    • + + +
    • +
      + +
      + +
      +

      without HTML5, we need Flash.

      + +
      + +
            sm2.html5.usingFlash = true;
      +      needsFlash = true;
      +      return false;
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      double-whammy: Opera 9.64 throws WRONG_ARGUMENTS_ERR if no parameter passed to Audio(), and Webkit + iOS happily tries to load "null" as a URL. :/

      + +
      + +
          var a = (Audio !== _undefined ? (isOpera && opera.version() < 10 ? new Audio(null) : new Audio()) : null),
      +        item, lookup, support = {}, aF, i;
      +
      +    function cp(m) {
      +
      +      var canPlay, j,
      +          result = false,
      +          isOK = false;
      +
      +      if (!a || typeof a.canPlayType !== 'function') {
      +        return result;
      +      }
      +
      +      if (m instanceof Array) {
      + +
    • + + +
    • +
      + +
      + +
      +

      iterate through all mime types, return any successes

      + +
      + +
              for (i=0, j=m.length; i<j; i++) {
      +          if (sm2.html5[m[i]] || a.canPlayType(m[i]).match(sm2.html5Test)) {
      +            isOK = true;
      +            sm2.html5[m[i]] = true;
      + +
    • + + +
    • +
      + +
      + +
      +

      note flash support, too

      + +
      + +
                  sm2.flash[m[i]] = !!(m[i].match(flashMIME));
      +          }
      +        }
      +        result = isOK;
      +      } else {
      +        canPlay = (a && typeof a.canPlayType === 'function' ? a.canPlayType(m) : false);
      +        result = !!(canPlay && (canPlay.match(sm2.html5Test)));
      +      }
      +
      +      return result;
      +
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      test all registered formats + codecs

      + +
      + +
      +    aF = sm2.audioFormats;
      +
      +    for (item in aF) {
      +
      +      if (aF.hasOwnProperty(item)) {
      +
      +        lookup = 'audio/' + item;
      +
      +        support[item] = cp(aF[item].type);
      + +
    • + + +
    • +
      + +
      + +
      +

      write back generic type too, eg. audio/mp3

      + +
      + +
              support[lookup] = support[item];
      + +
    • + + +
    • +
      + +
      + +
      +

      assign flash

      + +
      + +
              if (item.match(flashMIME)) {
      +
      +          sm2.flash[item] = true;
      +          sm2.flash[lookup] = true;
      +
      +        } else {
      +
      +          sm2.flash[item] = false;
      +          sm2.flash[lookup] = false;
      +
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      assign result to related formats, too

      + +
      + +
      +        if (aF[item] && aF[item].related) {
      +
      +          for (i=aF[item].related.length-1; i >= 0; i--) {
      + +
    • + + +
    • +
      + +
      + +
      +

      eg. audio/m4a

      + +
      + +
                  support['audio/'+aF[item].related[i]] = support[item];
      +            sm2.html5[aF[item].related[i]] = support[item];
      +            sm2.flash[aF[item].related[i]] = support[item];
      +
      +          }
      +
      +        }
      +
      +      }
      +
      +    }
      +
      +    support.canPlayType = (a?cp:null);
      +    sm2.html5 = mixin(sm2.html5, support);
      +
      +    sm2.html5.usingFlash = featureCheck();
      +    needsFlash = sm2.html5.usingFlash;
      +
      +    return true;
      +
      +  };
      +
      +  strings = {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
          notReady: 'Unavailable - wait until onready() has fired.',
      +    notOK: 'Audio support is not available.',
      +    domError: sm + 'exception caught while appending SWF to DOM.',
      +    spcWmode: 'Removing wmode, preventing known SWF loading issue(s)',
      +    swf404: smc + 'Verify that %s is a valid path.',
      +    tryDebug: 'Try ' + sm + '.debugFlash = true for more security details (output goes to SWF.)',
      +    checkSWF: 'See SWF output for more debug info.',
      +    localFail: smc + 'Non-HTTP page (' + doc.location.protocol + ' URL?) Review Flash player security settings for this special case:\nhttp://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html\nMay need to add/allow path, eg. c:/sm2/ or /users/me/sm2/',
      +    waitFocus: smc + 'Special case: Waiting for SWF to load with window focus...',
      +    waitForever: smc + 'Waiting indefinitely for Flash (will recover if unblocked)...',
      +    waitSWF: smc + 'Waiting for 100% SWF load...',
      +    needFunction: smc + 'Function object expected for %s',
      +    badID: 'Sound ID "%s" should be a string, starting with a non-numeric character',
      +    currentObj: smc + '_debug(): Current sound objects',
      +    waitOnload: smc + 'Waiting for window.onload()',
      +    docLoaded: smc + 'Document already loaded',
      +    onload: smc + 'initComplete(): calling soundManager.onload()',
      +    onloadOK: sm + '.onload() complete',
      +    didInit: smc + 'init(): Already called?',
      +    secNote: 'Flash security note: Network/internet URLs will not load due to security restrictions. Access can be configured via Flash Player Global Security Settings Page: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html',
      +    badRemove: smc + 'Failed to remove Flash node.',
      +    shutdown: sm + '.disable(): Shutting down',
      +    queue: smc + 'Queueing %s handler',
      +    smError: 'SMSound.load(): Exception: JS-Flash communication failed, or JS error.',
      +    fbTimeout: 'No flash response, applying .'+swfCSS.swfTimedout+' CSS...',
      +    fbLoaded: 'Flash loaded',
      +    fbHandler: smc + 'flashBlockHandler()',
      +    manURL: 'SMSound.load(): Using manually-assigned URL',
      +    onURL: sm + '.load(): current URL already assigned.',
      +    badFV: sm + '.flashVersion must be 8 or 9. "%s" is invalid. Reverting to %s.',
      +    as2loop: 'Note: Setting stream:false so looping can work (flash 8 limitation)',
      +    noNSLoop: 'Note: Looping not implemented for MovieStar formats',
      +    needfl9: 'Note: Switching to flash 9, required for MP4 formats.',
      +    mfTimeout: 'Setting flashLoadTimeout = 0 (infinite) for off-screen, mobile flash case',
      +    needFlash: smc + 'Fatal error: Flash is needed to play some required formats, but is not available.',
      +    gotFocus: smc + 'Got window focus.',
      +    policy: 'Enabling usePolicyFile for data access',
      +    setup: sm + '.setup(): allowed parameters: %s',
      +    setupError: sm + '.setup(): "%s" cannot be assigned with this method.',
      +    setupUndef: sm + '.setup(): Could not find option "%s"',
      +    setupLate: sm + '.setup(): url, flashVersion and html5Test property changes will not take effect until reboot().',
      +    noURL: smc + 'Flash URL required. Call soundManager.setup({url:...}) to get started.',
      +    sm2Loaded: 'SoundManager 2: Ready.',
      +    reset: sm + '.reset(): Removing event callbacks',
      +    mobileUA: 'Mobile UA detected, preferring HTML5 by default.',
      +    globalHTML5: 'Using singleton HTML5 Audio() pattern for this device.'
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +  };
      +
      +  str = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      internal string replace helper. +arguments: o [,items to replace]

      + + +
      + +
      +    var args,
      +        i, j, o,
      +        sstr;
      + +
    • + + +
    • +
      + +
      + +
      +

      real array, please

      + +
      + +
          args = slice.call(arguments);
      + +
    • + + +
    • +
      + +
      + +
      +

      first argument

      + +
      + +
          o = args.shift();
      +
      +    sstr = (strings && strings[o] ? strings[o] : '');
      +
      +    if (sstr && args && args.length) {
      +      for (i = 0, j = args.length; i < j; i++) {
      +        sstr = sstr.replace('%s', args[i]);
      +      }
      +    }
      +
      +    return sstr;
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +  };
      +
      +  loopFix = function(sOpt) {
      + +
    • + + +
    • +
      + +
      + +
      +

      flash 8 requires stream = false for looping to work

      + +
      + +
          if (fV === 8 && sOpt.loops > 1 && sOpt.stream) {
      +      _wDS('as2loop');
      +      sOpt.stream = false;
      +    }
      +
      +    return sOpt;
      +
      +  };
      +
      +  policyFix = function(sOpt, sPre) {
      +
      +    if (sOpt && !sOpt.usePolicyFile && (sOpt.onid3 || sOpt.usePeakData || sOpt.useWaveformData || sOpt.useEQData)) {
      +      sm2._wD((sPre || '') + str('policy'));
      +      sOpt.usePolicyFile = true;
      +    }
      +
      +    return sOpt;
      +
      +  };
      +
      +  complain = function(sMsg) {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
          if (hasConsole && console.warn !== _undefined) {
      +      console.warn(sMsg);
      +    } else {
      +      sm2._wD(sMsg);
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +  };
      +
      +  doNothing = function() {
      +
      +    return false;
      +
      +  };
      +
      +  disableObject = function(o) {
      +
      +    var oProp;
      +
      +    for (oProp in o) {
      +      if (o.hasOwnProperty(oProp) && typeof o[oProp] === 'function') {
      +        o[oProp] = doNothing;
      +      }
      +    }
      +
      +    oProp = null;
      +
      +  };
      +
      +  failSafely = function(bNoDisable) {
      + +
    • + + +
    • +
      + +
      + +
      +

      general failure exception handler

      + +
      + +
      +    if (bNoDisable === _undefined) {
      +      bNoDisable = false;
      +    }
      +
      +    if (disabled || bNoDisable) {
      +      sm2.disable(bNoDisable);
      +    }
      +
      +  };
      +
      +  normalizeMovieURL = function(smURL) {
      +
      +    var urlParams = null, url;
      +
      +    if (smURL) {
      +      if (smURL.match(/\.swf(\?.*)?$/i)) {
      +        urlParams = smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?') + 4);
      +        if (urlParams) {
      + +
    • + + +
    • +
      + +
      + +
      +

      assume user knows what they're doing

      + +
      + +
                return smURL;
      +        }
      +      } else if (smURL.lastIndexOf('/') !== smURL.length - 1) {
      + +
    • + + +
    • +
      + +
      + +
      +

      append trailing slash, if needed

      + +
      + +
              smURL += '/';
      +      }
      +    }
      +
      +    url = (smURL && smURL.lastIndexOf('/') !== - 1 ? smURL.substr(0, smURL.lastIndexOf('/') + 1) : './') + sm2.movieURL;
      +
      +    if (sm2.noSWFCache) {
      +      url += ('?ts=' + new Date().getTime());
      +    }
      +
      +    return url;
      +
      +  };
      +
      +  setVersionInfo = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      short-hand for internal use

      + +
      + +
      +    fV = parseInt(sm2.flashVersion, 10);
      +
      +    if (fV !== 8 && fV !== 9) {
      +      sm2._wD(str('badFV', fV, defaultFlashVersion));
      +      sm2.flashVersion = fV = defaultFlashVersion;
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      debug flash movie, if applicable

      + +
      + +
      +    var isDebug = (sm2.debugMode || sm2.debugFlash?'_debug.swf':'.swf');
      +
      +    if (sm2.useHTML5Audio && !sm2.html5Only && sm2.audioFormats.mp4.required && fV < 9) {
      +      sm2._wD(str('needfl9'));
      +      sm2.flashVersion = fV = 9;
      +    }
      +
      +    sm2.version = sm2.versionNumber + (sm2.html5Only?' (HTML5-only mode)':(fV === 9?' (AS3/Flash 9)':' (AS2/Flash 8)'));
      + +
    • + + +
    • +
      + +
      + +
      +

      set up default options

      + +
      + +
          if (fV > 8) {
      + +
    • + + +
    • +
      + +
      + +
      +

      +flash 9 base options

      + +
      + +
            sm2.defaultOptions = mixin(sm2.defaultOptions, sm2.flash9Options);
      +      sm2.features.buffering = true;
      + +
    • + + +
    • +
      + +
      + +
      +

      +moviestar support

      + +
      + +
            sm2.defaultOptions = mixin(sm2.defaultOptions, sm2.movieStarOptions);
      +      sm2.filePatterns.flash9 = new RegExp('\\.(mp3|' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i');
      +      sm2.features.movieStar = true;
      +    } else {
      +      sm2.features.movieStar = false;
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      regExp for flash canPlay(), etc.

      + +
      + +
          sm2.filePattern = sm2.filePatterns[(fV !== 8?'flash9':'flash8')];
      + +
    • + + +
    • +
      + +
      + +
      +

      if applicable, use _debug versions of SWFs

      + +
      + +
          sm2.movieURL = (fV === 8?'soundmanager2.swf':'soundmanager2_flash9.swf').replace('.swf', isDebug);
      +
      +    sm2.features.peakData = sm2.features.waveformData = sm2.features.eqData = (fV > 8);
      +
      +  };
      +
      +  setPolling = function(bPolling, bHighPerformance) {
      +
      +    if (!flash) {
      +      return false;
      +    }
      +
      +    flash._setPolling(bPolling, bHighPerformance);
      +
      +  };
      +
      +  initDebug = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      starts debug mode, creating output

      for UAs without console object

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      allow force of debug mode via URL

      + + +
      + +
          if (sm2.debugURLParam.test(wl)) {
      +      sm2.debugMode = true;
      +    }
      +
      +    if (id(sm2.debugID)) {
      +      return false;
      +    }
      +
      +    var oD, oDebug, oTarget, oToggle, tmp;
      +
      +    if (sm2.debugMode && !id(sm2.debugID) && (!hasConsole || !sm2.useConsole || !sm2.consoleOnly)) {
      +
      +      oD = doc.createElement('div');
      +      oD.id = sm2.debugID + '-toggle';
      +
      +      oToggle = {
      +        'position': 'fixed',
      +        'bottom': '0px',
      +        'right': '0px',
      +        'width': '1.2em',
      +        'height': '1.2em',
      +        'lineHeight': '1.2em',
      +        'margin': '2px',
      +        'textAlign': 'center',
      +        'border': '1px solid #999',
      +        'cursor': 'pointer',
      +        'background': '#fff',
      +        'color': '#333',
      +        'zIndex': 10001
      +      };
      +
      +      oD.appendChild(doc.createTextNode('-'));
      +      oD.onclick = toggleDebug;
      +      oD.title = 'Toggle SM2 debug console';
      +
      +      if (ua.match(/msie 6/i)) {
      +        oD.style.position = 'absolute';
      +        oD.style.cursor = 'hand';
      +      }
      +
      +      for (tmp in oToggle) {
      +        if (oToggle.hasOwnProperty(tmp)) {
      +          oD.style[tmp] = oToggle[tmp];
      +        }
      +      }
      +
      +      oDebug = doc.createElement('div');
      +      oDebug.id = sm2.debugID;
      +      oDebug.style.display = (sm2.debugMode?'block':'none');
      +
      +      if (sm2.debugMode && !id(oD.id)) {
      +        try {
      +          oTarget = getDocument();
      +          oTarget.appendChild(oD);
      +        } catch(e2) {
      +          throw new Error(str('domError')+' \n'+e2.toString());
      +        }
      +        oTarget.appendChild(oDebug);
      +      }
      +
      +    }
      +
      +    oTarget = null;
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +  };
      +
      +  idCheck = this.getSoundById;
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
        _wDS = function(o, errorLevel) {
      +
      +    return (!o ? '' : sm2._wD(str(o), errorLevel));
      +
      +  };
      +
      +  toggleDebug = function() {
      +
      +    var o = id(sm2.debugID),
      +    oT = id(sm2.debugID + '-toggle');
      +
      +    if (!o) {
      +      return false;
      +    }
      +
      +    if (debugOpen) {
      + +
    • + + +
    • +
      + +
      + +
      +

      minimize

      + +
      + +
            oT.innerHTML = '+';
      +      o.style.display = 'none';
      +    } else {
      +      oT.innerHTML = '-';
      +      o.style.display = 'block';
      +    }
      +
      +    debugOpen = !debugOpen;
      +
      +  };
      +
      +  debugTS = function(sEventType, bSuccess, sMessage) {
      + +
    • + + +
    • +
      + +
      + +
      +

      troubleshooter debug hooks

      + +
      + +
      +    if (window.sm2Debugger !== _undefined) {
      +      try {
      +        sm2Debugger.handleEvent(sEventType, bSuccess, sMessage);
      +      } catch(e) {
      + +
    • + + +
    • +
      + +
      + +
      +

      oh well

      + +
      + +
              return false;
      +      }
      +    }
      +
      +    return true;
      +
      +  };
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +  getSWFCSS = function() {
      +
      +    var css = [];
      +
      +    if (sm2.debugMode) {
      +      css.push(swfCSS.sm2Debug);
      +    }
      +
      +    if (sm2.debugFlash) {
      +      css.push(swfCSS.flashDebug);
      +    }
      +
      +    if (sm2.useHighPerformance) {
      +      css.push(swfCSS.highPerf);
      +    }
      +
      +    return css.join(' ');
      +
      +  };
      +
      +  flashBlockHandler = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      possible flash block situation.

      + +
      + +
      +    var name = str('fbHandler'),
      +        p = sm2.getMoviePercent(),
      +        css = swfCSS,
      +        error = {type:'FLASHBLOCK'};
      +
      +    if (sm2.html5Only) {
      + +
    • + + +
    • +
      + +
      + +
      +

      no flash, or unused

      + +
      + +
            return false;
      +    }
      +
      +    if (!sm2.ok()) {
      +
      +      if (needsFlash) {
      + +
    • + + +
    • +
      + +
      + +
      +

      make the movie more visible, so user can fix

      + +
      + +
              sm2.oMC.className = getSWFCSS() + ' ' + css.swfDefault + ' ' + (p === null?css.swfTimedout:css.swfError);
      +        sm2._wD(name + ': ' + str('fbTimeout') + (p ? ' (' + str('fbLoaded') + ')' : ''));
      +      }
      +
      +      sm2.didFlashBlock = true;
      + +
    • + + +
    • +
      + +
      + +
      +

      fire onready(), complain lightly

      + +
      + +
            processOnEvents({type:'ontimeout', ignoreInit:true, error:error});
      +      catchError(error);
      +
      +    } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      SM2 loaded OK (or recovered)

      + +
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            if (sm2.didFlashBlock) {
      +        sm2._wD(name + ': Unblocked');
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +      if (sm2.oMC) {
      +        sm2.oMC.className = [getSWFCSS(), css.swfDefault, css.swfLoaded + (sm2.didFlashBlock?' '+css.swfUnblocked:'')].join(' ');
      +      }
      +
      +    }
      +
      +  };
      +
      +  addOnEvent = function(sType, oMethod, oScope) {
      +
      +    if (on_queue[sType] === _undefined) {
      +      on_queue[sType] = [];
      +    }
      +
      +    on_queue[sType].push({
      +      'method': oMethod,
      +      'scope': (oScope || null),
      +      'fired': false
      +    });
      +
      +  };
      +
      +  processOnEvents = function(oOptions) {
      + +
    • + + +
    • +
      + +
      + +
      +

      if unspecified, assume OK/error

      + +
      + +
      +    if (!oOptions) {
      +      oOptions = {
      +        type: (sm2.ok() ? 'onready' : 'ontimeout')
      +      };
      +    }
      +
      +    if (!didInit && oOptions && !oOptions.ignoreInit) {
      + +
    • + + +
    • +
      + +
      + +
      +

      not ready yet.

      + +
      + +
            return false;
      +    }
      +
      +    if (oOptions.type === 'ontimeout' && (sm2.ok() || (disabled && !oOptions.ignoreInit))) {
      + +
    • + + +
    • +
      + +
      + +
      +

      invalid case

      + +
      + +
            return false;
      +    }
      +
      +    var status = {
      +          success: (oOptions && oOptions.ignoreInit?sm2.ok():!disabled)
      +        },
      + +
    • + + +
    • +
      + +
      + +
      +

      queue specified by type, or none

      + +
      + +
              srcQueue = (oOptions && oOptions.type?on_queue[oOptions.type]||[]:[]),
      +
      +        queue = [], i, j,
      +        args = [status],
      +        canRetry = (needsFlash && !sm2.ok());
      +
      +    if (oOptions.error) {
      +      args[0].error = oOptions.error;
      +    }
      +
      +    for (i = 0, j = srcQueue.length; i < j; i++) {
      +      if (srcQueue[i].fired !== true) {
      +        queue.push(srcQueue[i]);
      +      }
      +    }
      +
      +    if (queue.length) {
      + +
    • + + +
    • +
      + +
      + +
      +

      sm2._wD(sm + ': Firing ' + queue.length + ' ' + oOptions.type + '() item' + (queue.length === 1 ? '' : 's'));

      + +
      + +
            for (i = 0, j = queue.length; i < j; i++) {
      +        if (queue[i].scope) {
      +          queue[i].method.apply(queue[i].scope, args);
      +        } else {
      +          queue[i].method.apply(this, args);
      +        }
      +        if (!canRetry) {
      + +
    • + + +
    • +
      + +
      + +
      +

      useFlashBlock and SWF timeout case doesn't count here.

      + +
      + +
                queue[i].fired = true;
      +        }
      +      }
      +    }
      +
      +    return true;
      +
      +  };
      +
      +  initUserOnload = function() {
      +
      +    window.setTimeout(function() {
      +
      +      if (sm2.useFlashBlock) {
      +        flashBlockHandler();
      +      }
      +
      +      processOnEvents();
      + +
    • + + +
    • +
      + +
      + +
      +

      call user-defined "onload", scoped to window

      + +
      + +
      +      if (typeof sm2.onload === 'function') {
      +        _wDS('onload', 1);
      +        sm2.onload.apply(window);
      +        _wDS('onloadOK', 1);
      +      }
      +
      +      if (sm2.waitForWindowLoad) {
      +        event.add(window, 'load', initUserOnload);
      +      }
      +
      +    },1);
      +
      +  };
      +
      +  detectFlash = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      hat tip: Flash Detect library (BSD, (C) 2007) by Carl "DocYes" S. Yestrau - http://featureblend.com/javascript-flash-detection-library.html / http://featureblend.com/license.txt

      + +
      + +
      +    if (hasFlash !== _undefined) {
      + +
    • + + +
    • +
      + +
      + +
      +

      this work has already been done.

      + +
      + +
            return hasFlash;
      +    }
      +
      +    var hasPlugin = false, n = navigator, nP = n.plugins, obj, type, types, AX = window.ActiveXObject;
      +
      +    if (nP && nP.length) {
      +      type = 'application/x-shockwave-flash';
      +      types = n.mimeTypes;
      +      if (types && types[type] && types[type].enabledPlugin && types[type].enabledPlugin.description) {
      +        hasPlugin = true;
      +      }
      +    } else if (AX !== _undefined && !ua.match(/MSAppHost/i)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      Windows 8 Store Apps (MSAppHost) are weird (compatibility?) and won't complain here, but will barf if Flash/ActiveX object is appended to the DOM.

      + +
      + +
            try {
      +        obj = new AX('ShockwaveFlash.ShockwaveFlash');
      +      } catch(e) {
      + +
    • + + +
    • +
      + +
      + +
      +

      oh well

      + +
      + +
              obj = null;
      +      }
      +      hasPlugin = (!!obj);
      + +
    • + + +
    • +
      + +
      + +
      +

      cleanup, because it is ActiveX after all

      + +
      + +
            obj = null;
      +    }
      +
      +    hasFlash = hasPlugin;
      +
      +    return hasPlugin;
      +
      +  };
      +
      +  featureCheck = function() {
      +
      +    var flashNeeded,
      +        item,
      +        formats = sm2.audioFormats,
      + +
    • + + +
    • +
      + +
      + +
      +

      iPhone <= 3.1 has broken HTML5 audio(), but firmware 3.2 (original iPad) + iOS4 works.

      + +
      + +
              isSpecial = (is_iDevice && !!(ua.match(/os (1|2|3_0|3_1)/i)));
      +
      +    if (isSpecial) {
      + +
    • + + +
    • +
      + +
      + +
      +

      has Audio(), but is broken; let it load links directly.

      + +
      + +
            sm2.hasHTML5 = false;
      + +
    • + + +
    • +
      + +
      + +
      +

      ignore flash case, however

      + +
      + +
            sm2.html5Only = true;
      + +
    • + + +
    • +
      + +
      + +
      +

      hide the SWF, if present

      + +
      + +
            if (sm2.oMC) {
      +        sm2.oMC.style.display = 'none';
      +      }
      +
      +    } else {
      +
      +      if (sm2.useHTML5Audio) {
      +
      +        if (!sm2.html5 || !sm2.html5.canPlayType) {
      +          sm2._wD('SoundManager: No HTML5 Audio() support detected.');
      +          sm2.hasHTML5 = false;
      +        }
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
              if (isBadSafari) {
      +          sm2._wD(smc + 'Note: Buggy HTML5 Audio in Safari on this OS X release, see https://bugs.webkit.org/show_bug.cgi?id=32159 - ' + (!hasFlash ?' would use flash fallback for MP3/MP4, but none detected.' : 'will use flash fallback for MP3/MP4, if available'), 1);
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +      }
      +
      +    }
      +
      +    if (sm2.useHTML5Audio && sm2.hasHTML5) {
      + +
    • + + +
    • +
      + +
      + +
      +

      sort out whether flash is optional, required or can be ignored.

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      innocent until proven guilty.

      + +
      + +
            canIgnoreFlash = true;
      +
      +      for (item in formats) {
      +        if (formats.hasOwnProperty(item)) {
      +          if (formats[item].required) {
      +            if (!sm2.html5.canPlayType(formats[item].type)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      100% HTML5 mode is not possible.

      + +
      + +
                    canIgnoreFlash = false;
      +              flashNeeded = true;
      +            } else if (sm2.preferFlash && (sm2.flash[item] || sm2.flash[formats[item].type])) {
      + +
    • + + +
    • +
      + +
      + +
      +

      flash may be required, or preferred for this format.

      + +
      + +
                    flashNeeded = true;
      +            }
      +          }
      +        }
      +      }
      +
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      sanity check...

      + +
      + +
          if (sm2.ignoreFlash) {
      +      flashNeeded = false;
      +      canIgnoreFlash = true;
      +    }
      +
      +    sm2.html5Only = (sm2.hasHTML5 && sm2.useHTML5Audio && !flashNeeded);
      +
      +    return (!sm2.html5Only);
      +
      +  };
      +
      +  parseURL = function(url) {
      +
      +    /**
      +     * Internal: Finds and returns the first playable URL (or failing that, the first URL.)
      +     * @param {string or array} url A single URL string, OR, an array of URL strings or {url:'/path/to/resource', type:'audio/mp3'} objects.
      +     */
      +
      +    var i, j, urlResult = 0, result;
      +
      +    if (url instanceof Array) {
      + +
    • + + +
    • +
      + +
      + +
      +

      find the first good one

      + +
      + +
            for (i=0, j=url.length; i<j; i++) {
      +
      +        if (url[i] instanceof Object) {
      + +
    • + + +
    • +
      + +
      + +
      +

      MIME check

      + +
      + +
                if (sm2.canPlayMIME(url[i].type)) {
      +            urlResult = i;
      +            break;
      +          }
      +
      +        } else if (sm2.canPlayURL(url[i])) {
      + +
    • + + +
    • +
      + +
      + +
      +

      URL string check

      + +
      + +
                urlResult = i;
      +          break;
      +        }
      +
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      normalize to string

      + +
      + +
            if (url[urlResult].url) {
      +        url[urlResult] = url[urlResult].url;
      +      }
      +
      +      result = url[urlResult];
      +
      +    } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      single URL case

      + +
      + +
            result = url;
      +
      +    }
      +
      +    return result;
      +
      +  };
      +
      +
      +  startTimer = function(oSound) {
      +
      +    /**
      +     * attach a timer to this sound, and start an interval if needed
      +     */
      +
      +    if (!oSound._hasTimer) {
      +
      +      oSound._hasTimer = true;
      +
      +      if (!mobileHTML5 && sm2.html5PollingInterval) {
      +
      +        if (h5IntervalTimer === null && h5TimerCount === 0) {
      +
      +          h5IntervalTimer = setInterval(timerExecute, sm2.html5PollingInterval);
      +
      +        }
      +
      +        h5TimerCount++;
      +
      +      }
      +
      +    }
      +
      +  };
      +
      +  stopTimer = function(oSound) {
      +
      +    /**
      +     * detach a timer
      +     */
      +
      +    if (oSound._hasTimer) {
      +
      +      oSound._hasTimer = false;
      +
      +      if (!mobileHTML5 && sm2.html5PollingInterval) {
      + +
    • + + +
    • +
      + +
      + +
      +

      interval will stop itself at next execution.

      + +
      + +
      +        h5TimerCount--;
      +
      +      }
      +
      +    }
      +
      +  };
      +
      +  timerExecute = function() {
      +
      +    /**
      +     * manual polling for HTML5 progress events, ie., whileplaying() (can achieve greater precision than conservative default HTML5 interval)
      +     */
      +
      +    var i;
      +
      +    if (h5IntervalTimer !== null && !h5TimerCount) {
      + +
    • + + +
    • +
      + +
      + +
      +

      no active timers, stop polling interval.

      + +
      + +
      +      clearInterval(h5IntervalTimer);
      +
      +      h5IntervalTimer = null;
      +
      +      return false;
      +
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      check all HTML5 sounds with timers

      + +
      + +
      +    for (i = sm2.soundIDs.length-1; i >= 0; i--) {
      +
      +      if (sm2.sounds[sm2.soundIDs[i]].isHTML5 && sm2.sounds[sm2.soundIDs[i]]._hasTimer) {
      +
      +        sm2.sounds[sm2.soundIDs[i]]._onTimer();
      +
      +      }
      +
      +    }
      +
      +  };
      +
      +  catchError = function(options) {
      +
      +    options = (options !== _undefined ? options : {});
      +
      +    if (typeof sm2.onerror === 'function') {
      +      sm2.onerror.apply(window, [{type:(options.type !== _undefined ? options.type : null)}]);
      +    }
      +
      +    if (options.fatal !== _undefined && options.fatal) {
      +      sm2.disable();
      +    }
      +
      +  };
      +
      +  badSafariFix = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      special case: "bad" Safari (OS X 10.3 - 10.7) must fall back to flash for MP3/MP4

      + +
      + +
          if (!isBadSafari || !detectFlash()) {
      + +
    • + + +
    • +
      + +
      + +
      +

      doesn't apply

      + +
      + +
            return false;
      +    }
      +
      +    var aF = sm2.audioFormats, i, item;
      +
      +    for (item in aF) {
      +      if (aF.hasOwnProperty(item)) {
      +        if (item === 'mp3' || item === 'mp4') {
      +          sm2._wD(sm + ': Using flash fallback for ' + item + ' format');
      +          sm2.html5[item] = false;
      + +
    • + + +
    • +
      + +
      + +
      +

      assign result to related formats, too

      + +
      + +
                if (aF[item] && aF[item].related) {
      +            for (i = aF[item].related.length-1; i >= 0; i--) {
      +              sm2.html5[aF[item].related[i]] = false;
      +            }
      +          }
      +        }
      +      }
      +    }
      +
      +  };
      +
      +  /**
      +   * Pseudo-private flash/ExternalInterface methods
      +   * ----------------------------------------------
      +   */
      +
      +  this._setSandboxType = function(sandboxType) {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
          var sb = sm2.sandbox;
      +
      +    sb.type = sandboxType;
      +    sb.description = sb.types[(sb.types[sandboxType] !== _undefined?sandboxType:'unknown')];
      +
      +    if (sb.type === 'localWithFile') {
      +
      +      sb.noRemote = true;
      +      sb.noLocal = false;
      +      _wDS('secNote', 2);
      +
      +    } else if (sb.type === 'localWithNetwork') {
      +
      +      sb.noRemote = false;
      +      sb.noLocal = true;
      +
      +    } else if (sb.type === 'localTrusted') {
      +
      +      sb.noRemote = false;
      +      sb.noLocal = false;
      +
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +  };
      +
      +  this._externalInterfaceOK = function(swfVersion) {
      + +
    • + + +
    • +
      + +
      + +
      +

      flash callback confirming flash loaded, EI working etc. +swfVersion: SWF build string

      + +
      + +
      +    if (sm2.swfLoaded) {
      +      return false;
      +    }
      +
      +    var e;
      +
      +    debugTS('swf', true);
      +    debugTS('flashtojs', true);
      +    sm2.swfLoaded = true;
      +    tryInitOnFocus = false;
      +
      +    if (isBadSafari) {
      +      badSafariFix();
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      complain if JS + SWF build/version strings don't match, excluding +DEV builds

      + + +
      + +
          if (!swfVersion || swfVersion.replace(/\+dev/i,'') !== sm2.versionNumber.replace(/\+dev/i, '')) {
      +
      +      e = sm + ': Fatal: JavaScript file build "' + sm2.versionNumber + '" does not match Flash SWF build "' + swfVersion + '" at ' + sm2.url + '. Ensure both are up-to-date.';
      + +
    • + + +
    • +
      + +
      + +
      +

      escape flash -> JS stack so this error fires in window.

      + +
      + +
            setTimeout(function versionMismatch() {
      +        throw new Error(e);
      +      }, 0);
      + +
    • + + +
    • +
      + +
      + +
      +

      exit, init will fail with timeout

      + +
      + +
            return false;
      +
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      IE needs a larger timeout

      + +
      + +
          setTimeout(init, isIE ? 100 : 1);
      +
      +  };
      +
      +  /**
      +   * Private initialization helpers
      +   * ------------------------------
      +   */
      +
      +  createMovie = function(smID, smURL) {
      +
      +    if (didAppend && appendSuccess) {
      + +
    • + + +
    • +
      + +
      + +
      +

      ignore if already succeeded

      + +
      + +
            return false;
      +    }
      +
      +    function initMsg() {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
      +      var options = [],
      +          title,
      +          msg = [],
      +          delimiter = ' + ';
      +
      +      title = 'SoundManager ' + sm2.version + (!sm2.html5Only && sm2.useHTML5Audio ? (sm2.hasHTML5 ? ' + HTML5 audio' : ', no HTML5 audio support') : '');
      +
      +      if (!sm2.html5Only) {
      +
      +        if (sm2.preferFlash) {
      +          options.push('preferFlash');
      +        }
      +
      +        if (sm2.useHighPerformance) {
      +          options.push('useHighPerformance');
      +        }
      +
      +        if (sm2.flashPollingInterval) {
      +          options.push('flashPollingInterval (' + sm2.flashPollingInterval + 'ms)');
      +        }
      +
      +        if (sm2.html5PollingInterval) {
      +          options.push('html5PollingInterval (' + sm2.html5PollingInterval + 'ms)');
      +        }
      +
      +        if (sm2.wmode) {
      +          options.push('wmode (' + sm2.wmode + ')');
      +        }
      +
      +        if (sm2.debugFlash) {
      +          options.push('debugFlash');
      +        }
      +
      +        if (sm2.useFlashBlock) {
      +          options.push('flashBlock');
      +        }
      +
      +      } else {
      +
      +        if (sm2.html5PollingInterval) {
      +          options.push('html5PollingInterval (' + sm2.html5PollingInterval + 'ms)');
      +        }
      +
      +      }
      +
      +      if (options.length) {
      +        msg = msg.concat([options.join(delimiter)]);
      +      }
      +
      +      sm2._wD(title + (msg.length ? delimiter + msg.join(', ') : ''), 1);
      +
      +      showSupport();
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +    }
      +
      +    if (sm2.html5Only) {
      + +
    • + + +
    • +
      + +
      + +
      +

      100% HTML5 mode

      + +
      + +
            setVersionInfo();
      +
      +      initMsg();
      +      sm2.oMC = id(sm2.movieID);
      +      init();
      + +
    • + + +
    • +
      + +
      + +
      +

      prevent multiple init attempts

      + +
      + +
            didAppend = true;
      +
      +      appendSuccess = true;
      +
      +      return false;
      +
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      flash path

      + +
      + +
          var remoteURL = (smURL || sm2.url),
      +    localURL = (sm2.altURL || remoteURL),
      +    swfTitle = 'JS/Flash audio component (SoundManager 2)',
      +    oTarget = getDocument(),
      +    extraClass = getSWFCSS(),
      +    isRTL = null,
      +    html = doc.getElementsByTagName('html')[0],
      +    oEmbed, oMovie, tmp, movieHTML, oEl, s, x, sClass;
      +
      +    isRTL = (html && html.dir && html.dir.match(/rtl/i));
      +    smID = (smID === _undefined?sm2.id:smID);
      +
      +    function param(name, value) {
      +      return '<param name="'+name+'" value="'+value+'" />';
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      safety check for legacy (change to Flash 9 URL)

      + +
      + +
          setVersionInfo();
      +    sm2.url = normalizeMovieURL(overHTTP?remoteURL:localURL);
      +    smURL = sm2.url;
      +
      +    sm2.wmode = (!sm2.wmode && sm2.useHighPerformance ? 'transparent' : sm2.wmode);
      +
      +    if (sm2.wmode !== null && (ua.match(/msie 8/i) || (!isIE && !sm2.useHighPerformance)) && navigator.platform.match(/win32|win64/i)) {
      +      /**
      +       * extra-special case: movie doesn't load until scrolled into view when using wmode = anything but 'window' here
      +       * does not apply when using high performance (position:fixed means on-screen), OR infinite flash load timeout
      +       * wmode breaks IE 8 on Vista + Win7 too in some cases, as of January 2011 (?)
      +       */
      +       messages.push(strings.spcWmode);
      +      sm2.wmode = null;
      +    }
      +
      +    oEmbed = {
      +      'name': smID,
      +      'id': smID,
      +      'src': smURL,
      +      'quality': 'high',
      +      'allowScriptAccess': sm2.allowScriptAccess,
      +      'bgcolor': sm2.bgColor,
      +      'pluginspage': http+'www.macromedia.com/go/getflashplayer',
      +      'title': swfTitle,
      +      'type': 'application/x-shockwave-flash',
      +      'wmode': sm2.wmode,
      + +
    • + + +
    • + + +
            'hasPriority': 'true'
      +    };
      +
      +    if (sm2.debugFlash) {
      +      oEmbed.FlashVars = 'debug=1';
      +    }
      +
      +    if (!sm2.wmode) {
      + +
    • + + +
    • +
      + +
      + +
      +

      don't write empty attribute

      + +
      + +
            delete oEmbed.wmode;
      +    }
      +
      +    if (isIE) {
      + +
    • + + +
    • +
      + +
      + +
      +

      IE is "special".

      + +
      + +
            oMovie = doc.createElement('div');
      +      movieHTML = [
      +        '<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">',
      +        param('movie', smURL),
      +        param('AllowScriptAccess', sm2.allowScriptAccess),
      +        param('quality', oEmbed.quality),
      +        (sm2.wmode? param('wmode', sm2.wmode): ''),
      +        param('bgcolor', sm2.bgColor),
      +        param('hasPriority', 'true'),
      +        (sm2.debugFlash ? param('FlashVars', oEmbed.FlashVars) : ''),
      +        '</object>'
      +      ].join('');
      +
      +    } else {
      +
      +      oMovie = doc.createElement('embed');
      +      for (tmp in oEmbed) {
      +        if (oEmbed.hasOwnProperty(tmp)) {
      +          oMovie.setAttribute(tmp, oEmbed[tmp]);
      +        }
      +      }
      +
      +    }
      +
      +    initDebug();
      +    extraClass = getSWFCSS();
      +    oTarget = getDocument();
      +
      +    if (oTarget) {
      +
      +      sm2.oMC = (id(sm2.movieID) || doc.createElement('div'));
      +
      +      if (!sm2.oMC.id) {
      +
      +        sm2.oMC.id = sm2.movieID;
      +        sm2.oMC.className = swfCSS.swfDefault + ' ' + extraClass;
      +        s = null;
      +        oEl = null;
      +
      +        if (!sm2.useFlashBlock) {
      +          if (sm2.useHighPerformance) {
      + +
    • + + +
    • +
      + +
      + +
      +

      on-screen at all times

      + +
      + +
                  s = {
      +              'position': 'fixed',
      +              'width': '8px',
      +              'height': '8px',
      + +
    • + + +
    • +
      + +
      + +
      +
      +

      = 6px for flash to run fast, >= 8px to start up under Firefox/win32 in some cases. odd? yes.

      +
      + +
      + +
                    'bottom': '0px',
      +              'left': '0px',
      +              'overflow': 'hidden'
      +            };
      +          } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      hide off-screen, lower priority

      + +
      + +
                  s = {
      +              'position': 'absolute',
      +              'width': '6px',
      +              'height': '6px',
      +              'top': '-9999px',
      +              'left': '-9999px'
      +            };
      +            if (isRTL) {
      +              s.left = Math.abs(parseInt(s.left,10))+'px';
      +            }
      +          }
      +        }
      +
      +        if (isWebkit) {
      + +
    • + + +
    • +
      + +
      + +
      +

      soundcloud-reported render/crash fix, safari 5

      + +
      + +
                sm2.oMC.style.zIndex = 10000;
      +        }
      +
      +        if (!sm2.debugFlash) {
      +          for (x in s) {
      +            if (s.hasOwnProperty(x)) {
      +              sm2.oMC.style[x] = s[x];
      +            }
      +          }
      +        }
      +
      +        try {
      +          if (!isIE) {
      +            sm2.oMC.appendChild(oMovie);
      +          }
      +          oTarget.appendChild(sm2.oMC);
      +          if (isIE) {
      +            oEl = sm2.oMC.appendChild(doc.createElement('div'));
      +            oEl.className = swfCSS.swfBox;
      +            oEl.innerHTML = movieHTML;
      +          }
      +          appendSuccess = true;
      +        } catch(e) {
      +          throw new Error(str('domError')+' \n'+e.toString());
      +        }
      +
      +      } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      SM2 container is already in the document (eg. flashblock use case)

      + +
      + +
              sClass = sm2.oMC.className;
      +        sm2.oMC.className = (sClass?sClass+' ':swfCSS.swfDefault) + (extraClass?' '+extraClass:'');
      +        sm2.oMC.appendChild(oMovie);
      +        if (isIE) {
      +          oEl = sm2.oMC.appendChild(doc.createElement('div'));
      +          oEl.className = swfCSS.swfBox;
      +          oEl.innerHTML = movieHTML;
      +        }
      +        appendSuccess = true;
      +
      +      }
      +
      +    }
      +
      +    didAppend = true;
      +    initMsg();
      + +
    • + + +
    • +
      + +
      + +
      +

      sm2._wD(sm + ': Trying to load ' + smURL + (!overHTTP && sm2.altURL ? ' (alternate URL)' : ''), 1);

      + +
      + +
      +    return true;
      +
      +  };
      +
      +  initMovie = function() {
      +
      +    if (sm2.html5Only) {
      +      createMovie();
      +      return false;
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      attempt to get, or create, movie (may already exist)

      + +
      + +
          if (flash) {
      +      return false;
      +    }
      +
      +    if (!sm2.url) {
      +
      +      /**
      +       * Something isn't right - we've reached init, but the soundManager url property has not been set.
      +       * User has not called setup({url: ...}), or has not set soundManager.url (legacy use case) directly before init time.
      +       * Notify and exit. If user calls setup() with a url: property, init will be restarted as in the deferred loading case.
      +       */
      +
      +       _wDS('noURL');
      +       return false;
      +
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      inline markup case

      + +
      + +
          flash = sm2.getMovie(sm2.id);
      +
      +    if (!flash) {
      +      if (!oRemoved) {
      + +
    • + + +
    • +
      + +
      + +
      +

      try to create

      + +
      + +
              createMovie(sm2.id, sm2.url);
      +      } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      try to re-append removed movie after reboot()

      + +
      + +
              if (!isIE) {
      +          sm2.oMC.appendChild(oRemoved);
      +        } else {
      +          sm2.oMC.innerHTML = oRemovedHTML;
      +        }
      +        oRemoved = null;
      +        didAppend = true;
      +      }
      +      flash = sm2.getMovie(sm2.id);
      +    }
      +
      +    if (typeof sm2.oninitmovie === 'function') {
      +      setTimeout(sm2.oninitmovie, 1);
      +    }
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
          flushMessages();
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +    return true;
      +
      +  };
      +
      +  delayWaitForEI = function() {
      +
      +    setTimeout(waitForEI, 1000);
      +
      +  };
      +
      +  rebootIntoHTML5 = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      special case: try for a reboot with preferFlash: false, if 100% HTML5 mode is possible and useFlashBlock is not enabled.

      + +
      + +
      +    window.setTimeout(function() {
      +
      +      complain(smc + 'useFlashBlock is false, 100% HTML5 mode is possible. Rebooting with preferFlash: false...');
      +
      +      sm2.setup({
      +        preferFlash: false
      +      }).reboot();
      + +
    • + + +
    • +
      + +
      + +
      +

      if for some reason you want to detect this case, use an ontimeout() callback and look for html5Only and didFlashBlock == true.

      + +
      + +
            sm2.didFlashBlock = true;
      +
      +      sm2.beginDelayedInit();
      +
      +    }, 1);
      +
      +  };
      +
      +  waitForEI = function() {
      +
      +    var p,
      +        loadIncomplete = false;
      +
      +    if (!sm2.url) {
      + +
    • + + +
    • +
      + +
      + +
      +

      No SWF url to load (noURL case) - exit for now. Will be retried when url is set.

      + +
      + +
            return false;
      +    }
      +
      +    if (waitingForEI) {
      +      return false;
      +    }
      +
      +    waitingForEI = true;
      +    event.remove(window, 'load', delayWaitForEI);
      +
      +    if (hasFlash && tryInitOnFocus && !isFocused) {
      + +
    • + + +
    • +
      + +
      + +
      +

      Safari won't load flash in background tabs, only when focused.

      + +
      + +
            _wDS('waitFocus');
      +      return false;
      +    }
      +
      +    if (!didInit) {
      +      p = sm2.getMoviePercent();
      +      if (p > 0 && p < 100) {
      +        loadIncomplete = true;
      +      }
      +    }
      +
      +    setTimeout(function() {
      +
      +      p = sm2.getMoviePercent();
      +
      +      if (loadIncomplete) {
      + +
    • + + +
    • +
      + +
      + +
      +

      special case: if movie partially loaded, retry until it's 100% before assuming failure.

      + +
      + +
              waitingForEI = false;
      +        sm2._wD(str('waitSWF'));
      +        window.setTimeout(delayWaitForEI, 1);
      +        return false;
      +      }
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            if (!didInit) {
      +
      +        sm2._wD(sm + ': No Flash response within expected time. Likely causes: ' + (p === 0 ? 'SWF load failed, ':'') + 'Flash blocked or JS-Flash security error.' + (sm2.debugFlash?' ' + str('checkSWF'):''), 2);
      +
      +        if (!overHTTP && p) {
      +
      +          _wDS('localFail', 2);
      +
      +          if (!sm2.debugFlash) {
      +            _wDS('tryDebug', 2);
      +          }
      +
      +        }
      +
      +        if (p === 0) {
      + +
    • + + +
    • +
      + +
      + +
      +

      if 0 (not null), probably a 404.

      + +
      + +
                sm2._wD(str('swf404', sm2.url), 1);
      +
      +        }
      +
      +        debugTS('flashtojs', false, ': Timed out' + overHTTP?' (Check flash security or flash blockers)':' (No plugin/missing SWF?)');
      +
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
    • + + +
    • +
      + +
      + +
      +

      give up / time-out, depending

      + +
      + +
      +      if (!didInit && okToDisable) {
      +
      +        if (p === null) {
      + +
    • + + +
    • +
      + +
      + +
      +

      SWF failed to report load progress. Possibly blocked.

      + +
      + +
      +          if (sm2.useFlashBlock || sm2.flashLoadTimeout === 0) {
      +
      +            if (sm2.useFlashBlock) {
      +
      +              flashBlockHandler();
      +
      +            }
      +
      +            _wDS('waitForever');
      +
      +          } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      no custom flash block handling, but SWF has timed out. Will recover if user unblocks / allows SWF load.

      + +
      + +
      +            if (!sm2.useFlashBlock && canIgnoreFlash) {
      +
      +              rebootIntoHTML5();
      +
      +            } else {
      +
      +              _wDS('waitForever');
      + +
    • + + +
    • +
      + +
      + +
      +

      fire any regular registered ontimeout() listeners.

      + +
      + +
                    processOnEvents({type:'ontimeout', ignoreInit: true, error: {type: 'INIT_FLASHBLOCK'}});
      +
      +            }
      +
      +          }
      +
      +        } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      SWF loaded? Shouldn't be a blocking issue, then.

      + +
      + +
      +          if (sm2.flashLoadTimeout === 0) {
      +
      +            _wDS('waitForever');
      +
      +          } else {
      +
      +            if (!sm2.useFlashBlock && canIgnoreFlash) {
      +
      +              rebootIntoHTML5();
      +
      +            } else {
      +
      +              failSafely(true);
      +
      +            }
      +
      +          }
      +
      +        }
      +
      +      }
      +
      +    }, sm2.flashLoadTimeout);
      +
      +  };
      +
      +  handleFocus = function() {
      +
      +    function cleanup() {
      +      event.remove(window, 'focus', handleFocus);
      +    }
      +
      +    if (isFocused || !tryInitOnFocus) {
      + +
    • + + +
    • +
      + +
      + +
      +

      already focused, or not special Safari background tab case

      + +
      + +
            cleanup();
      +      return true;
      +    }
      +
      +    okToDisable = true;
      +    isFocused = true;
      +    _wDS('gotFocus');
      + +
    • + + +
    • +
      + +
      + +
      +

      allow init to restart

      + +
      + +
          waitingForEI = false;
      + +
    • + + +
    • +
      + +
      + +
      +

      kick off ExternalInterface timeout, now that the SWF has started

      + +
      + +
          delayWaitForEI();
      +
      +    cleanup();
      +    return true;
      +
      +  };
      +
      +  flushMessages = function() {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
    • + + +
    • +
      + +
      + +
      +

      SM2 pre-init debug messages

      + +
      + +
          if (messages.length) {
      +      sm2._wD('SoundManager 2: ' + messages.join(' '), 1);
      +      messages = [];
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +  };
      +
      +  showSupport = function() {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
      +    flushMessages();
      +
      +    var item, tests = [];
      +
      +    if (sm2.useHTML5Audio && sm2.hasHTML5) {
      +      for (item in sm2.audioFormats) {
      +        if (sm2.audioFormats.hasOwnProperty(item)) {
      +          tests.push(item + ' = ' + sm2.html5[item] + (!sm2.html5[item] && needsFlash && sm2.flash[item] ? ' (using flash)' : (sm2.preferFlash && sm2.flash[item] && needsFlash ? ' (preferring flash)': (!sm2.html5[item] ? ' (' + (sm2.audioFormats[item].required ? 'required, ':'') + 'and no flash support)' : ''))));
      +        }
      +      }
      +      sm2._wD('SoundManager 2 HTML5 support: ' + tests.join(', '), 1);
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +  };
      +
      +  initComplete = function(bNoDisable) {
      +
      +    if (didInit) {
      +      return false;
      +    }
      +
      +    if (sm2.html5Only) {
      + +
    • + + +
    • +
      + +
      + +
      +

      all good.

      + +
      + +
            _wDS('sm2Loaded');
      +      didInit = true;
      +      initUserOnload();
      +      debugTS('onload', true);
      +      return true;
      +    }
      +
      +    var wasTimeout = (sm2.useFlashBlock && sm2.flashLoadTimeout && !sm2.getMoviePercent()),
      +        result = true,
      +        error;
      +
      +    if (!wasTimeout) {
      +      didInit = true;
      +    }
      +
      +    error = {type: (!hasFlash && needsFlash ? 'NO_FLASH' : 'INIT_TIMEOUT')};
      +
      +    sm2._wD('SoundManager 2 ' + (disabled ? 'failed to load' : 'loaded') + ' (' + (disabled ? 'Flash security/load error' : 'OK') + ')', disabled ? 2: 1);
      +
      +    if (disabled || bNoDisable) {
      +      if (sm2.useFlashBlock && sm2.oMC) {
      +        sm2.oMC.className = getSWFCSS() + ' ' + (sm2.getMoviePercent() === null?swfCSS.swfTimedout:swfCSS.swfError);
      +      }
      +      processOnEvents({type:'ontimeout', error:error, ignoreInit: true});
      +      debugTS('onload', false);
      +      catchError(error);
      +      result = false;
      +    } else {
      +      debugTS('onload', true);
      +    }
      +
      +    if (!disabled) {
      +      if (sm2.waitForWindowLoad && !windowLoaded) {
      +        _wDS('waitOnload');
      +        event.add(window, 'load', initUserOnload);
      +      } else {
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
              if (sm2.waitForWindowLoad && windowLoaded) {
      +          _wDS('docLoaded');
      +        }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
              initUserOnload();
      +      }
      +    }
      +
      +    return result;
      +
      +  };
      +
      +  /**
      +   * apply top-level setupOptions object as local properties, eg., this.setupOptions.flashVersion -> this.flashVersion (soundManager.flashVersion)
      +   * this maintains backward compatibility, and allows properties to be defined separately for use by soundManager.setup().
      +   */
      +
      +  setProperties = function() {
      +
      +    var i,
      +        o = sm2.setupOptions;
      +
      +    for (i in o) {
      +
      +      if (o.hasOwnProperty(i)) {
      + +
    • + + +
    • +
      + +
      + +
      +

      assign local property if not already defined

      + +
      + +
      +        if (sm2[i] === _undefined) {
      +
      +          sm2[i] = o[i];
      +
      +        } else if (sm2[i] !== o[i]) {
      + +
    • + + +
    • +
      + +
      + +
      +

      legacy support: write manually-assigned property (eg., soundManager.url) back to setupOptions to keep things in sync

      + +
      + +
                sm2.setupOptions[i] = sm2[i];
      +
      +        }
      +
      +      }
      +
      +    }
      +
      +  };
      +
      +
      +  init = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      called after onload()

      + +
      + +
      +    if (didInit) {
      +      _wDS('didInit');
      +      return false;
      +    }
      +
      +    function cleanup() {
      +      event.remove(window, 'load', sm2.beginDelayedInit);
      +    }
      +
      +    if (sm2.html5Only) {
      +      if (!didInit) {
      + +
    • + + +
    • +
      + +
      + +
      +

      we don't need no steenking flash!

      + +
      + +
              cleanup();
      +        sm2.enabled = true;
      +        initComplete();
      +      }
      +      return true;
      +    }
      + +
    • + + +
    • +
      + +
      + +
      +

      flash path

      + +
      + +
          initMovie();
      +
      +    try {
      + +
    • + + +
    • +
      + +
      + +
      +

      attempt to talk to Flash

      + +
      + +
            flash._externalInterfaceTest(false);
      + +
    • + + +
    • +
      + +
      + +
      +

      apply user-specified polling interval, OR, if "high performance" set, faster vs. default polling +(determines frequency of whileloading/whileplaying callbacks, effectively driving UI framerates)

      + +
      + +
            setPolling(true, (sm2.flashPollingInterval || (sm2.useHighPerformance ? 10 : 50)));
      +
      +      if (!sm2.debugMode) {
      + +
    • + + +
    • +
      + +
      + +
      +

      stop the SWF from making debug output calls to JS

      + +
      + +
              flash._disableDebug();
      +      }
      +
      +      sm2.enabled = true;
      +      debugTS('jstoflash', true);
      +
      +      if (!sm2.html5Only) {
      + +
    • + + +
    • +
      + +
      + +
      +

      prevent browser from showing cached page state (or rather, restoring "suspended" page state) via back button, because flash may be dead +http://www.webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/

      + +
      + +
              event.add(window, 'unload', doNothing);
      +      }
      +
      +    } catch(e) {
      +
      +      sm2._wD('js/flash exception: ' + e.toString());
      +      debugTS('jstoflash', false);
      +      catchError({type:'JS_TO_FLASH_EXCEPTION', fatal:true});
      + +
    • + + +
    • +
      + +
      + +
      +

      don't disable, for reboot()

      + +
      + +
            failSafely(true);
      +      initComplete();
      +
      +      return false;
      +
      +    }
      +
      +    initComplete();
      + +
    • + + +
    • +
      + +
      + +
      +

      disconnect events

      + +
      + +
          cleanup();
      +
      +    return true;
      +
      +  };
      +
      +  domContentLoaded = function() {
      +
      +    if (didDCLoaded) {
      +      return false;
      +    }
      +
      +    didDCLoaded = true;
      + +
    • + + +
    • +
      + +
      + +
      +

      assign top-level soundManager properties eg. soundManager.url

      + +
      + +
          setProperties();
      +
      +    initDebug();
      +
      +    /**
      +     * Temporary feature: allow force of HTML5 via URL params: sm2-usehtml5audio=0 or 1
      +     * Ditto for sm2-preferFlash, too.
      +     */
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
          (function(){
      +
      +      var a = 'sm2-usehtml5audio=',
      +          a2 = 'sm2-preferflash=',
      +          b = null,
      +          b2 = null,
      +          l = wl.toLowerCase();
      +
      +      if (l.indexOf(a) !== -1) {
      +        b = (l.charAt(l.indexOf(a)+a.length) === '1');
      +        if (hasConsole) {
      +          console.log((b?'Enabling ':'Disabling ')+'useHTML5Audio via URL parameter');
      +        }
      +        sm2.setup({
      +          'useHTML5Audio': b
      +        });
      +      }
      +
      +      if (l.indexOf(a2) !== -1) {
      +        b2 = (l.charAt(l.indexOf(a2)+a2.length) === '1');
      +        if (hasConsole) {
      +          console.log((b2?'Enabling ':'Disabling ')+'preferFlash via URL parameter');
      +        }
      +        sm2.setup({
      +          'preferFlash': b2
      +        });
      +      }
      +
      +    }());
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +    if (!hasFlash && sm2.hasHTML5) {
      +      sm2._wD('SoundManager 2: No Flash detected' + (!sm2.useHTML5Audio ? ', enabling HTML5.' : '. Trying HTML5-only mode.'), 1);
      +      sm2.setup({
      +        'useHTML5Audio': true,
      + +
    • + + +
    • +
      + +
      + +
      +

      make sure we aren't preferring flash, either +TODO: preferFlash should not matter if flash is not installed. Currently, stuff breaks without the below tweak.

      + +
      + +
              'preferFlash': false
      +      });
      +    }
      +
      +    testHTML5();
      +
      +    if (!hasFlash && needsFlash) {
      +      messages.push(strings.needFlash);
      + +
    • + + +
    • +
      + +
      + +
      +

      TODO: Fatal here vs. timeout approach, etc. +hack: fail sooner.

      + +
      + +
            sm2.setup({
      +        'flashLoadTimeout': 1
      +      });
      +    }
      +
      +    if (doc.removeEventListener) {
      +      doc.removeEventListener('DOMContentLoaded', domContentLoaded, false);
      +    }
      +
      +    initMovie();
      +
      +    return true;
      +
      +  };
      +
      +  domContentLoadedIE = function() {
      +
      +    if (doc.readyState === 'complete') {
      +      domContentLoaded();
      +      doc.detachEvent('onreadystatechange', domContentLoadedIE);
      +    }
      +
      +    return true;
      +
      +  };
      +
      +  winOnLoad = function() {
      + +
    • + + +
    • +
      + +
      + +
      +

      catch edge case of initComplete() firing after window.load()

      + +
      + +
          windowLoaded = true;
      +    event.remove(window, 'load', winOnLoad);
      +
      +  };
      +
      +  /**
      +   * miscellaneous run-time, pre-init stuff
      +   */
      +
      +  preInit = function() {
      +
      +    if (mobileHTML5) {
      + +
    • + + +
    • +
      + +
      + +
      +

      prefer HTML5 for mobile + tablet-like devices, probably more reliable vs. flash at this point.

      + +
      + +
    • + + +
    • +
      + +
      + +
      + + +
      + +
            if (!sm2.setupOptions.useHTML5Audio || sm2.setupOptions.preferFlash) {
      + +
    • + + +
    • +
      + +
      + +
      +

      notify that defaults are being changed.

      + +
      + +
              messages.push(strings.mobileUA);
      +      }
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
      +      sm2.setupOptions.useHTML5Audio = true;
      +      sm2.setupOptions.preferFlash = false;
      +
      +      if (is_iDevice || (isAndroid && !ua.match(/android\s2\.3/i))) {
      + +
    • + + +
    • +
      + +
      + +
      +

      iOS and Android devices tend to work better with a single audio instance, specifically for chained playback of sounds in sequence. +common use case: exiting sound onfinish() -> createSound() -> play()

      + + +
      + +
              messages.push(strings.globalHTML5);
      + +
    • + + +
    • +
      + +
      + +
      +

      + +
      + +
              if (is_iDevice) {
      +          sm2.ignoreFlash = true;
      +        }
      +        useGlobalHTML5Audio = true;
      +      }
      +
      +    }
      +
      +  };
      +
      +  preInit();
      + +
    • + + +
    • +
      + +
      + +
      +

      sniff up-front

      + +
      + +
        detectFlash();
      + +
    • + + +
    • +
      + +
      + +
      +

      focus and window load, init (primarily flash-driven)

      + +
      + +
        event.add(window, 'focus', handleFocus);
      +  event.add(window, 'load', delayWaitForEI);
      +  event.add(window, 'load', winOnLoad);
      +
      +  if (doc.addEventListener) {
      +
      +    doc.addEventListener('DOMContentLoaded', domContentLoaded, false);
      +
      +  } else if (doc.attachEvent) {
      +
      +    doc.attachEvent('onreadystatechange', domContentLoadedIE);
      +
      +  } else {
      + +
    • + + +
    • +
      + +
      + +
      +

      no add/attachevent support - safe to assume no JS -> Flash either

      + +
      + +
          debugTS('onload', false);
      +    catchError({type:'NO_DOM2_EVENTS', fatal:true});
      +
      +  }
      +
      +} // SoundManager()
      + +
    • + + +
    • + + +
      +if (window.SM2_DEFER === undefined || !SM2_DEFER) {
      +  soundManager = new SoundManager();
      +}
      +
      +/**
      + * SoundManager public interfaces
      + * ------------------------------
      + */
      +
      +window.SoundManager = SoundManager; // constructor
      +window.soundManager = soundManager; // public API, flash callbacks etc.
      +
      +}(window));
      + +
    • + +
    +
    + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/getstarted/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/getstarted/index.html new file mode 100755 index 00000000..10f022ac --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/getstarted/index.html @@ -0,0 +1,563 @@ + + + +SoundManager 2 Tutorial: Getting Started + + + + + + + + + + + + + + + + + + +
    + + + +
    + +
    + +
    +
    +

    How SoundManager Works

    +

    It starts out easy, but you can go down the rabbit hole if you want.

    +
    + +
    + +
    + + + +

    SoundManager 2 Tutorial: What, Why, How

    + +

    Problem: Browsers lack good, consistent native audio support. (HTML 5's Audio() is the future, but is still in development.)

    +

    Solution: Javascript API using HTML5 Audio() + headless Flash via ExternalInterface, works almost everywhere. If HTML5 is supported but "non-free" MP3/MP4 formats are not, flash can be used as a fallback.

    +

    SoundManager 2 wraps and extends both the HTML Audio and Flash Audio APIs, providing a single, unified sound API to Javascript; the API is consistent regardless of the technology working under the hood to play sound. (The flash portion is hidden, transparent to both developers and end users.)

    + +
    + +
    + + +

    Including SoundManager 2

    + +

    The soundmanager2.js core can get down to 11 KB over the wire, depending on what version you use. A few versions of the SM2 script are available, balancing code size between commented, debug-enabled and production-optimized builds.

    +

    Regardless of which build you use, take advantage of gzip compression on your server for big savings. As shown below, SoundManager 2 compresses quite well with gzip; the full debug-enabled version served with gzip is smaller than even the minified, no-debug version served without.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Build versionRecommended useFile size+ gzip
    +

    Original, formatted debug-enabled version with comments. Passes jslint.

    +
    <script src="soundmanager2.js"></script>
    +
    Development, testing, debugging153 KB41 KB
    +

    "No-debug", formatted (comments removed, whitespace retained) version

    +
    <script src="soundmanager2-nodebug.js"></script>
    +
    Production, "clean" no-debug code78 KB17 KB
    +

    Minified (Google Closure Compiler-munged, no comments or whitespace), debug-enabled version

    +
    <script src="soundmanager2-jsmin.js"></script>
    +
    Production, with debug code47 KB16 KB
    +

    Build-script optimized, minified, no-debug version

    +
    <script src="soundmanager2-nodebug-jsmin.js"></script>
    +
    Production-optimized, debug code removed34 KB11 KB!
    + +

    You then need to tell SM2 where to find the flash .SWF it will need (depending on HTML5 support), and optionally what version of Flash (~2.8 KB for flash 8, and ~8.5 KB for flash 9) depending on what API features you want:

    + +
    <script>
    +soundManager.setup({
    +  url: '/path/to/swf-files/',
    +  flashVersion: 9, // optional: shiny features (default = 8)
    +  // optional: ignore Flash where possible, use 100% HTML5 mode
    +  // preferFlash: false,
    +  onready: function() {
    +    // Ready to use; soundManager.createSound() etc. can now be called.
    +  }
    +});
    +</script>
    + +

    If you plan to eventually use the flash block handling feature (disabled in this example), you'll want to look at the flash block demo and include the relevant CSS it uses.

    + + + +

    Basic SoundManager Template

    + +

    For a live example of a page including SoundManager 2, check the bare-bones template.

    + +

    SoundManager File Structure

    +

    Or, "What you get when you download SM2."

    +

    The core audio API bits require script/soundmanager2.js and the SWF files swf/soundmanager2.swf and swf/soundmanager2_flash9.swf, as well as the _debug versions of the SWFs. The flash 9 SWF enables some extra API features, and is only used if you set soundManager.flashVersion = 9 (the default is 8.)

    + +
      +
    • + soundmanager2/ +
        +
      • + demo/ - Examples, MP3 player UIs etc. +
      • +
      • + doc/ - API method documentation, notes, troubleshooting +
      • +
      • + script/ - API core, soundmanager2.js +
      • +
      • + src/ - AS2/AS3 Flash source used to build SWFs (for flash development) +
      • +
      • + swf/ - API core, SoundManager 2 .SWF files +
      • +
      • + troubleshoot/ - Tool for finding/fixing startup issues +
      • +
      +
    • +
    + +

    How SoundManager 2 Really Works

    + +

    SoundManager 2 is the result of Javascript talking to a hidden Flash movie. The Flash layer is not something you have to work with directly, but it is the component which makes audio control possible behind the scenes.

    + +
    + +
    + soundmanager2.js <- Flash + ExternalInterface, and/or HTML5 Audio() -> <- HTTP -> audio file +
    + +
    + +

    Flash can expose methods to Javascript via ExternalInterface, allowing bi-directional calls to be made and thus providing additional functionality to Javascript.

    + +

    For the real gory details on the behind-the-scenes action of JS + Flash, see How SoundManager 2 Works on schillmania.com.

    + + +
    + +
    + +

    Startup / Initialization

    + +

    In brief, here is now SM2 starts up:

    +
      +
    • soundmanager2.js loads
    • +
    • new SoundManager() constructor call, event listeners attached for dom ready/init
    • +
    • document.createElement('embed') (or 'object' for IE), append Flash .SWF to document
    • +
    • SWF loads, Flash makes call to JS function: "Hi, JS!"
    • +
    • JS -> Flash test (JS calls Flash function): "Hello, Flash!"
    • +
    • -- startup is complete, soundManager.onready() fires --
    • +
    + +

    A single Javascript include will link in all of the required code for the library, which will automatically begin loading either at onDOMContentLoaded() if supported, or alternately, after window.onload() (eg., IE 6 and others.) The default behaviour is to start "as soon as possible", but the library can be configured to wait for window.onload() in all cases as well. Loading and initialisation are separate events.

    + +

    Once initialised, SM2 will call event handlers/listeners registered via soundManager.onready(). There are also "old-skool" onload()/onerror() event handlers which you can define just as you would with window.onload().

    + +

    If you want to lazy-load or defer SM2, see Lazy-loading and SM2_DEFER.

    + +

    SoundManager onready() / ontimeout() Event Handlers

    + +

    onready() is a flexible method that can be used to queue numerous listeners for SM2's successful start-up. Simply pass a callback function, which will be called when SM2 has successfully started:

    + +
    soundManager.onready(function() {
    +    // SM2 is ready to go!
    +    makeSomeNoise(); // soundManager.createSound(), etc.
    +});
    + +

    ontimeout() is used to add listeners for SM2 init failures, which can happen due to missing or blocked Flash support. They are not necessarily fatal as in the flash block case, where onready() calls can follow ontimeout() if the user unblocks flash after a failed init attempt.

    + +
    soundManager.ontimeout(function() {
    +    // SM2 could not start. Flash blocked, missing or security error? Complain, etc.?
    +});
    + +

    Lazy-loading / Dynamically-loading SM2 on-the-fly

    + +

    Let's say you wanted to load and start SM2 after your page has loaded, using JavaScript to insert a script node etc., or otherwise only start SM2 conditionally. You can load the library dynamically (at or after DOMContentReady), and it will not attempt to init until you call setup() with a url parameter.

    +

    Example:

    + +
    function loadSM2() {
    +  // -- load soundmanager2.js via <script>, createElement('script') or XHR etc. --
    +  // imaginary loadJS() function with callback ...
    +  loadJS('/path/to/soundmanager2.js', function() {
    +    // once soundmanager2.js has loaded, call soundManager.setup().
    +    soundManager.setup({
    +      url: '/path/to/swfs/',
    +      onready: function() {
    +        // soundManager.createSound() etc. here
    +      }
    +    });
    +  });
    +}
    + +

    For a live demo, check out the deferred loading example.

    + +
    + + +
    + +
    + +
    + +
    +

    Sound Options Object Format

    +

    Object Literal, JSON-style data passed to createSound() and play()

    +
    + +
    + +
    + +

    Object Literal Format

    + +

    Sounds can be created with instance-specific parameters in an object literal (JSON-style) format, where omitted parameters inherit default values as defined in soundManager.

    + +
    soundManager.createSound({
    +  id: 'mySound',
    +  url: '/path/to/some.mp3',
    +  autoLoad: true,
    +  autoPlay: false,
    +  onload: function() {
    +    alert('The sound '+this.id+' loaded!');
    +  },
    +  volume: 50
    +});
    + +

    This object can also be passed as an optional argument to the play method, overriding options set at creation time.

    + +

    For a full list of available options, see Sound Properties Object

    + +
    + + +
    + +
    + +
    +
    +

    "Use Responsibly"

    +

    Only you can prevent audio pollution?

    +
    + +
    + +
    + +

    A Word Of Vice

    +

    Not every button, link, element or paragraph on the web needs to zoom, move, change colour and be noisy, repetitive and annoying all at the same time. Use your own discretion!

    +

    Sites which automatically start playing background sound, and/or don't have volume or mute controls are the kind of things you should avoid building. As a developer, gentle reader, you may eventually find yourself in such a situation. Please do your part in enhancing the web with sound if you use SM2, while at the same time keeping it audibly usable. :)

    + +
    + +
    + +
    + +
    + +
    +

    Troubleshooting

    +

    Console-style messaging, useful for troubleshooting start-up and runtime issues.

    +
    + +
    + +

    SoundManager 2 Start-up and Debug Tools

    +

    This troubleshooting tool can come in handy for debugging SM2 start-up problems, when Flash support is required.

    + +

    Flash options: Flash 8 (default), Flash 9 (normal) or Flash 9 + highPerformance + fastPolling modes.

    + +
    +
      + +
    • +

      OKFAILN/AUnknownSoundManager 2 start-up

      +
      +

      soundManager onready() or ontimeout() events are ultimately called when start-up completes.

      +

      If you're seeing a failure, refer to the below for troubleshooting details for common causes.

      +
      +
    • + +
    • +

      OKErrorN/AUnknownFlash

      +
      +

      Flash 8 or 9 may be required for SoundManager 2 to start, depending on HTML5 support. You are currently using [unknown].

      +
      +
    • + +
    • +

      OKErrorN/AUnknownFlash SWF

      +
      +

      SoundManager 2 must load a flash movie before initialisation can proceed. If you have errors here, check that soundManager.url is correctly defined and that the URL being loaded is correct.

      +

      If the Flash movie URL is OK, Flash security or flash blockers are the likely cause. Check the section below.

      +
      +
    • + +
    • +

      OKErrorN/AUnknownFlash -> JS

      +
      +

      Once the flash component of SM2 has loaded, it tries to make a call to Javascript-land. This is a common point of failure, for security reasons.

      +
        +
      • +

        Have a flash blocker? Check that the SM2 flash movie (below) is loading and is not being blocked.

        +
      • +
      • + First time opening SM2 after downloading it? Is your browser URL at file:// or c:/path/ or otherwise not using HTTP? Flash security "whitelisting" is required to allow Flash + JS to work when offline, placing it in the "LocalTrusted" Flash security sandbox rather than "localWithFile". + +
        +

        Offline viewing: Adding a "trusted location" to the Flash Security Settings Panel

        +

        The Flash Player Global Security Settings Panel is a web-based control panel which allows you to configure Flash security. You will need to add the path of the SoundManager 2 project in order for it to work "offline" (ie., when viewing via file:// or c:/)

        +

        Show me how: Adding a "trusted location"

        + +

        Launch the Flash Security Settings Panel

        +
        + +
      • +
      • Flash blockers (FlashBlock, "click to flash" etc.) preventing flash load and start-up - need whitelisting/"allow this domain" to work smoothly. If you suspect blocking is the issue, try the SoundManager 2 Flashblock demo.
      • +
      • Online viewing (HTTP/S): Same-domain security rules apply to HTML + Flash content by default (crossdomain.xml/allowDomain() in .AS source required to override.)
      • +
      +

      See Flash debug output for more security error details.

      + +
      +

      Online viewing: Cross-domain security restrictions

      +

      HTML page on domain A loading .SWF from domain B: Flash security prevents JS + Flash when a cross-domain XML permission file is not available on domain B, and/or flash movie was not compiled with allowDomain('domainA') or allowDomain('*') - note that the SWF distributed with SM2 does not use this by default; try using the cross-domain version of the SWF, or compile your own which whitelists your own domain(s).

      + +

      Flash Blockers

      +

      Browser extensions/add-ons like "FlashBlock" and "click to flash" can prevent the .SWF from loading, and this will mean SM2 will time-out and fail waiting for a response from Flash. For development, it's best to whitelist the domain(s) or the .SWF for SM2 to allow it to work.

      +

      Have a flash blocker installed? Want to test it? Try the SoundManager 2 Flashblock demo.

      + +
      + +
      +
    • + +
    • +

      OKErrorN/AUnknownJS -> Flash

      +
      +

      At this point, Javascript attempts to respond to Flash's initial outgoing Flash -> JS call, completing the test for JS/flash communication. If SM2 does not receive a response from flash, it will eventually fail.

      +

      Offline viewing conditions and cross-domain security rules will prevent Flash <-> JS communication. See the details of Flash -> JS for information.

      +

      Special Firefox Note: Some versions of Firefox (9.0 and newer?) may break JS/Flash in the file:// or offline case even when the path has been whitelisted in the Flash player security settings panel. IE, Chrome, Safari and Opera do not have this issue.

      +
      +
    • + +
    • +

      OKErrorN/AUnknownSound test

      +
      +

      Here, a simple createSound() call is made to test SM2's actual operation. A sound should load and play provided SM2 was able to start successfully.

      +
      +
    • + +
    +
    + +

    Flash detection code from Flash Detect (featureblend.com)

    + +

    Flash Movie Debug Output

    +

    When soundManager.debugFlash = true, Flash will write debug info as text to the flash movie. This can be helpful for troubleshooting Flash/JS issues when timeouts or security errors are involved which prevent Flash from talking to Javascript, potentially hiding useful debug information. A CSS class of flash_debug will also be appended to the Flash #sm2-container DIV element when enabled, if you wish to style it differently.

    +

    You can also specify ?debug=1 in the URL to the SWF, and it will write debug output. Try soundmanager2_debug.swf?debug=1, or soundmanager2_flash9_debug.swf?debug=1.

    + +
    + +
    + +

    Live Debug Output

    +

    SoundManager 2 relies on Javascript and Flash communicating via ExternalInterface, and this is subject to a number of timing, loading and browser security conditions. Because of this complexity, debug information is essential for troubleshooting start-up, loading, initialization and error conditions between Flash and Javascript.

    +

    With debug mode enabled via debugMode = true, SM2 can write helpful troubleshooting information to javascript console.log()-style interfaces. Additionally, output can be written to an optional DIV element with the ID of "soundmanager-debug".

    +

    If loading from the local filesystem (offline eg. file://, not over HTTP), Flash security is likely preventing SM2 from talking to Javascript. You will need to add this project's directory to the trusted locations in the Flash global security settings panel, or simply view this page over HTTP.

    +

    Below is a live example of debug output.

    +
    +
    + +
    +
    +

    For more examples of live debug output, see the Basic Template, API demo and other demos in the top navigation.

    + +

    Standalone version of troubleshooting tool

    +

    For debugging your development/production environment with this widget, see the troubleshooting subdirectory of the SoundManager 2 package.

    + +
    + +
    + +
    + + + +
    + +
    + +
    + +
    + + +
    + + +
    + + +
    + + + + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/index.html new file mode 100755 index 00000000..5463f54d --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/index.html @@ -0,0 +1,1934 @@ + + + +SoundManager 2: Documentation + + + + + + + + + + + + + + + + + +
    + + + +
    + +
    + +
    + + + +
    + + + +
    + +

    API Elements

    + +

    SoundManager and SMSound API

    + + + + +
    + +
    + +
    + +
    + + +
    + +
    +
    +
    + +
    +
    +
    + +
    + +
    + +
    + +

    SoundManager Properties: soundManager.setup()

    + +

    + Just getting started? See the basics. For nicely-formatted, annotated source code, see the pretty-printed version. +

    + +
    + +

    The soundManager object has many configurable properties which set debug mode, determine the flash movie path and other behaviours.

    + +

    When configuring soundManager for your use, soundManager.setup() is the method used to assign these options; for example, soundManager.setup({ url: '/path/to/swfs/', flashVersion: 9 });

    + +

    You should call the setup method before "DOM Ready", which is when SM2 applies configuration and starts up.

    + +

    Below are the default settings for SoundManager 2, which are appropriate for the majority of use cases - you shouldn't need to change them. These parameters are defined and stored in soundManager.setupOptions.

    + +

    Note: The only property requiring customization is url - this defines the path used to look for the appropriate flash SWF for driving audio when HTML5 is not available. (If not specified, the current working path is used.) Aside from flash-specific items like url and flashVersion, most properties can be set after "DOM Ready" without issue.

    + +
    + +
      + +
    • +
      url: '/path/to/swf-files/',
      + // the directory where SM2 can find the flash movies (soundmanager2.swf, soundmanager2_flash9.swf and debug versions etc.) Note that SM2 will append the correct SWF file name, depending on flashVersion and debugMode settings. +
    • + +
    • +
      allowScriptAccess: 'always',
      + // for scripting the SWF (object/embed property), 'always' or 'sameDomain' +
    • + +
    • +
      bgColor: '#ffffff',
      + // SWF background color. N/A when wmode = 'transparent' +
    • + +
    • +
      consoleOnly: true,
      + // if console is being used, do not create/write to #soundmanager-debug +
    • + +
    • +
      debugMode: true,
      + // enable debugging output (console.log() with HTML fallback) +
    • + +
    • +
      debugFlash: false,
      + // enable debugging output inside SWF, troubleshoot Flash/browser issues +
    • + +
    • +
      flashVersion: 8,
      + // flash build to use (8 or 9.) Some API features require 9. +
    • + +
    • +
      flashPollingInterval: null,
      + // msec affecting whileplaying/loading callback frequency. If null, default of 50 msec is used. +
    • + +
    • +
      html5PollingInterval: null,
      + // msec affecting whileplaying/loading callback frequency. If null, native HTML5 update events are used. +
    • + +
    • +
      html5Test: /^(probably|maybe)$/i,
      + // HTML5 Audio() format support test. Use /^probably$/i; if you want to be more conservative. +
    • + +
    • +
      flashLoadTimeout: 1000,
      + // msec to wait for flash movie to load before failing (0 = infinity) +
    • + +
    • +
      idPrefix: 'sound',
      + // if an id is not provided to createSound(), this prefix is used for generated IDs - 'sound0', 'sound1' etc. +
    • + + +
    • +
      noSWFCache: false,
      + // if true, appends ?ts={date} to break aggressive SWF caching. +
    • + +
    • +
      preferFlash: true,
      + // overrides useHTML5audio. if true and flash support present, will try to use flash for MP3/MP4 as needed since HTML5 audio support is still quirky in browsers. +
    • + +
    • +
      useConsole: true,
      + // use console.log() if available (otherwise, writes to #soundmanager-debug element) +
    • + +
    • +
      useFlashBlock: false,
      + // requires flashblock.css, see demos - allow recovery from flash blockers. Wait indefinitely and apply timeout CSS to SWF, if applicable. +
    • + +
    • +
      useHighPerformance: false,
      + // position:fixed flash movie can help increase js/flash speed, minimize lag +
    • + +
    • +
      useHTML5Audio: true,
      + // use HTML5 Audio() where supported. Some browsers may not support "non-free" MP3/MP4/AAC codecs. Ideally, transparent vs. Flash API where possible. +
    • + +
    • +
      waitForWindowLoad: false,
      + // force SM2 to wait for window.onload() before trying to call soundManager.onready() +
    • + +
    • +
      wmode: null
      + // flash rendering mode - null, 'transparent', or 'opaque' (last two allow z-index) +
    • + + +
    + +
    + +

    Legacy support note: The new approach defines top-level properties in soundManager.setupOptions. The old approach was to assign properties directly to the soundManager instance. Thus, when soundManager.setup({ url: ... }); is called, the updated property value is assigned to both soundManager.setupOptions.url and soundManager.url. You can assign soundManager.url directly as with the old method, but it is recommended to use the new setup()-based method for forward compatibility.

    + +
    + +

    Bonus: Extended soundManager.setup() Parameters

    + +

    As it is common to configure soundManager properties and related events all at once, you can also pass onready and ontimeout parameters which will be called as if you had used soundManager.onready() and soundManager.ontimeout().

    + +

    You can also provide values from the following top-level soundManager properties:

    + +
      +
    • defaultOptions: {...} (global defaults for new sound objects)
    • +
    • flash9Options: {...} (API feature options specific to Flash 9)
    • +
    • movieStarOptions: {...} (Flash 9-only NetStream/RTMP-specific options)
    • +
    + +
    soundManager.setup({
    +  url: '/path/to/swfs/',
    +  flashVersion: 9,
    +  preferFlash: false, // prefer 100% HTML5 mode, where both supported
    +  onready: function() {
    +    // console.log('SM2 ready!');
    +  },
    +  ontimeout: function() {
    +    // console.log('SM2 init failed!');
    +  },
    +  defaultOptions: {
    +    // set global default volume for all sound objects
    +    volume: 33
    +  }
    +});
    + +
    + +
    + +
    +

    debugFlash

    +

    soundManager.debugFlash configures SM2's flash debugging output, disabled (false) by default. When enabled, the Flash portion of SM2 will write debug statements within the Flash movie. This can be useful for troubleshooting Flash/JS/browser (ExternalInterface) issues and so on.

    +

    A CSS class of flash_debug will also be appended to the Flash #sm2-container DIV element when enabled, if you wish to style it differently.

    +

    For a live example, see Flash Movie Debug Output in the Troubleshooting section.

    +
    + +
    +

    debugMode

    +

    soundManager.debugMode configures SM2's debug behaviour, enabled (true) by default. When enabled, SoundManager 2 will write console-like output to console.log()-style javascript interfaces, and/or an HTML element with the ID soundmanager-debug (will be created if not found in the DOM at runtime.)

    +

    For a live example of debug output, see Debug + Console Output.

    +
    + +
    + +

    flashVersion

    + +

    SoundManager 2 started with a Flash 8 base requirement, but can also use Flash 9 and take advantages of some unique features Flash 9 offers. By default Flash 8 will be used, but the version can be easily changed by setting flashVersion appropriately.

    + +

    Example: soundManager.setup({ flashVersion: 9 });

    + +

    The Flash 8 version is soundmanager2.swf, and the flash 9 version is soundmanager2_flash9.swf, accordingly. Note that only Flash 8 and Flash 9 are supported at this time; other values will result in errors.

    + +
    + +
    + +

    Flash 9-only features:

    + +
      +
    • MPEG-4 (HE-AAC/H.264) audio support
    • +
    • True "multi-shot" sound behaviour. play() can be called multiple times, giving a layered, "chorus" effect. Sound will also fire onfinish() multiple times. (Previous behaviour did not layer sounds, but would re-play a single instance.)
    • +
    • waveformData array: 256 waveform data values available while playing sound
    • +
    • eqData array: 256 EQ spectrum data values available while playing sound
    • +
    • peakData object: Left and right channel peak/volume data available while playing sound
    • +
    + +
    + +
    +

    flashLoadTimeout

    +

    After initializing the flash component during start-up, SM2 will wait for a defined period of time before timing out and calling soundManager.onerror().

    +

    The default value is 1000 (msec.) Setting a value of 0 disables the timeout and makes SM2 wait indefinitely for a call from the flash component. If you want to handle flash block-type situations, see soundManager.useFlashBlock.

    +

    Setting this parameter to 0 may be useful when attempting to gracefully recover from a flashBlock situation, where the user has whitelisted the movie after it was blocked etc.

    +

    Note that when the timeout is disabled, soundManager will not fire its onerror() handler if there is an error at the flash loading stage.

    +
    + +
    +

    flashPollingInterval

    +

    Setting this will override useFastPolling, and defines the interval of the internal flash timer used for callbacks to sound events like whileloading() and whileplaying(). For example, set this to 200 to have 200ms intervals. This is useful in the case where your callbacks are CPU intensive, or you simply wish to throttle your calls to be more CPU-conservative.

    +
    + +
    +

    html5PollingInterval

    +

    Setting this will enable a single interval that will affect the frequency of event callbacks such whileplaying() for HTML5 sounds, with the exclusion of mobile devices. If null, native HTML5 update events are used. The frequency of native events may vary widely across browsers, and may exceed 500 msec on mobile and other resource-limited devices.

    +

    By default, Flash uses a 50-msec timer interval and this is a reasonable value to apply to html5PollingInterval for desktop use cases.

    +
    + +
    +

    preferFlash

    +

    This property handles "mixed-mode" HTML5 + flash cases, and may prevent 100% HTML5 mode when enabled depending on the configuration of soundManager.audioFormats. In the event HTML5 supports the default "required" formats (presently MP3), and preferFlash is true (and flash is installed), flash will be used for MP3/MP4 content while allowing HTML5 to play OGG, WAV and other supported formats.

    +

    Important note: Because HTML5 audio has some bugs across various browsers and operating systems, preferFlash is true by default to help ensure MP3/MP4 play consistently. If set to false or flash is not available, "HTML5-only" mode will kick in and will apply to all formats.

    +

    To encourage 100% HTML5 mode, call soundMangager.setup({ preferFlash: false }) and then Flash will not be used for MP3/MP4 playback, provided that HTML5 supports them.

    +
    + +
    +

    url

    +

    soundManager.url, applied via soundManager.setup(), specifies the "online", generally HTTP-based path which SM2 will load .SWF movies from. The "local" (current) path of ./ will be used by default. The appropriate .SWF required (depending on the desired Flash version) will be appended to the URL.

    +

    Example: soundManager.setup({ url: '/path/to/swf-directory/' }); (Note trailing slash)

    +

    For a simple demo of this in action, see the basic template.

    +

    For cases where SM2 is being used "offline" in non-HTTP cases (eg., development environments), see altURL.

    +
    + +
    +

    useFastPolling

    +

    By default useFastPolling = false, and thus SoundManager uses a 50-millisecond timer inside Flash when polling for updated sound properties such as bytesLoaded and data and event callbacks eg. whileloading(), whileplaying() and so on. With useFastPolling = true, a 10-msec timer is used and callback frequency may noticeably increase. This is best combined with useHighPerformance for optimal results.

    +
    + +
    +

    useFlashBlock

    +

    Flash blockers (eg. FlashBlock, "Click To Flash") can prevent the flash portion of SM2 from loading, which will cause a start-up error with a time-out.

    +

    SM2 historically has kept the flash movie off-screen and out of view, and thus the user could not click on and unblock it. Now with useFlashBlock = true, the movie positioning can be handled by CSS. The initial state is still off-screen by default, but will change to be in view when a blocking (time-out) situation may be encountered. You can also edit the CSS to taste, of course.

    +

    When starting up, CSS classes are appended to the #sm2-container DIV (which you can provide, or SM2 will create and append to the document.) The CSS classes change with the state of SM2's start-up, eg. #sm2-container.swf_timedout { border:1px solid red; } could be used to highlight the movie to the user for unblocking and so on.

    +

    Setting useFlashBlock = true will cause SM2 to wait infinitely for the Flash content to load after an initial (non-fatal) timeout, having already waited for flashLoadTimeout to pass. If flashLoadTimeout = 0, SM2 will immediately go into "flash block mode" on start-up.

    +

    The relevant CSS is as follows:

    +
    #sm2-container {
    + /**
    +  * Initial/default state...
    +  * position:absolute/off-screen, or left/top:0
    +  */
    +}
    +
    +#sm2-container.swf_timedout {
    +  /**
    +   * Didn't load before time-out, show to user.
    +   * Maybe highlight on-screen, red border, etc..? 
    +   */
    +}
    +
    +#sm2-container.swf_unblocked {
    +  /**
    +   * Applied if movie loads successfully
    +   * (flash started, so move off-screen etc.)
    +   */
    +}
    +
    +#sm2-container.swf_error {
    +  /**
    +   * "Fatal" error case: SWF loaded, but SM2 was unable to start.
    +   * (Flash security or other error case.)
    +   */
    +}
    +
    +#sm2-container.high_performance {
    +  /**
    +   * Additional modifier for "high performance" mode
    +   * should apply position:fixed and left/bottom 0 to stay on-screen
    +   * at all times (better flash performance)
    +   */
    +}
    +
    +#sm2-container.flash_debug {
    +  /**
    +   * Additional modifier for flash debug output mode
    +   * should use width/height 100% so you can read debug messages
    +   */
    +}
    + +

    For a live example, see the FlashBlock Demo.

    +
    + +
    +

    useHighPerformance

    +

    Perhaps intuitively, Flash is given higher priority when positioned within the viewable area of the browser, at least 6px in height (oddly), fully-opaque, visible and displayed on the screen. By default, useHighPerformance is disabled. When enabled, it may noticeably reduce JS/flash lag and increase the frequency of callbacks such as whileplaying() in some circumstances.

    +

    soundManager.setup({useHighPerformance: true});

    +

    This has made a noticeable impact in responsiveness on Mac OS X, and Safari on Windows; animation lag is practically non-existent (see demo). Because setting wmode=transparent and fixed position has been reported to cause some issues, the feature is disabled by default.

    +

    To be least-obtrusive, SM2 attempts to set position:fixed, and uses bottom/left:0px to stay within view (though using wmode=transparent where possible, to be hidden from view.) It occupies an 8x8px square. If you wish to position the movie yourself or show it inline, have a DIV element with the ID of sm2-container present in the DOM for SM2 to reference and it will write the movie there without positioning.

    +
    + +
    + +

    useHTML5Audio

    + +

    HTML5 support is in active development. See Revision History for the latest updates on HTML5 playback support.

    + +

    useHTML5Audio determines whether HTML5 Audio() support is used (as available) to play sound, with flash as the fallback for playing MP3 and MP4 (AAC) formats. Browser support for HTML5 Audio varies, and format support (eg. MP3, MP4/AAC, OGG, WAV) can vary by browser/platform.

    + +

    The SM2 API is effectively transparent, consistent whether using flash or HTML5 Audio() for sound playback behind the scenes. The HTML5 Audio API is roughly equivalent to the flash 8 feature set, minus ID3 tag support and a few other items. (Flash 9 features like waveform data etc. are not available in HTML5 mode.)

    + +

    By default, "100% HTML5 mode" applies to Apple iPad 3.2+ (iPad version 1.0), iPhone / iOS 4.0+ devices and others without flash. In other cases, HTML5 support is tested and if MP3/MP4 aren't natively supported, flash will be used as a backup method of playing these "required" formats. (It is assumed MP3 playback is required by default, but this is user-configurable via soundManager.audioFormats.) HTML5 may also enable support for additional formats such as OGG and WAV.

    +

    On the desktop and other devices with flash support, SM2 will still try for 100% HTML5 mode by default. However, you can use soundManager.setup({ preferFlash: true }) if you would like to have Flash play MP3 and MP4 (AAC) formats even when they are supported via HTML5.

    + +
    SoundManager 2 + useHTML5Audio: Init Process
    + +

    At DOM ready (if useHTML5Audio = true), a test for Audio() is done followed by a series of canPlayType() tests to see if MP3, MP4, WAV and OGG formats are supported. If any of the "required" formats (by default, MP3) are not supported via HTML5, or if preferFlash = true and MP3 or MP4 are required, then flash is also added as a requirement for SM2 to start.

    + +

    soundManager.audioFormats defines the list of formats to check (MP3, MP4 and so on), their possible canPlayType() strings (long story short, it's complicated) and whether or not they are "required" - that is, whether flash should be loaded if they don't work under HTML5. (Again, only MP3 + MP4 are supported by flash.) If you had a page solely using OGG, you could make MP3/MP4 non-required, but many browsers do not play OGG files natively.

    + +

    SM2 will indicate its state (HTML 5 support or not, using flash or not) in console.log()-style debug output messages when debugMode = true.

    + +
    "My browser does HTML5, why not MP3"?
    + +

    Despite best efforts, some browsers eg. Chrome on Windows may only return "maybe" for Audio().canPlayType('audio/mpeg; codecs=mp3') and variants; SoundManager 2 will presently assume a format is supported if a "probably" or "maybe" response is given. You can modify html5Test to be /probably/i if you want to be more strict, for example.

    + +

    Safari, IE 9, and Chrome (excluding Chromium?) support the "non-free" MP3 and MP4 (including AAC) formats. Firefox, in some cases, does support the MP3 codec where the underlying OS has support for it. This includes Windows Vista (and newer), and as of November 2013, Firefox Aurora (development builds) also on OS X.

    +

    For the cases where MP3 is not supported via HTML5, flash is used as the fallback support for MP3/MP4 as needed. Additionally, if flash support is present, soundManager.preferFlash means that MP3/MP4 will be handled by flash even if HTML5 support is present for those formats.

    + +
    Additional HTML5 formats: OGG, WAV
    + +

    WAVe (uncompressed audio) and OGG (a free/open-source alternative to MP3) are both supported in a majority of browsers via HTML5, so SoundManager 2 will also test for support for these formats. A flash fallback for these formats has not been implemented. In 2011, Adobe suggested they would support OGG audio + video (combined, the "WebM" format) in a future release of flash. As of November 2013, this has yet to materialize.

    + +

    You may need to make a few server configuration updates given the importance of MIME types and the use of certain HTTP headers when serving audio to HTML5 clients. See Client Requests for more.

    + +

    HTML5 is not limited to OGG and WAV, of course, as the system is designed to be extensible. Support for other formats may exist, depending on what built-in support exists, and plug-ins or codecs the user has installed on their system.

    + +
    Testing audio format support
    + +

    Once soundManager.onready() has fired and SM2 has started, you can check for support via a number of methods. Namely, soundManager.canPlayLink() will take an <a> element and check its href and type attributes, if available, for hints as to its format or type. You can also pass arbitrary URLs to soundManager.canPlayURL(), which will make a "best guess" based on the extension it finds. In any event, SM2 will return a true/false value from canPlay methods based on HTML and/or flash capabilities.

    + +

    To see what formats are supported by HTML5, watch SM2's debug/console output when debug is enabled, or dump the contents of soundManager.html5 to the console; it will show the results of tests for simple items like "mp3", as well as canPlayType() strings such as 'mpeg; codecs=mp3'

    + +
    Apple iPad, iPhone, Palm Pre: Special Cases
    +

    The "Big iPhone" doesn't do Flash, and does support HTML5 Audio() pretty decently - so SM2 makes a special exception to enable useHTML5Audio when it detects an iPad, iPhone or Palm Pre user agent string by default. Feel free to disable this if you wish.

    +

    iPad and iPhone require user interaction to start a sound, eg. the createSound() and play() call should happen within an onclick() handler on a link, etc. The "security" model here seems to be implemented similarly to the way pop-up blockers work. You may "chain" sounds (eg. create and play a new one) provided it is done via the onfinish() event of a sound initiated by a user, however. The Muxtape-style demo on the SM2 homepage uses this, and will advance the playlist on the iPad/iPhone if allowed.

    +

    iPad 3.2 gets hung up on the "BC quail" HE-AAC example sound for some reason, and endlessly loops it rather than finishing and moving on to the next item. May be an iPad playback bug, as other formats are fine. iPhone OS 4 (iOS 4) does not show this issue.

    +

    iPhone OS version < 3.1 doesn't work, but 3.1 (and possibly earlier versions, not verified) have a native Audio() object. However, they seem to simply not play sound when play() is called, so SM2 looks for and ignores the iPhone with these OS revisions.

    +

    The Palm Pre supports a number of MP3, MP4 and WAV formats (WebOS 1.4.1 was tested; it didn't seem to like MP3s at 192kbps, but 128kbps was fine.)

    + +
    General Disclaimer
    +

    HTML5 audio support may still be in flux, and may not be fully-supported or implemented consistently in modern browsers. Be careful out there.

    + +
    Related Reading on HTML5
    +

    For some more backstory on HTML and audio, see the 24ways.org article "Probably, Maybe, No": The State Of HTML5 Audio (published December, 2010.)

    + +
    + +
    +

    wmode

    +

    The wmode property is applied directly to the flash movie, and can be either null, 'window', 'transparent' or 'opaque'. By default if useHighPerformance is enabled, transparency will be attempted by SM2 unless there are known issues with the rendering mode.

    +

    It appears that non-IE browsers on Windows will not load SWF content "below the fold" (out of scrollable view) when wmode is set to anything other than null (window). This will break SM2 as it expects Flash to load within a reasonably short amount of time - so SM2 by default will reset wmode for this case. If you wish to force retention of your wmode, set soundManager.flashTimeout = 0 which will ensure that if the content is below the fold, SM2 will not time out waiting for it to load.

    +

    Additionally, soundManager.specialWmodeCase will be set to true if wmode has been reset due to this special condition.

    +
    + + +
    + +

    SoundManager Top-Level Properties

    + +

    A few additional properties that hang off the soundManager instance object

    + +
    + +
    +

    soundManager.altURL

    +

    soundManager.altURL specifies an alternate path to soundManager.setupOptions.url which SM2 can load its SWF from. It is a simple convenience for when you may need to load SWFs from different paths depending on your hosting environment (eg., offline development vs. production.)

    +

    Example: soundManager.altURL = '../'; (Load from parent directory - note trailing slash)

    +

    For altURL to be used, it must be defined and an "alternate environment" condition must be met:

    +

    soundManager.useAltURL = (!document.location.protocol.match(/http/i));

    +

    By default and as shown above, SM2 will use this property when the hosting page is not being served over HTTP, and thus is assumed to being served "offline" - for example, when loading via file://, from the local file system.

    +

    This can easily be adapted to taste, eg., checking the domain matching yourdomain.com vs. localhost:

    +

    soundManager.useAltURL = (!document.location.match(/mydomain.com/i));

    +

    If soundManager.altURL is null (the default), soundManager.setupOptions.url will be used for all cases.

    +
    + +
    +

    soundManager.audioFormats

    + +

    soundManager.audioFormats defines a structure listing the audio codecs that will be tested for support under both HTML5 and Flash. Each type is defined by a file extension and MIME types, and optionally, a list of related extensions (eg. MPEG-4 content can be in an .mp4 file, but may also be .aac, or .m4a.)

    + +

    Additionally, each format can be defined as "required", meaning that SM2 can fail to start if playback support is not found via either HTML5 or Flash. By default, MP3 is a required format.

    +
    soundManager.audioFormats = {
    +
    +  /**
    +   * determines HTML5 support + flash requirements.
    +   * if no support (via flash/HTML5) for "required" format, SM2 will fail to start.
    +   * flash fallback is used for MP3 or MP4 if lacking HTML5 (or preferFlash = true)
    +   * multiple MIME types may be tried looking for positive canPlayType() response.
    +   */
    +
    +  'mp3': {
    +    'type': ['audio/mpeg; codecs="mp3"', 'audio/mpeg', 'audio/mp3', 'audio/MPA', 'audio/mpa-robust'],
    +    'required': true
    +  },
    +
    +  'mp4': {
    +    'related': ['aac','m4a'], // additional formats under the MP4 container
    +    'type': ['audio/mp4; codecs="mp4a.40.2"', 'audio/aac', 'audio/x-m4a', 'audio/MP4A-LATM', 'audio/mpeg4-generic'],
    +    'required': false
    +  },
    +
    +  'ogg': {
    +    'type': ['audio/ogg; codecs=vorbis'],
    +    'required': false
    +  },
    +
    +  'wav': {
    +    'type': ['audio/wav; codecs="1"', 'audio/wav', 'audio/wave', 'audio/x-wav'],
    +    'required': false
    +  }
    +
    +};
    + +
    + + +
    + + +
    + +
    + +
    + +
    + +

    soundManager Global Object

    + +

    This is a collection of methods, properties and event handlers available via the soundManager Javascript object. Sound properties and methods can be set on a global (inherited) default, or per-sound basis.

    + +
    + + + +
    +
    canPlay:boolean canPlayMIME(MIMEtype:string)
    +
    Returns a boolean indicating whether soundManager can play the given MIME type - eg., audio/mp3. The types supported vary based on Flash version and MPEG4 (MovieStar mode) options.
    +
    + MIME type patterns are as follows: +
      +
    • Defaults: /^audio\/(?:x-)?(?:mp(?:eg|3))\s*;?/i; - eg. audio/mp3 or audio/mpeg
    • +
    • MovieStar-only formats: /^audio\/(?:x-)?(?:mp(?:eg|3)|mp4a-latm|aac|speex)\s*;?/i; - eg. audio/m4a or audio/aac
    • +
    +
    +
    Example: +
    // link example: <a id="song1" href="foo.php?songID=1" type="audio/mp3">play #1</a>
    +var aLink = document.getElementById('song1');
    +if (soundManager.canPlayMIME(aLink.type)) {
    + soundManager.createSound('song1Sound', aLink.href);
    +}
    +
    If no type attribute is found, this method will return null instead of false.
    +
    + +
    +
    canplay:boolean canPlayURL(mediaURL:string)
    +
    Returns a boolean indicating whether soundManager can play the given URL. Playability is determined by a matching URL pattern set at runtime, based on Flash version and MPEG4 (MovieStar mode) support.
    +
    Example: +
    var sURL = '/path/to/some.mp3';
    +if (soundManager.canPlayURL(sURL)) {
    + soundManager.createSound('fooSound', sURL);
    +}
    +
    If no href attribute is found, this method will return null instead of false.
    +
    + +
    +
    object:SMSound clearOnPosition(id:string, msecOffset:integer, [callback:function])
    +
    Clears the event listener set via onPosition(), in the same way it was registered. If the callback is omitted, any and all callbacks registered for the given offset will be cleared.
    +
    Example: soundManager.clearOnPosition('mySound', 3000, positionHandler);
    +
    Example 2: soundManager.clearOnPosition('mySound', 3000);
    +
    + +
    + +
    object:SMSound createSound(object:options)
    +
    Creates a sound object, supporting an arbitrary number of optional arguments. Returns a SMSound object instance. At minimum, a url parameter is required.
    +
    + Minimal example: +
    var someSound = soundManager.createSound({ 
    +  url: '/path/to/an.mp3'
    +});
    +
    +
    + With optional parameters: +
    var mySoundObject = soundManager.createSound({
    + // optional id, for getSoundById() look-ups etc. If omitted, an id will be generated.
    + id: 'mySound',
    + url: '/audio/mysoundfile.mp3',
    + // optional sound parameters here, see Sound Properties for full list
    + volume: 50,
    + autoPlay: true,
    + whileloading: function() { console.log(this.id + ' is loading'); }
    +});
    +

    Each createSound() call results in the creation of a SMSound object which stores all properties, methods and events relevant to that particular sound instance. If you keep the SMSound object in scope, you probably don't need to specify an ID. However, if you do provide an id, you can easily get a reference to the given sound via soundManager.getSoundById() (for the above example, you would use mySound.)

    +

    When specifying an id you can also use controller-level convenience methods, i.e., soundManager.play('mySound'), soundManager.stop('mySound') and so on.

    +

    Individual sound objects can also easily be referenced as returned from createSound():

    +
    var mySoundObject = soundManager.createSound({
    + url: '/audio/mysoundfile.mp3'
    +});
    +mySoundObject.play(); // SMSound object instance
    + +

    For more SMSound parameters, see Object Literal Format.

    +
    +
    If createSound is called with the ID of an existing sound, that sound object will be returned "as-is". Any other createSound options passed (eg., url or volume, etc.) will be ignored.
    + +
    + +
    +
    object:SMSound createSound(id:string, url:string) - overloaded method
    +
    Creates a sound with the specified ID and URL (simple two-parameter method.)
    +
    Example: soundManager.createSound('mySound','/audio/mysoundfile.mp3');
    +
    + +
    +
    destroySound(id:string)
    +
    Stops, unloads and destroys a sound specified by ID.
    +
    Example: soundManager.destroySound('mySound');
    +
    SMSound equivalent example: mySound.destruct();
    +
    + +
    +
    object:SMSound mute([id:string])
    +
    Mutes the sound specified by ID and returns that sound object. If no ID specified, all sounds will be muted and null is returned. Affects muted property (boolean.)
    +
    Example: soundManager.mute('mySound');
    +
    + +
    +
    object:SMSound onPosition(id:string, msecOffset:integer, callback:function, [scope])
    +
    Registers an event listener, fired when a sound reaches or passes a certain position while playing. Position being "listened" for is passed back to event handler. Will also fire if a sound is "rewound" (eg. via setPosition() to an earlier point) and the given position is reached again. Listeners will be removed if a sound is unloaded. An optional scope can be passed as well.
    +
    Note that for multiShot cases, only the first play instance's position is tracked in Flash; therefore, subsequent "shots" will not have onPosition() events being fired.
    +
    Example: soundManager.onPosition('mySound', 3000, function(eventPosition){console.log(this.id+' reached '+eventPosition});
    +
    + +
    +
    onready(callback:function, [scope])
    +
    Queues an event callback/handler for successful initialization and "ready to use" state of SoundManager 2. An optional scope parameter can be specified; if none, the callback is scoped to the window. If onready() is called after successful initialization, the callback will be executed immediately. The onready() queue is processed before soundManager.onload().
    +
    Example: +
    soundManager.onready(function() {
    +  alert('Yay, SM2 loaded OK!');	
    +});
    +
    +
    Queueing multiple handlers: soundManager.onready(myOnReadyHandler); soundManager.onready(myOtherHandler);
    +
    The same listener may be added multiple times; there is no duplicate checking. Queue is processed in order of addition.
    +
    If soundManager.reboot() is called, all listeners' "fired" flags will be reset and they will be eligible to fire again when SM2 starts.
    +
    This method can also be used via soundManager.setup({ onready: function() { ... } });
    +
    + +
    +
    ontimeout(callback:function, [scope])
    +
    Queues an event callback/handler for SM2 init failure, processed at (or immediately, if added after) SM2 initialization has failed, just before soundManager.onerror() is called. An optional scope parameter can be specified; if none, the callback is scoped to the window.
    +
    Additionally, a status object containing success and error->type parameters is passed as an argument to your callback.
    +
    Example: +
    soundManager.ontimeout(function(status) {
    +  alert('SM2 failed to start. Flash missing, blocked or security error?');
    +  alert('The status is ' + status.success + ', the error type is ' + status.error.type);
    +});
    +
    +
    Queueing multiple handlers: soundManager.ontimeout(myOnTimeoutHandler); soundManager.ontimeout(myOtherHandler);
    +
    The timeout event is not necessarily fatal, as SM2 may be rebooted and fire an onready() in the useFlashBlock case (where the user sees, and chooses to unblock the Flash component after a failed init attempt.)
    +
    The same listener may be added multiple times; there is no duplicate checking. Queue is processed in order of addition.
    +
    If soundManager.reboot() is called, all listeners' "fired" flags will be reset and they will be eligible to fire again when SM2 starts.
    +
    This method can also be used via soundManager.setup({ ontimeout: function() { ... } });
    +
    + +
    +
    object:SMSound play(id:string, [options object])
    +
    Starts playing the sound specified by ID. (Will start loading if applicable, and will play ASAP.)
    +
    Returns an SMSound (sound object) instance.
    +
    Example: soundManager.play('mySound');
    +
    Note that the second parameter, options object, is not required and can take almost any argument from the object literal format (eg. volume.) It is convenient when you wish to override the sound defaults for a single instance.
    +
    Example: soundManager.play('mySound',{volume:50,onfinish:playNextSound});
    +
    + +
    +
    object:SMSound pause(id:string)
    +
    Pauses the sound specified by ID. Does not toggle. Affects paused property (boolean.) Returns the given sound object.
    +
    Example: soundManager.pause('mySound');
    +
    + +
    +
    pauseAll()
    +
    Pauses all sounds whose playState is >0. Affects paused property (boolean.)
    +
    Example: soundManager.pauseAll();
    +
    + +
    +
    reboot()
    +
    Destroys any created SMSound objects, unloads the flash movie (removing it from the DOM) and restarts the SM2 init process, retaining all currently-set properties.
    +
    Example: +
    soundManager.ontimeout(function() {
    +  // Something went wrong during init - in this example, we *assume* flashblock etc.
    +  soundManager.flashLoadTimeout = 0; // When restarting, wait indefinitely for flash
    +  soundManager.onerror = {}; // Prevent an infinite loop, in case it's not flashblock
    +  soundManager.reboot(); // and, go!
    +});
    +
    +
    This method may be helpful when trying to gracefully recover from FlashBlock-type situations where the user has prevented the SWF from loading, but is able to whitelist it. For more ideas, see Flashblock demo.
    +
    When using this method also consider flashLoadTimeout, which can have SM2 wait indefinitely for the flash to load if desired.
    +
    + +
    +
    reset()
    +
    Effectively restores SoundManager's original state without rebooting (re-initializing).
    +
    Similar to reboot() which destroys sound objects and the flash movie (as applicable), but also nukes any registered onready() and related callbacks.
    +
    Once soundManager.reset() has been called, soundManager.beginDelayedInit() (or soundManager.setup() with a url property) may be called to re-init SM2.
    +
    + +
    +
    object:SMSound resume(id:string)
    +
    Resumes and returns the currently-paused sound specified by ID.
    +
    Example: soundManager.resume('mySound');
    +
    + +
    +
    resumeAll()
    +
    Resumes all currently-paused sounds.
    +
    Example: soundManager.resumeAll();
    +
    + +
    +
    object:SMSound setPan(id:string,volume:integer)
    +
    Sets the stereo pan (left/right bias) of the sound specified by ID, and returns the related sound object. Accepted values: -100 to 100 (L/R, 0 = center.) Affects pan property.
    +
    Example: soundManager.setPan('mySound',-80);
    +
    + +
    +
    object:SMSound setPosition(id:string,msecOffset:integer)
    +
    Seeeks to a given position within a sound, specified by miliseconds (1000 msec = 1 second) and returns the related sound object. Affects position property.
    +
    Example: soundManager.setPosition('mySound',2500);
    +
    Can only seek within loaded sound data, as defined by the duration property.
    +
    + +
    +
    object:SMSound setVolume(id:string, volume:integer)
    +
    Sets the volume of the sound specified by ID and returns the related sound object. Accepted values: 0-100. Affects volume property.
    +
    Example: soundManager.setVolume('mySound',50);
    +
    + +
    +
    object:SMSound stop(id:string)
    +
    Stops playing the sound specified by ID. Returns the related sound object.
    +
    Example: soundManager.stop('mySound');
    +
    + +
    +
    stopAll()
    +
    Stops any currently-playing sounds.
    +
    Example: soundManager.stopAll();
    +
    + +
    +
    object:SMSound toggleMute(id:string)
    +
    Mutes/unmutes the sound specified by ID. Returns the related sound object.
    +
    Example: soundManager.toggleMute('mySound');
    +
    + +
    +
    object:SMSound togglePause(id:string)
    +
    Pauses/resumes play on the sound specified by ID. Returns the related sound object.
    +
    Example: soundManager.togglePause('mySound');
    +
    + +
    +
    object:SMSound unload(id:string)
    +
    Stops loading the sound specified by ID, canceling any current HTTP request. Returns the related sound object.
    +
    Example: soundManager.unload('mySound');
    +
    Note that for Flash 8, SoundManager does this by pointing the sound object to about:blank, which replaces the current one from loading.
    +
    + +
    +
    object:SMSound unmute([id:string])
    +
    Unmutes the sound specified by ID. If no ID specified, all sounds will be unmuted. Affects muted property (boolean.) Returns the related sound object.
    +
    Example: soundManager.unmute('mySound');
    +
    + +
    +
    object:SMSound load(id:string, [options object])
    +
    Starts loading the sound specified by ID, with options if specified. Returns the related sound object.
    +
    Example: soundManager.load('mySound');
    +
    Example 2: soundManager.load('mySound',{volume:50,onfinish:playNextSound});
    +
    + +
    +
    object:SMSound getSoundById(id:string)
    +
    Returns an SMSound object specified by ID, or null if a sound with that ID is not found.
    +
    Example: var mySMSound = soundManager.getSoundById('mySound');
    +
    + +
    +
    number:bytesUsed getMemoryUse()
    +
    Returns the total number of bytes allocated to the Adobe Flash player or Adobe AIR, or 0 if unsupported (Flash 9+ only.) This number may include memory use across all tabs, browsers etc. See system.totalMemory (livedocs.adobe.com)
    +
    Example: var mbUsed = (soundManager.getMemoryUse()/1024/1024).toFixed(2); // eg. 12.05 MB
    +
    + +
    +
    isSupported:boolean ok() ( previous name: supported() )
    +
    Returns a boolean indicating whether soundManager has attempted to and succeeded in initialising. This function will return false if called before initialisation has occurred, and is useful when you want to create or play a sound without knowing SM2's current state.
    +
    Example: var isSupported = soundManager.ok();
    +
    + +
    + +
    + +
    + +
    + +
    + +

    Sound Object Methods

    + +

    Each sound under SoundManager 2 is given a SMSound object instance which includes the following events, methods and properties. Note that most methods will return the sound object instance, allowing for method chaining if desired.

    + +
    +
    object:SMSound clearOnPosition(msecOffset:integer, [callback:function])
    +
    Clears the event listener set via onPosition(), in the same way it was registered. If the callback is omitted, any and all callbacks registered for the given offset will be cleared.
    +
    Example: mySound.clearOnPosition(3000, positionHandler);
    +
    Example 2: mySound.clearOnPosition('mySound', 3000);
    +
    + +
    +
    destruct()
    +
    Stops, unloads and destroys a sound, freeing resources etc.
    +
    Example: mySound.destruct();
    +
    + +
    +
    object:SMSound load([options object])
    +
    Starts loading the given sound, with options if specified.
    +
    Example: mySound.load();
    +
    Example 2: mySound.load({volume:50,onfinish:playNextSound});
    +
    + +
    +
    object:SMSound mute()
    +
    Mutes the given sound. Affects muted property.
    +
    Example: mySound.mute();
    +
    + +
    +
    object:SMSound onPosition(msecOffset:integer, callback:function, [scope])
    +
    Registers an event listener, fired when a sound reaches or passes a certain position while playing. Position being "listened" for is passed back to event handler. Will also fire if a sound is "rewound" (eg. via setPosition() to an earlier point) and the given position is reached again. Listeners will be removed if a sound is unloaded. An optional scope can be passed as well.
    +
    Note that for multiShot cases, only the first play instance's position is tracked in Flash; therefore, subsequent "shots" will not have onPosition() events being fired.
    +
    Example: mySound.onPosition(3000, function(eventPosition){console.log(this.id+' reached '+eventPosition});
    +
    If you need to fire an event relative to the true duration of the sound, reference its duration once the sound has fully-loaded - ie., at or after the onload() event - as the duration will not be completely accurate until that time. durationEstimate may be referenced before onload(), but it should not be relied on when "precise" timings of say, < 1 second are desired.
    +
    Example:
    mySound.load({
    +  onload: function() {
    +    this.onPosition(this.duration * 0.5, function(eventPosition) {
    +      console.log('the sound ' + this.id + ' is now at position ' + this.position + ' (event position: ' + eventPosition + ')');
    +    });
    +  }
    +});
    +
    +
    Again, note that due to the interval / polling-based methods of both HTML5 and flash audio, sound status updates and thus precision can vary between 20 msec to perhaps 0.5 seconds and the sound's position property will reflect this delta when the onPosition() callback fires.
    + +
    + +
    +
    object:SMSound pause()
    +
    Pauses the given sound. (Does not toggle.) Affects paused property (boolean.)
    +
    Example: mySound.pause();
    +
    + +
    +
    object:SMSound play([options object])
    +
    Starts playing the given sound, with an optional options object. (Will start loading if applicable, and will play ASAP.)
    +
    Note that the options object parameter is not required and can take almost any argument from the object literal format (eg. volume.)
    +
    Example: mySound.play('mySound',{volume:50,onfinish:playNextSound});
    +
    + +
    +
    object:SMSound setPosition(msecOffset:integer)
    +
    Seeks to a given position within a sound, specified by miliseconds (1000 msec = 1 second.) Affects position property.
    +
    Example: mySound.setPosition(2500);
    +
    Can only seek within loaded sound data, as defined by the duration property.
    +
    + +
    +
    object:SMSound resume()
    +
    Resumes the currently-paused sound. Does not affect currently-playing sounds.
    +
    Example: mySound.resume();
    +
    + +
    +
    object:SMSound setPan(volume:integer)
    +
    Sets the stereo pan (left/right bias) of the given sound. Accepted values: -100 to 100 (L/R, 0 = center.) Affects pan property.
    +
    Example: mySound.setPan(-80);
    +
    + +
    +
    object:SMSound setVolume(volume:integer)
    +
    Sets the volume of the given sound. Accepted values: 0-100. Affects volume property.
    +
    Example: mySound.setVolume(50);
    +
    + +
    +
    object:SMSound toggleMute()
    +
    Mutes/unmutes the given sound. Affected muted property (boolean.)
    +
    Example: mySound.toggleMute();
    +
    + +
    +
    object:SMSound togglePause()
    +
    Pauses/resumes play of the given sound. Will also start a sound if it is has not yet been played.
    +
    Example: mySound.togglePause();
    +
    + +
    +
    object:SMSound stop()
    +
    Stops playing the given sound.
    +
    Example: mySound.stop();
    +
    + +
    +
    object:SMSound unload()
    +
    Stops loading the given sound, canceling any current HTTP request.
    +
    Example: mySound.unload();
    +
    Note that for Flash 8, SoundManager does this by pointing the sound object to about:blank, which replaces the current one from loading.
    +
    + +
    +
    object:SMSound unmute()
    +
    Unmutes the given sound. Affects muted property.
    +
    Example: mySound.unmute();
    +
    + +
    + +
    + +
    + +
    + +
    + +
    + +

    Sound Object Events

    + +

    Like native javascript objects, each SoundManager SMSound (sound instance) object can fire a number of onload-like events. Handlers cannot be "directly" assigned (eg. someSound.onload), but can be passed as option parameters to several sound methods.

    +
    +
    soundManager.play('mySound',{
    +  onfinish: function() {
    +    alert('The sound '+this.id+' finished playing.');
    +  }
    +});
    +
    +

    Event handlers are scoped to the relevant sound object, so the this keyword will point to the sound object on which the event fired such that its properties can easily be accessed - eg. within an SMSound event handler, this.id will give the sound ID.

    + +
    + +
    + +
    +
    onbufferchange()
    +
    Fires when a sound's reported buffering state has changed while playing and/or loading. The current state is reflected in the boolean isBuffering property.
    +
    Flash 9+ only. Related information on Adobe, Sound.isBuffering.
    +
    + +
    +
    ondataerror()
    +
    Fires at least once per sound play instance when Flash encounters a security error when trying to call computeSpectrum() internally. This typically happens when sounds are 'inaccessible' due to another Flash movie (eg. YouTube) in another tab which has loaded, and may (or may not be) playing sound. Flash attempts to read the "combined" output to the sound card, and must have security permissions for all sounds as a result. See areSoundsInaccessible() on Adobe for more info.
    +
    If the offending resource causing the security error is closed or becomes inactive(?), the data will become available again. Intermittent availability will result in intermittent calls to ondataerror().
    +
    + +
    +
    onbeforefinishcomplete()
    +
    This method has been removed. Use the newer SMSound.onPosition() as a replacement.
    + +
    + +
    +
    onbeforefinish()
    +
    This method has been removed. Use the newer SMSound.onPosition() as a replacement.
    + +
    + +
    +
    onconnect()
    +
    Fires when a sound using an RTMP serverURL property has attempted to connect, and has either succeeded or failed. Affects connected property. Once connected, a stream can be requested from the RTMP server.
    +
    Example: +
    var s = soundManager.createSound({
    +  id: 'rtmpTest',
    +  serverURL: 'rtmp://localhost/test/',
    +  url: 'song.mp3',
    +  onconnect: function(bConnect) {
    +    // this.connected can also be used
    +    soundManager._writeDebug(this.id+' connected: '+(bConnect?'true':'false'));
    +  }
    +}).play(); // will result in connection being made
    +
    +
    + +
    +
    onfinish()
    +
    Fires when a playing sound has reached its end. By this point, relevant properties like playState will have been reset to non-playing status.
    +
    + +
    +
    onid3()
    +
    Fires when ID3 data has been received. Relevant property is id3, which is an object literal (JSON)-style object. Only fields with data will be populated.
    +
    Note that ID3V2 data is located at the beginning (header) of an MP3 file and will load almost immediately, whereas ID3V1 data is at the end and will not be received until the MP3 has fully loaded.
    +
    + Example handler code: +
    +
    soundManager._writeDebug('sound '+this.id+' ID3 data received');
    +var prop = null;
    +var data = '';
    +for (prop in this.id3) {
    +  data += prop+': '+this.id3[prop]+','; // eg. title: Loser, artist: Beck
    +}
    +
    +
    +
    Refer to the Flash 8 Sound.id3 documentation for a list of ID3 properties.
    +
    When parsing ID3 data, it is best to check for the existance of ID3V1 data first, and apply ID3V2 if no matching ID3V1 data is defined. (V1 should "inherit" from V2, ideally, if available.)
    +
    Note that Flash's cross-domain security restrictions may prevent access to ID3 information, even though the MP3 itself can be loaded. (crossdomain.xml files on the remote host can grant Flash permission to access this.)
    +
    Also note some issues with parsing ID3 from iTunes.
    +
    + + +
    +
    onjustbeforefinish()
    +
    This method has been removed. Use the newer SMSound.onPosition() as a replacement.
    + +
    + +
    +
    onload(boolean:success)
    +
    Fires on sound load. Boolean reflects successful load (true), or fail/load from cache (false).
    +
    False value should seemingly only be for failure, but appears to be returned for load from cache as well. This strange behaviour comes from Flash. More detail may be available from the Flash 8 sound object documentation.
    +
    Failure can occur if the Flash sandbox (security) model is preventing access, for example loading SoundManager 2 on the local file system and trying to access an MP3 on a network (or internet) URL. (Security can be configured in the Flash security panel, [see here].)
    + +
    + +
    +
    onpause()
    +
    Fires when a sound pauses, eg. via sound.pause().
    +
    Example: soundManager.pause('mySound');
    +
    + +
    +
    onplay()
    +
    Fires when sound.play() is called.
    +
    + +
    +
    onresume()
    +
    Fires when a sound resumes playing, eg. via sound.resume().
    +
    Example: soundManager.resume('mySound');
    +
    + +
    +
    onsuspend()
    +
    HTML5-only event: Fires when a browser has chosen to stop downloading of an audio file.
    +
    Per spec: "The user agent is intentionally not currently fetching media data, but does not have the entire media resource downloaded."
    +
    One use case may be catching the behaviour where mobile Safari (iOS) will not auto-load or auto-play audio without user interaction, and using this event to show a message where the user can click/tap to start audio.
    +
    The HTML5 stalled event may also fire in desktop cases and might behave differently across browsers and platforms, so careful testing is recommended.
    +
    + +
    +
    onstop()
    +
    Fires when sound.stop() is explicitly called. For natural "sound finished" onfinish() case, see below.
    +
    + +
    +
    whileloading()
    +
    Fires at a regular interval when a sound is loading and new data has been received. The relevant, updated property is bytesLoaded.
    +
    Example handler code: soundManager._writeDebug('sound '+this.id+' loading, '+this.bytesLoaded+' of '+this.bytesTotal);
    +
    Note that the duration property starts from 0 and is updated during whileloading() to reflect the duration of currently-loaded sound data (ie. when a 4:00 MP3 has loaded 50%, the duration will be reported as 2:00 in milliseconds.) However, an estimate of final duration can be calculated using bytesLoaded, bytesTotal and duration while loading. Once fully-loaded, duration will reflect the true and accurate value.
    +
    + +
    +
    whileplaying()
    +
    Fires at a regular interval when a sound is playing, and a position (time) change is detected. The relevant, updated property is position.
    +
    Example handler code: soundManager._writeDebug('sound '+this.id+' playing, '+this.position+' of '+this.duration);
    +
    + +
    + +
    + +
    + + +
    + +
    + +
    + +

    Sound Object Properties

    +

    Each sound object inherits these properties from soundManager.defaultOptions. They can be set individually or at once when enclosed in object literal form to either createSound() or play().

    + +
    + +
    + +
    +
    id
    +
    Sound ID string as provided from the id parameter via createSound(). Can be referenced as this.id from within sound object event handlers such as onload(), whileloading() or whileplaying(), etc.
    +
    If an ID is known, the related SMSound object can be retrieved via getSoundById or directly referencing sounds[id] on the SoundManager global object.
    +
    Legacy note: The sound ID property used to be referenced as sID from within the sound object; this name is maintained for backward compatibility.
    +
    + +
    +
    url
    +
    The specified URL from which the sound is loaded, typically over HTTP. Can be referenced as this.url from within sound object event handlers such as onload() or whileplaying(), etc.
    +
    Experimental feature: Multiple formats/encodings can now be applied to the url parameter by specifying an array instead of a single string.
    +
    Example: +
    soundManager.createSound({
    +  id: 'foo',
    +  url: ['bar.ogg','bar.mp3']
    +});
    +
    SoundManager 2 will use the first playable URL it finds (according to canPlayURL() and/or canPlayType()), and the URL property will then reflect the playable URL after that point. Note that this means the original array data will be lost.
    +
    In this alternate format, the array accepts "type" attributes.
    +
    +
    soundManager.createSound({
    +  id: 'foo',
    +  // useful for URLs without obvious filetype extensions
    +  url: [
    +    {type:'audio/mp3',url:'/path/to/play.php?song=123'},
    +    {type:'audio/mp4',url:'/path/to/play.php?song=256'}
    +  ]
    +});
    +
    + +
    +
    serverURL
    +
    Note: Experimental feature. Only for use with RTMP streaming, ie., Flash Media Server and similar servers.
    +
    The RTMP server address which Flash will connect to using a NetStream object. Only the server address is specified here, when RTMP is in use; the url property is used to point to a specific resource on the server.
    +
    Example: +
    soundManager.createSound({
    +  id: 'mySound',
    +  serverURL: 'rtmp://localhost/rtmpDemo/', // RTMP server
    +  url: 'mysong.mp3' // path to stream
    +}).play();
    +
    + +
    +
    usePolicyFile
    +
    Boolean value (default: false) which instructs Flash, when loading MP3/MP4 content from remote/third party domains, to request example.com/crossdomain.xml first in order to determine permissions for access to metadata such as ID3 info, waveform, peak and/or spectrum data.
    +
    usePolicyFile will be automagically set to true if your sound options have an onid3() event handler, or uses sound data (peak/wave/spectrum) features. By default, Flash will not have access to this metadata on remote domains unless granted cross-domain security permissions via the crossdomain.xml file.
    +
    Consider additional HTTP traffic (albeit, perhaps with caching-like behaviour for subsequent checks?) and silent 404s in most cases given few hosts use crossdomain.xml files.
    +
    See Adobe's knowledge base for related ID3 + crossdomain.xml documentation.
    +
    + +
    + +
    + +
    + +

    Sound Object Dynamic Properties

    +

    Each sound includes a number of properties that are updated throughout the life of a sound - while loading or playing, for example. Many of these properties have related events that fire when they are updated, and should be treated as read-only.

    + +
    + +
    +
    buffered
    +
    Based loosely on the native HTML5 attribute, SM2 defines buffered as an array of objects which include start and end position (time) values. This property is updated during the SM2 whileloading event; internally, SM2 uses HTML5's progress event to track changes.
    +
    It is important to note that the buffered values may not always be contiguous and can change, particularly if the user seeks within the file during downloading. With ranges, you can draw highlighted segments on a progress bar UI which would reflect the current "slices" of buffered data.
    +
    Example: a buffered array of [{ start: 0, end: 2 }, { start: 5, end: 7 }]; shows a sound that has buffered data for the ranges 0-2 seconds, and 5-7 seconds.
    +
    In order to determine the total buffered data and thus "total percent loaded" under HTML5, you can loop through the buffered array and sum the total of (buffered[i].end - buffered[i].start). If you want to draw ranges, you can use the start and end values of each buffered item and draw that relative to the total duration (normalized as durationEstimate for flash compatibility).
    +
    Example: +
    var i, total = 0;
    +for (i=0, j=this.buffered.length; i<j; i++) {
    +  // draw current range in progress bar UI?
    +  drawProgressUI(this.buffered[i].start, this.buffered[i].end);
    +  // sum of all ranges vs. whole file duration
    +  total += (this.buffered[i].end - this.buffered[i].start);
    +}
    +
    +
    Note that under Flash, downloading is always sequential and thus the buffered array will always be a single item with start: 0 and an end value of duration (eg., the amount of currently-downloaded "time").
    +
    Additional behaviour note: A browser might download additional bytes of a sound in advance under HTML5, but may only update the buffered state to reflect the newly-downloaded range(s) when the "playback head" reaches near the end of the current buffer. This can also be affected if the user seeks within the file.
    +
    + +
    +
    bytesLoaded
    +
    The number of bytes currently received while loading a sound.
    +
    + +
    +
    bytesTotal
    +
    The total number of bytes to be downloaded, while loading a sound.
    +
    + +
    +
    didBeforeFinish
    +
    This property has been removed. Use the newer SMSound.onPosition() as a replacement.
    + +
    + +
    +
    didJustBeforeFinish
    +
    This property has been removed. Use the newer SMSound.onPosition() as a replacement.
    + +
    + +
    +
    duration
    +
    The current length of the sound, specified in milliseconds.
    +
    Note that during loading, this property reflects the length of downloaded data, not the full length, until completely loaded (see whileloading().) For an approximate "full duration" value while loading, see durationEstimate.
    +
    + +
    +
    durationEstimate
    +
    The estimated duration of the sound, specified in milliseconds.
    +
    Due to the dynamic nature of duration while loading, this attempts to provide the full duration by calculating parseInt((self.bytesTotal/self.bytesLoaded)*self.duration) and is updated with each whileloading() interval.
    +
    (Flash-only): Once the sound has fully loaded (onload() has fired), durationEstimate will be updated with the final, Flash-calculated value of duration.
    +
    Note that the durationEstimate method works only with Constant Bitrate (CBR)-encoded MP3s due to the consistent data/time assumption. VBR-encoded MP3s will give inaccurate results.
    +
    HTML5 behaviour: Both duration and durationEstimate are updated at regular intervals during loading of HTML5 audio, directly referencing the duration property provided on the native HTML5 object. Unlike Flash, HTML5 typically gets the true and final duration value by the time playback begins.
    +
    + +
    +
    eqData = {left:[], right: []}
    +
    Object containing two arrays of 256 floating-point (three decimal place) values from 0 to 1, the result of an FFT on the waveform data. Can be used to draw a spectrum (frequency range) graph while playing a sound. See Page-as-playlist demo for example implementation. Requires Flash 9+.
    +
    A spectrum frequency graph reflects the level of frequencies being played, from left to right, low to high (i.e., 0 to 20,000 Hz.)
    +
    eqData is set and updated during whileplaying(). A simple graph could be drawn by looping through the values and multiplying by a vertical scale value (eg. 32, thus a graph with peaks of 32 pixels.)
    +
    Example code: +
    someSoundObject.whileplaying = function() {
    +  // Move 256 absolutely-positioned 1x1-pixel DIVs, for example (ugly, but works)
    +  var gPixels = document.getElementById('graphPixels').getElementsByTagName('div');
    +  var gScale = 32; // draw 0 to 32px from bottom
    +  for (var i=0; i<256; i++) {
    +    graphPixels[i].style.top = (32-(gScale+Math.ceil(this.waveformData.left[i]*gScale)))+'px';
    +  }
    +}
    +
    +
    Related Adobe technical documentation (Flash 9/AS3 Sound() object): computeSpectrum()
    +
    Note: Flash security measures may deny access to waveformData when loading MP3s from remote domains.
    +
    Warning: This feature can eat up a lot of CPU in some cases. The amount of data passed from Flash to JS is not terribly large, but the JS-DOM updates and browser reflow can be expensive. Use with caution.
    +
    Backward compatibility note: Up to SoundManager 2.95a.20090717, eqData was a single array containing one channel of data. In newer versions this is unchanged, except the array now has .left[] and .right[] objects attached to it. To ensure future compatibility, use eqData.left[0] instead of eqData[0] and so on.
    +
    + +
    +
    id3
    +
    An object literal populated, if applicable, when ID3 data is received (related handler: onid3())
    +
    For property details, see onid3().
    +
    + +
    +
    isBuffering
    +
    Boolean value reflecting the buffering state of a playing or loading object. To be notified when this property changes, see onbufferchange().
    +
    Flash 9+ only. Related information on Adobe, Sound.isBuffering.
    +
    + +
    +
    isHTML5
    +
    Boolean property indicating whether a sound object is using HTML5 Audio for playback. Treat as read-only.
    +
    This should not really be relied on for anything, but it is provided as an indicator of support on a per-sound basis.
    +
    isHTML5 is set based on the URL provided to createSound(), and is updated when the URL changes.
    +
    + +
    +
    connected
    +
    Boolean value reflecting the state of an RTMP server connection (when serverURL is used to connect to a Flash Media Server or similar RTMP service.) Calls to load or play will result in a connection attempt being made, and onconnect() ultimately being called.
    +
    For example code using connected, see onconnect().
    +
    + +
    +
    loaded
    +
    Boolean value indicating load success as returned from Flash. True indicates success, False is a failure.
    +
    Because of the potential for false positives, duration and other properties could be checked as a test of whether sound data actually loaded. For more granular state information, see readyState.
    +
    + +
    +
    muted
    +
    Boolean indicating muted status. True/False.
    +
    Treat as read-only; use mute(), unmute() and toggleMute() methods to affect state.
    +
    + +
    +
    paused
    +
    Boolean indicating pause status. True/False.
    +
    Treat as read-only; use pause(), resume() and togglePause() methods to affect state.
    +
    + +
    +
    peakData = {left:0.0, right:0.0}
    +
    Object literal format including left and right properties with floating-point values ranging from 0 to 1, indicating "peak" (volume) level. Updated during whileplaying(). See Page-as-playlist demo as one example. Requires Flash 9+.
    +
    Example (within relevant sound object handler): +
    someSoundObject.whileplaying = function() {
    +  soundManager._writeDebug('Peaks, L/R: '+this.peakData.left+'/'+this.peakData.right);
    +}
    +
    + +
    +
    playState
    +
    Numeric value indicating the current playing state of the sound.
    +
    0 = stopped/uninitialised
    +
    1 = playing or buffering sound (play has been called, waiting for data etc.)
    +
    Note that a 1 may not always guarantee that sound is being heard, given buffering and autoPlay status.
    +
    + + +
    +
    position
    +
    The current location of the "play head" within the sound, specified in milliseconds (1 sec = 1000 msec).
    +
    + +
    +
    readyState
    +
    Numeric value indicating a sound's current load status
    +
    0 = uninitialised
    +
    1 = loading
    +
    2 = failed/error
    +
    3 = loaded/success
    +
    Under Flash, readyState will move from 0 to 1, and then change to 3 when the sound's onload() event fires (and all bytes have loade.)
    +
    Under HTML5, readyState will move from 0 to 1 when initializing the HTTP request (from load()), and will quickly change to 3 when the sound is ready to play. Note that HTML5 is buffer-based and onload() means "enough audio data has buffered to begin playback".
    +
    + +
    +
    type
    +
    A MIME type-like string eg. audio/mp3, used as a hint for SM2 to determine playability of a link with methods like canPlayURL().
    +
    This can be helpful when you have a sound URL that does not have an .mp3 extension, but serves MP3 data (eg., a PHP or other CGI script.)
    +
    Example: +
    var s = soundManager.createSound({
    +  id: 'aSound',
    +  url: '/path/to/some.php?songID=123',
    +  type: 'audio/mp3' // indicates an MP3 link, so SM2 can handle it appropriately
    +});
    +
    + +
    +
    waveformData = {left:[], right:[]}
    +
    Array of 256 floating-point (three decimal place) values from -1 to 1, can be used to draw a waveform while playing a sound. See Page-as-playlist demo for example implementation. Requires Flash 9+.
    +
    waveformData is set and updated during whileplaying(). A simple graph could be drawn by looping through the values and multiplying by a vertical scale value (eg. 32, which would make a graph with peaks of -32 and +32 pixels.)
    +
    Example code: +
    someSoundObject.whileplaying = function() {
    +  // Move 256 absolutely-positioned 1x1-pixel DIVs, for example (ugly, but works)
    +  var gPixels = document.getElementById('graphPixels').getElementsByTagName('div');
    +  var gScale = 32; // draw -32 to +32px from "zero" (i.e., center Y-axis point)
    +  for (var i=0; i<256; i++) {
    +    graphPixels[i].style.top = (gScale+Math.ceil(this.waveformData.left[i]*-gScale))+'px';
    +  }
    +}
    +
    +
    SM2 implementation note: waveformData contains both left and right channels, and the data represents a raw sound wave rather than a frequency spectrum.
    +
    Related Adobe technical documentation (Flash 9/AS3 Sound() object): computeSpectrum()
    +
    Note: Flash security measures may deny access to waveformData when loading MP3s from remote domains.
    +
    Warning: This feature can eat up a lot of CPU in some cases. The amount of data passed from Flash to JS is not terribly large, but the JS-DOM updates and browser reflow can be expensive. Use with caution.
    +
    + +
    + +
    + +
    + +
    + +
    + +
    +

    SMSound Object Methods

    +

    SoundManager provides wrappers for most SMSound methods - eg. soundManager.play('mySound') checks for a valid sound object, and then calls soundManager.sounds['mySound'].play() on that particular object; thus, it is the same as var sound = soundManager.getSoundById('mySound'); mySound.play();

    +

    The following methods can be called directly on a SMSound instance. The method calls are the same as the SoundManager global methods documented above for existing sound objects, minus the sound ID parameter.

    +
    + + + + +
    +
    + + + +
    + +
    + +
    + +

    SoundManager: Default Sound Options

    + +

    Sound objects inherit properties from soundManager.defaultOptions when they are created.

    +

    Sound parameters can be overridden on a per-sound basis at create time, or changed dynamically in some cases. Note that none of these options are required when calling createSound() except for id and url; the others will inherit the default values if unspecified.

    +

    soundManager.defaultOptions apply the properties and event handlers as specified above. Defaults are shown below as an example.

    + +
    soundManager.defaultOptions = {
    +  autoLoad: false,        // enable automatic loading (otherwise .load() will call with .play())
    +  autoPlay: false,        // enable playing of file ASAP (much faster if "stream" is true)
    +  from: null,             // position to start playback within a sound (msec), see demo
    +  loops: 1,               // number of times to play the sound. Related: looping (API demo)
    +  multiShot: true,        // let sounds "restart" or "chorus" when played multiple times..
    +  multiShotEvents: false, // allow events (onfinish()) to fire for each shot, if supported.
    +  onid3: null,            // callback function for "ID3 data is added/available"
    +  onload: null,           // callback function for "load finished"
    +  onstop: null,           // callback for "user stop"
    +  onfinish: null,         // callback function for "sound finished playing"
    +  onpause: null,          // callback for "pause"
    +  onplay: null,           // callback for "play" start
    +  onresume: null,         // callback for "resume" (pause toggle)
    +  position: null,         // offset (milliseconds) to seek to within downloaded sound.
    +  pan: 0,                 // "pan" settings, left-to-right, -100 to 100
    +  stream: true,           // allows playing before entire file has loaded (recommended)
    +  to: null,               // position to end playback within a sound (msec), see demo
    +  type: null,             // MIME-like hint for canPlay() tests, eg. 'audio/mp3'
    +  usePolicyFile: false,   // enable crossdomain.xml request for remote domains (for ID3/waveform access)
    +  volume: 100,            // self-explanatory. 0-100, the latter being the max.
    +  whileloading: null,     // callback function for updating progress (X of Y bytes received)
    +  whileplaying: null,     // callback during play (position update)
    +  // see optional flash 9-specific options, too
    +}
    +
    + +

    As a simple example, the following code would override the default autoPlay, pan and volume options for a given sound:

    + +
    soundManager.createSound({
    +  url: '/path/to/some.mp3',
    +  autoPlay: true,
    +  pan: -75,
    +  volume: 50
    +});
    + +

    Note: For live examples, see the code behind the "page as playlist" demo which uses much of this functionality.

    + +
    + +
    + +

    Sound Properties Object: Version-specific Options (Merging)

    + +

    Some sound properties object items (eg. usePeakData) are flash version-specific, non-default and are intentionally separated from soundManager.defaultOptions. Flash 9-specific options fall under this category.

    + +

    soundManager.flash9Options and soundManager.movieStarOptions are both defined as separate objects, and if supported according to flashVersion and defaultOptions parameters, are merged at the property level into soundManager.defaultOptions.

    + +
    // Note: These are merged into soundManager.defaultOptions when flashVersion = 9.
    +
    +soundManager.flash9Options = {
    +  isMovieStar: null,      // "MovieStar" MPEG4 audio mode. Null (default) = auto detect MP4, AAC etc. based on URL. true = force on, ignore URL
    +  usePeakData: false,     // enable left/right channel peak (level) data
    +  useWaveformData: false, // enable sound spectrum (raw waveform data) - WARNING: May set CPUs on fire.
    +  useEQData: false,       // enable sound EQ (frequency spectrum data) - WARNING: Also CPU-intensive.
    +  onbufferchange: null,	  // callback for "isBuffering" property change
    +  ondataerror: null	  // callback for waveform/eq data access error (flash playing audio in other tabs/domains)
    +}
    +
    +soundManager.movieStarOptions = {
    +  bufferTime: null  // seconds of data to buffer (null = flash default of 0.1 - if AAC gappy, try up to 3 seconds)
    +}
    +
    +// when merged, soundManager.flash9Options.isMovieStar -> soundManager.defaultOptions.isMovieStar, etc.
    + +
    + +
    + +
    + +
    + +
    + +
    + +

    SoundManager Dynamic (Runtime) Properties

    + +

    Some properties are dynamic, determined at initialisation or later during runtime, and should be treated as read-only.

    + + +

    soundManager.features Object

    + +

    As certain sound functionality is only available beginning with Flash 9, soundManager.features can provide a consistent way of checking for feature support.

    + +

    The structure (intended as read-only) is currently as follows:

    + +
    soundManager.features = {
    +  buffering: [boolean],
    +  peakData: [boolean],
    +  waveformData: [boolean],
    +  eqData: [boolean],
    +  movieStar: [boolean]
    +}
    + +

    Example (checking for peakData support):

    +
    if (soundManager.features.peakData) {
    +  // do peak data-related things here
    +}
    + +

    The features object is populated at initialisation time; the current feature support tests simply check the value of soundManager.flashVersion being >= 9. This object has been added in anticipation of additional features with future versions of Flash.

    + +
    + +

    soundManager.html5Only [boolean, read-only]

    +

    This property is set during initialization and reflects whether SM2 is running in "100% HTML5 mode", based on support for required formats defined by soundManager.audioFormats.

    + +
    + +
    + +
    + +
    + +
    + +

    SoundManager Core Events

    + +

    The following events are attached to the soundManager global object and are useful for detecting the success/failure of the API's initialisation.

    +

    Keep in mind that these core events are effectively asynchronous (ie., they may fire long before or after window.onload()) and therefore should not be relied on as the "ready" event for starting your application. Use the standard "DOM content loaded" or window load events for your own initialization routines.

    + +
    + +
    onready(callback:function(status),[scope])
    +
    Queue onload()-style event listener(s), triggered when soundManager has successfully started.
    +
    Example: soundManager.onready(myOnReadyHandler); soundManager.onready(myOtherHandler);
    +
    For more detail and examples, see soundManager.onready().
    + +
    ontimeout(callback:function(status),[scope])
    +
    Queue onload()-style event listener(s), triggered when soundManager has successfully started.
    +
    Example: soundManager.ontimeout(myOnTimeoutHandler); soundManager.ontimeout(myOtherHandler);
    +
    For more detail and examples, see soundManager.ontimeout().
    + +
    onerror(status)
    +
    Deprecation note: Use the newer soundManager.ontimeout() instead of this method.
    + + +
    oninitmovie()
    +
    Deprecation note: Use the newer soundManager.ontimeout() instead of this method.
    + +
    onload()
    + +
    Deprecation note: Use the newer soundManager.onready() instead of this method.
    + + +
    + +
    + + +
    +
    + +
    + +
    + +
    + +

    SoundManager Object Collections

    + +
    +
    soundIDs[]
    +
    An array of sound ID strings, ordered by creation. Can be used to iterate through sounds{} by ID.
    +
    sounds{}
    +
    An object literal/JSON-style instance of SMSound objects indexed by sound ID (as in sounds['mySound'] or sounds.mySound), used internally by SoundManager. soundManager.getSoundById() may be used as an alternate to directly accessing this object.
    +
    + +
    + +
    +
    + +
    + +
    + +
    + +

    Object Literal Format

    + +

    Sounds can be created with instance-specific parameters in an object literal (JSON) format, where omitted parameters inherit default values as defined in soundManager.

    + +
    soundManager.createSound({
    +  id: 'mySound',
    +  url: '/path/to/some.mp3',
    +  autoLoad: true,
    +  autoPlay: false,
    +  onload: function() {
    +    alert('The sound '+this.id+' loaded!');
    +  },
    +  volume: 50
    +});
    + +

    This object can also be passed as an optional argument to the play method, overriding options set at creation time.

    + +

    For a full list of available options, see Sound Properties Object

    + +
    + + +
    + +
    + + +
    + + +
    + + +
    + + + + + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/resources/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/resources/index.html new file mode 100755 index 00000000..d8cd10af --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/resources/index.html @@ -0,0 +1,243 @@ + + + +SoundManager 2: Resources + + + + + + + + + + + + + + + + +
    + + + +
    + +
    + +
    + +
    +

    Licensing

    +

    BSD licensed.

    +
    + +
    +

    SoundManager 2 License

    +

    SoundManager 2 is provided under a BSD license.

    +
    + +
    + + + + + +
    + + + +
    + + + +
    + +
    + +
    + + +
    + + +
    + + +
    + + + + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/technotes/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/technotes/index.html new file mode 100755 index 00000000..86972486 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/doc/technotes/index.html @@ -0,0 +1,508 @@ + + + +SoundManager 2: Technical Notes + + + + + + + + + + + + + + + + +
    + + + +
    + +
    + +
    + +
    +
    +
    + +
    +
    +
    + +
    + +
    + +
    +

    Requirements + Specifications

    +

    What SM2 needs, and how it works.

    +
    + +
    + +
    + +

    Requirements + Specifications

    + +

    Prerequisites (client)

    + +
      +
    • HTML5 Audio() support and/or Flash plugin, version 8 or higher
    • +
    • Supported web browser + platform
    • +
    + +

    Tested Browsers and Platforms

    + +
      +
    • Firefox (all versions), Windows/Mac
    • +
    • Safari 1.3+ (Mac) / All Windows versions
    • +
    • Mobile Webkit: iOS 4.0 devices, iPad 3.2 (original iPad iOS release) and newer
    • +
    • Android (2.3+, confirmed on 2.3.3.)
    • +
    • Google Chrome (all versions/OSes)
    • +
    • Internet Explorer 5.0+, Windows
    • +
    • Opera 9.10 (slightly buggy, 9.5+ ideal), Windows/Mac
    • +
    • Netscape 8.0+, Windows/Mac
    • +
    • Firefox 1.5+, Linux (Flash 9 beta)
    • +
    + +

    In the absence of native HTML5 audio support, JavaScript-to-flash communication is used to provide Flash-based audio playback. JS-to-flash is possible through Flash 8's ExternalInterface feature, which uses a standard browser plugin architecture implemented by each browser manufacturer (see NPAPI.)

    + +

    For further JS/flash reference, see Adobe's Flash 8 documentation, under the "ExternalInterface support" page which details supported browsers.

    + +

    Of course, not all possible combinations of browser/OS have been tested. Most modern browsers and devices should work reasonably well.

    + +
    + +
    + +

    Caveats + Limitations / FAQ

    + +
    + +
    + +

    Supported sound formats (MP3 via Flash 8 and MP4/M4A/AAC via Flash 9 "MovieStar", with caveats)

    +

    SM2 uses Flash's native Sound object for loading and managing sound, so it is subject to the same limitations that Flash 8 is. Perhaps a design decision, the Flash 8 sound object only supports MP3 files through the loadSound() ActionScript method. SM2 is not able to load other sound formats, including audio-only SWF files, due to this limitation. Refer to the Flash 8 documentation for details.

    + +

    MP3 Format Caveats

    +

    Additionally, some very low and very high bitrate MP3s, and Variable Bitrate (VBR) MP3s may play either too quickly or too slowly (see "the chipmunk problem"); if you are encountering this issue, try re-encoding at a different bitrate (between 64 kbps and 192 kbps, for example.) Using Constant Bitrate (CBR) encoding may also alleviate this problem.

    +

    It has been suggested that sample rates that are neither 22/44 KHz can also contribute to this issue. 44 KHz is the standard CD-spec sample rate, and is recommended for "hi-fi" recordings.

    + +

    Looping

    +

    Perhaps due to the way Flash dynamically loads and decodes MP3 data, seamless looping doesn't seem to be fully implemented. Loops have a noticeable gap between the finish and start. This has been an issue since the original version of SoundManager. Rather than have a broken feature, the funcionality has been omitted until a solid workaround is found.

    + +

    Flash 8 limitations with multiShot (overlaying/"chorus") effects

    +

    Regarding "layering" sounds (calling play() on a sound multiple times): Even though a multi-shot option can be specified, it does not work with Flash 8; a single instance of a sound can only have one timeline. The current behaviour is that when multiShot is specified and play() is called on a currently-playing sound, it will restart from the beginning without an overlay.

    +

    However, the API does provide some creative ways (onfinish for looping, multiple sound objects for multi-shot layering) of working around these Flash limitations.

    +

    It should be noted that sounds can loop seamlessly and be layered when linked and exported to SWF from within the Flash IDE, but SoundManager does not support SWF-based audio.

    + +

    Flash 9 multiShot capabilities

    +

    The Flash 9-based version of SoundManager2 can successfully layer sounds via "multiShot", truly playing a single sound multiple times on top of itself. However the API will only call certain timing-related methods such as whileplaying() for the first play() "instance" of the sound, to avoid confusion. By contrast, simpler methods such as onfinish() will be called multiple times, one for each instance of play().

    + +

    ID3 Parsing

    +

    ID3 data can differ in formatting, version and subsequently be oddly-parsed by Flash. Values may sometimes be repeated across different fields.

    +

    ID3 info seems to fail to load for iTunes 7-edited files, perhaps due to the format or inclusion of album artwork (image data.)

    + +

    Performance Notes: Caching + RAM Obeservations

    +

    Flash appears to use the browser cache (presumably the OS' native, or closest browser,) so the browser's cache size and other settings may affect Flash's cache behaviour. It is safe to assume a 100 MB MP3 will probably not be cached, for example, but a 16 MB one most likely will be.

    +

    MP3s appear to be loaded and stored in RAM while loading over HTTP, so memory use needs to be considered for both large MP3s and streaming radio-type applications.

    + +

    Timing/Latency (JS + Flash, ExternalInterface-related)

    +

    JavaScript-to-Flash communication is not instantaneous on slower systems, but can be much better on more modern systems. Latency (timing lag/delays) can be noted in some cases from function call to sound execution. It is possible some performance analysis can help to speed up this area for timing-critical applications involving animation etc., but this area has not been thoroughly investigated yet. Brad Neuberg has some notes on speeding up ExternalInterface which may be relevant.

    +

    Flash-to-OS/hardware latency (where flash reports progress, but no sound is heard for a number of milliseconds) may also be an unfortunate reality of Flash-based audio, varying between platform and OS version etc.

    +

    Additionally, MP3 files may contain audible gaps at the beginning or end by default when encoded, even if the source (eg. WAVE) file did not. Using optional "nogap" encoding options with programs such as LAME may help to remedy this.

    +

    Finally, the useHighPerformance option may help with JS/flash lag. Using this option causes the flash movie to be placed with position:fixed on-screen at all times (though in a small, hidden box) and has been shown to notably improve performance on Mac OS X. As well, flashPollingInterval will use a lower timer value, making polling calls run as quickly as reasonably possible and increasing the frequency of calls to whileplaying(), whileloading() and other time-related events.

    +

    Use these options with caution, as overly-aggressive intervals may hinder performance if event callbacks become too frequent.

    + +
    + +
    + +
    + +
    + +
    + +

    Serving to HTML5 + Flash Clients

    +

    A few notes on HTTP response headers, configuration and so forth.

    + +
    + +
    + +

    Tips for serving audio to HTML5 + Flash Clients

    +

    HTTP response headers from your server are important. Below is a brief list of recommended practices for serving audio content to clients using HTML5, and/or Flash.

    + +

    HTML5

    + +
      +
    • Likes Content-Length HTTP response headers (can affect duration and playback events if missing.)
    • +
    • Arbitrary seeking, dynamic loading/buffering works when the server supports Byte Serving via byte ranges, also known as HTTP partials / range requests. Without this support, behaviour falls back to a Flash-like single-connection, sequential/progressive-style download.
    • +
    • Likes a proper MIME type response from the server, e.g., audio/mpeg for MP3 content.
    • +
    + +

    Flash

    + +
      +
    • Likes Content-Length HTTP response headers. When missing, duration may be unknown and certain events like whileloading() / whileplaying() may not fire.
    • +
    • Does not care about MIME type or partials in server responses.
    • +
    + +

    In summary...

    + +

    Always serve a proper Content-Length HTTP response header. For HTML5, review that HTTP partials / range requests are enabled and that you are serving the correct MIME type in your response as well.

    +

    Never apply gzip or mod_deflate compression to binary assets. It causes playback problems, costs CPU and in some cases, may even increase the transfer size.

    + + +
    + +
    + +
    + +
    + +

    How Clients Download Audio

    +

    Progressive, sequential HTTP vs. HTTP 206 partials / range requests.

    + +
    + +
    + +

    How HTML5 + Flash Clients Download Audio

    + +

    In terms of HTTP, assets are typically requested and downloaded in sequential byte order over a single connection. Flash typically works this way, but HTML5 clients can use behaviours that are closer to streaming - instead, using multiple requests for pieces of data.

    + +

    Browsers can request audio from servers either sequentially or using Byte Serving (AKA "partials"), depending on client and server capabilities. The key difference is that with byte serving, clients request data in a "streaming" fashion and can buffer at will, therefore allowing arbitrary seeking, pausing and requesting of audio data in pieces - similar to how video playback typically works on YouTube, for example. Thus, preloading and onload() is less-meaningful when byte serving is involved.

    + +

    Traditional, "progressive" download (single request)

    + +

    The typical HTTP file download can be described as follows:

    + +
      +
    • Single HTTP request, one TCP connection
    • +
    • All bytes are sent sequentially "over the wire"
    • +
    • Network connection is closed when the download completes (or fails)
    • +
    • SoundManager 2 fires relevant sound onload() callback when the connection closes and the sound is deemed to be valid
    • +
    + +

    In terms of HTTP traffic, the sequence is something like this (excluding some headers for brevity):

    + +
      +
    • Client request +
        +
      • GET some.mp3 HTTP/1.1
      • +
      +
    • +
    • + Server response +
        +
      • HTTP/1.1 200 OK
      • +
      • Content-Length: 158958
      • +
      • Connection: close
      • +
      • Content-type: audio/mpeg
      • +
      +
    + +

    Progressive downloading behaviour in SoundManager 2

    + +

    This method is typically used by Flash when requesting audio via standard HTTP, and HTML5 clients in the event that Byte Serving (HTTP 206/Partial Content) is not implemented or cannot be negotiated.

    + +
      +
    • Playback begins after a small amount of buffering, once the download has started.
    • +
    • Once started, the download progress continues until all bytes are received. Stopping or pausing playback does not cancel the download.
    • +
    • During load, a SM2 sound object's whileloading() event will fire at a regular interval with bytesLoaded, bytesTotal and duration properties updating as the file progresses. Because Flash only reflects the "amount of duration loaded", durationEstimate is provided as a means of reflecting the total duration before load has completed (at which point duration is 100% and accurate.)
    • +
    • During load, the user can only seek within the amount of data (duration) downloaded.
    • +
    • onload() fires when the connection is closed, and all bytes have been received.
    • +
    + +

    Byte Serving (partials / byte range requests, "streaming"-style delivery)

    + +

    HTML5 clients will send a Accept-ranges: bytes header in the HTTP request for an audio asset to indicate their capability for Byte Serving, along with a Range header indicating what piece of the file to download.

    +

    If the server supports partials, it will reply with a HTTP/1.1 206 Partial Content header and a Content-Range header indicating the bytes it is going to send.

    +

    It appears that servers will return the whole range in the first response unless interrupted (and when a client requests a range of "0-" as in this case), but the initial connection may be dropped by the client if it wishes to stop "buffering" at any point, or if the user tries to seek to a new position in the audio that has not yet buffered.

    + +
      +
    • + Client request +
        +
      • GET some.mp3 HTTP/1.1
      • +
      • Range: bytes=0-
      • +
      +
    • +
    • + Server response +
        +
      • HTTP/1.1 206 Partial Content
      • +
      • Accept-ranges: bytes
      • +
      • Content-length: 4237566
      • +
      • Content-Range: bytes 0-4237565/7237566
      • +
      +
    • +
    • The first response includes all bytes in this case, but a client may drop this connection and make a new range request, if needed; for example, the user may seek to a new position in the file where data is not yet available, and the client will make a new request to buffer data beginning at the appropriate offset.
    • +
    + +

    HTTP/1.1 206 Partial Content request/response example

    + +
      +
    • + Client request +
        +
      • GET some.ogg HTTP/1.1
      • +
      • Range: bytes=5210604-5275910
      • +
      • If-Range: "508107-4d8a0b4e90d26"
      • +
      +
    • +
    • + Server response +
        +
      • HTTP/1.1 206 Partial Content
      • +
      • Accept-Ranges: bytes
      • +
      • Content-length: 65307
      • +
      • Content-Range: bytes 5210604-5275910/5275911
      • +
      • Content-Type: audio/ogg
      • +
      +
    • +
    + +

    Byte Serving behaviour in SoundManager 2

    + +

    Byte Serving is automatically negotiated between client and server, and offers a number of advantages over traditional downloads. Most notably, Byte Serving is closer to a "streaming" technology and enables clients to seek, buffer and resume playback at arbitrary positions within a file once the duration is known. Larger files benefit most from this technique, since they can be handled in smaller chunks vs. being held entirely in memory a la Flash.

    + +

    While SoundManager 2 uses the same events for HTML5 and Flash regardless of transport mechanism, there are some notable differences in SoundManager 2's behaviour when using HTML5 and Byte Serving.

    + +

    Most importantly, the concept of "loaded" (i.e., preloading data and waiting for onload()) with partials is irrelevant due to the way clients are able to pause, cancel and resume requests.

    + +
      +
    • Playback begins after a small amount of buffering, once the download has started.
    • +
    • The HTML5-native canplay() event fires when playback is ready to begin. This will cause SoundManager 2 to fire a sound's onload() callback. At this point, the sound's duration should be known, but the SM2-provided bytesLoaded and bytesTotal sound properties may not be known and thus are 0/0 during load time, and 1/1 if still undefined at load time.
    • +
    • SoundManager 2 attempts to fire whileloading() events as the HTML5-native progress() event fires, but keep in mind that any "bytes loaded" data may refer to blocks (i.e., buffered sequences of data) that are non-sequential and thus bytesLoaded and bytesTotal should not be relied on as an indicator of "total load progress".
    • +
    • HTML5 clients may use their own heuristic to determine how much to buffer, if and when to pause, cancel or resume requesting data.
    • +
    • Clients may request metadata from the end of a file in some cases, as with OGG formats, in order to determine information like the total duration of the sound.
    • +
    • During load (and once the duration is known), the user can seek to any position within the file.
    • +
    • A client may drop an open request in order to request a new byte range - for example, to buffer and resume playback if the user jumps to half-way through the file where that data has not been downloaded yet.
    • +
    + +
    + +
    + +
    + +
    +

    Mobile Device Limitations

    +

    Known restrictions, quirks and annoyances relating to HTML5 + mobile Webkit (iOS / Android) software.

    +
    + +
    +

    Mobile Device Restrictions, Quirks and Issues

    +

    Mobile devices tend to be somewhat limited in terms of battery life, network connection and other resources. Furthermore, they are unlike larger (laptop/desktop) devices in that audio is often not a "shareable" resource, and only one application may be using the sound hardware at any given time. Thus, mobile devices must be treated slightly differently in terms of playing audio via JavaScript.

    +

    iOS (mobile Safari/Webkit)

    +
      +
    • Sound play() calls are blocked by the OS unless in direct response to a user event like touch or click. ("Auto-play" attempts will be blocked, and the sound may fire a suspend event in this case.) For the curious, setTimeout() calls will also result in playback being blocked.
    • +
    • Sound load() and load-related methods may also have some limitations, similar to play().
    • +
    • Only one sound may be actively playing at a time. If an other sound (or application) is playing audio, it will be stopped by the OS in order to play the new sound.
    • +
    • Chained playback (sequential / playlist-style behaviour) works when using the onfinish event handler. Otherwise, blocking occurs.
    • +
    +

    Possible Alternatives

    +

    The Webkit Audio API (possibly a future standard as the Web Audio API) allows for low-level access, manipulation and control of audio from JavaScript. This API is mostly separate from the HTML5 audio API, but will ultimately allow for better fine-grained control and mixing of sound.

    +

    Once playback is allowed, the Webkit Audio API should be able to get around many of the current HTML5 audio limitations present on iOS including multiple sound playback, volume and pan control, and dynamic filtering / processing effects. However, the API is not a standard and is not consistently supported in Webkit, let alone other browsers.

    +

    SM2 does not presently use the Webkit Audio API. It may be experimentally or more formally added at some point in the future, when the API is more universally-supported.

    +
    + +
    + +
    + +
    +

    Debug + Console Output

    +

    Console-style messaging, useful for troubleshooting start-up and runtime issues.

    +
    + +
    +

    Live Debug Output

    +

    With debug mode enabled via soundManager.setup({debugMode: true}), SM2 can write helpful troubleshooting information to JavaScript console.log()-style interfaces. Additionally, output can be written to an optional DIV element with the ID of soundmanager-debug.

    +

    soundManager.setup({consoleOnly: true}) can be applied to disable HTML output (using console.log()-only methods) as well.

    +

    Additionally, debugging within the Flash portion of SM2 is also available and set using soundManager.setup({debugFlash: true}). Debug messages are written to the flash movie itself.

    +

    For info on SoundManager 2 loading/initialization failures and how to fix them, see troubleshooting.

    + +

    Below is a live example of debug output from SM2:

    + +
    +
    + +
    +
    + +

    Flash debug output, as applicable:

    + +
    + +
    +
    + +
    + + +
    + + + +
    + + + +
    + +
    + +
    + + +
    + + +
    + + +
    + + + + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/index.html new file mode 100755 index 00000000..5058e802 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/index.html @@ -0,0 +1,691 @@ + + + +SoundManager 2: JavaScript Sound For The Web + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + +
    + +
    + +
    + +
    + + +
    +

    + SM2 options:  +html5 +  |  + -html5 +  |  + +debug +

    +
    + +
    + + +
    + +
    + +
    + +
    + +
    + +
    + +
    + SoundManager 2 speaker logo +
    + +

    SoundManager 2 makes it easier to play audio using JavaScript.

    + +

    + Using HTML5 and Flash, SoundManager 2 provides reliable cross-platform audio under a single JavaScript API.  Get SoundManager 2 +

    + +
    + +
    + +
    + +
    + +
    + +

    Speak and be heard

    +

    More sound, in more places

    + +

    Despite being one of the senses, sound has largely been missing from the web due to inconsistent technology support. SoundManager 2 bridges this gap, making it easier to use audio across a growing variety of devices and platforms, both desktop and mobile.

    + +

    Getting started is pretty easy, too.

    + +

    A few live examples:

    + +
    + +
    + +
    + +
    + + + +
    + Random +
    + + + + + +
    + +
    + coins.mp3 +    glass0.mp3 +    glass1.mp3 + + + +
    + +
    + +
    +
    + +
    + +
    + + +
    +
    + +

    HTML5 + flash hybrid

    +

    Complexity, reduced

    + +

    Supporting HTML5 audio can be tedious in modern browsers, let alone legacy ones. With real-world visitors using browsers ranging from mobile Safari to IE 6 across a wide range of devices, there can be many support cases to consider.

    + +

    SoundManager 2 gives you a single, powerful API that supports both new and old, using HTML5 audio where supported and optional Flash-based fallback where needed. Ideally when using SoundManager 2, audio "just works."

    + +
    +
      +
    • Desktop support: Windows, Mac OS, Linux
    • +
    • Laptop/tablet support: Windows, Mac OS, Linux / Blackberry Playbook, Kindle Fire + other HTML5/Flash devices
    • +
    • iPhone support: iOS 4.0 and newer
    • +
    • iPad support: Version 1.0 (iOS 3.2) and newer
    • +
    • Android OS supporting HTML5 and/or Flash (Version 2.3 or newer)
    • +
    + The details: how it works » +
    + +
    +
    + +
    +
    +

    The ginsu knife: 11 KB

    +

    Big features, small footprint

    +

    But wait, there's more!

    +

    Performance is an important metric, too. SoundManager 2 packs a comprehensive, feature-rich API into as little as 11 KB over the wire when optimized; that's less than 8% of the original, uncompressed file size.

    +

    SM2 is self-contained, having no external dependencies, and is compatible with popular JavaScript frameworks.

    +

    The source code is BSD-licensed and is provided in fully-commented, non-debug and compiler-optimized "minified" versions appropriate for development and production use.

    +
    +
    + +
    + + +
    + +
    +
    + +

    Basic

    +

    Playable links and playlists

    + +

    These demos use unordered lists with MP3 links that play in-place; the UI is easily customized via CSS.

    + + + + + +
    + +

    A richer playlist theme with optional time, seekable progress bar and a VU meter where supported:

    + + + + +
    +
    + +
    +
    + +

    Shiny

    +

    Data visualization features

    + +

    The 360° player UI demo uses <canvas> and includes options for waveform and spectrum analysis data via Flash 9, adding beautiful visual feedback to the interface.

    + +

    Seven Or Eight Days courtesy of Adrian Glynn, from the album Bruise. For more, see the music video.

    + + + + + +
    +
    + +
    + +
    + +

    Experimental

    +

    Advanced prototypes

    + +

    The Cassette Tape UI is a skinnable player based on the TDK MA-R90 cassette tape, a classic design from 1982.

    + +
    + Cassette Tape UI Prototype Screenshot +
    + +

    Remember Type IV, Metal & Chromium/CrO2? Those were the days.

    + +

    The "Wheels Of Steel" started as a simple CSS prototype, and evolved to replicate most of the UI and functionality of a traditional DJ set-up. Pitch bending, scratch and EQ effects are present where supported.

    +

    wheelsofsteel.net: Online turntable demo (screenshot)

    +

    The Wheels Of Steel, a browser-based DJ turntable prototype. For the tech details, read An Ode To Turntables (in HTML.)

    + +
    +
    + +
    + +
    + +
    +
    + +

    Getting started

    + +

    Basic SoundManager 2 set-up

    + +

    Including the script, configuring the url and registering an onready() callback:

    + +
    <script src="soundmanager2.js"></script>
    +<script>
    +soundManager.setup({
    +  // where to find flash audio SWFs, as needed
    +  url: '/path/to/swf-files/',
    +  onready: function() {
    +    // SM2 is ready to play audio!
    +  }
    +});
    +</script>
    + +

    Upon execution of soundmanager2.js, SM2 will determine what Flash SWF to load (if any) based on the path defined in soundManager.url.

    +

    After successful initialization, soundManager.onready() will fire and sounds can be played.

    +

    By default, SM2 uses a Flash 8-based SWF build. Some additional features are available when using the Flash 9-based build.

    + +

    For a live example, see the basic template demo.

    + +
    + +
    + + +
    + +
    + +

    Playing audio

    +

    Basic playback control

    + +

    Once soundManager.onready() has fired, sounds can be loaded and played.

    + +

    Creating and playing a sound object

    + +
    // create "mySound"...
    +var mySound = soundManager.createSound({
    +  url: '/path/to/an.mp3'
    +});
    +
    +// ...and play it
    +mySound.play();
    +
    + +

    Additional options and events can be specified when loading and playing sounds. For more examples of playback features, see API Demos.

    + +
    + +
    + +
    + +
    + +
    +
    + +

    Bonus

    +

    Additional demos

    + +

    + Examples using multi-track playback, progress and combinations of sound and animation: +

    + +
      + +
    • +

      Armor Alley (game)

      + Armor Alley: Web Prototype (demo screenshot) +
    • + +
    • +

      SURVIVOR remake

      + SURVIVOR (C64 game remake) demo screenshot +
    • + +
    • +

      Drum Machine

      + MPC (drum machine) demo screenshot +
    • + +
    • +

      Christmas Lights

      + Smash Christmas Lights demo +
    • + +
    + +

    "Audio sprites" (sound segments / samples) demo

    + +

    With sound playback options like from and to, you can play portions of a larger, single-file "sprite" of many sounds.

    + +

    + "Fitter, Happier" waveform screenshot +

    + + +

    + For more live examples, see the API Demos. +

    + +
    +
    + +
    +
    + +

    Elsewhere

    +

    As heard on TV the internets

    + +

    A few nifty places SoundManager 2 has been seen in use on the Wild World Web:

    + + + +

    Articles and presentations

    + +

    Some other words, pictures and video on the subject of HTML5 and web audio:

    + + + +

    Credits and thank-yous

    + +
      +
    • Icons: Desktop / mobile / iOS device iconography via glyphish.com (CC). Tile background: "Tiny Grid". Homepage header typeface: Chunk (Five) by Meredith Mandel (OFL).
    • +
    • Music: Seven Or Eight Days courtesy of Adrian Glynn. Graffiti Sex courtesy of The Fugitives, from the album In Streetlight Communion. I Tried and People Asking courtesy of SonReal.
    • +
    + +
    + +
    + + + + +
    + +
    + +
    +
    + +

    Technical overview

    + +

    HTML5 audio + optional Flash fallback

    + +
      +
    • 100% Flash-free audio on iPad, iPhone (iOS4) and other HTML5-enabled devices + browsers
    • +
    • Invisible Flash SWF provides HTML5 fallback as needed
    • +
    • API is consistent whether using HTML5 or Flash
    • +
    • See useHTML5Audio for implementation details
    • +
    + +
    +
    + +
    +
    + +

    API specifics

    +

    Basic API features (HTML5, Flash 8*)

    + +
      +
    • Load, stop, play, pause, mute, seek, pan*, volume control from JavaScript
    • +
    • Events: onload(), whileloading(), whileplaying(), onfinish() and more
    • +
    • ID3V1 + ID3V2 tag support for MP3s (title, artist, genre etc.)*
    • +
    + +
    + +

    Additional Flash 9-based API features

    + +
      +
    • RTMP / Flash Media Server streaming support (experimental) - see serverURL
    • +
    • MPEG-4 (AAC, HE-AAC, H.264) audio support
    • +
    • "MultiShot" play (layered/chorusing effects)
    • +
    • Waveform/frequency spectrum data
    • +
    • Peak (L/R channel volume) data
    • +
    • Audio buffering state/event handling
    • +
    + +
    +
    + +
    +
    + +

    Everything else

    +

    Documentation, tools and demos

    + + + +
    +

    Not only do you get the ginsu knife...

    +

    Even more demos and examples using the SoundManager 2 API...

    + + + +
    +
    + + + +
    + + + + +
    + +
    + +
     
    + + + +
    + + + +
    + +
    + + + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/license.txt b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/license.txt new file mode 100755 index 00000000..1a17182f --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/license.txt @@ -0,0 +1,29 @@ +Software License Agreement (BSD License) + +Copyright (c) 2007, Scott Schiller (schillmania.com) +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +* Neither the name of schillmania.com nor the names of its contributors may be + used to endorse or promote products derived from this software without + specific prior written permission from schillmania.com. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/script/soundmanager2-jsmin.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/script/soundmanager2-jsmin.js new file mode 100755 index 00000000..7a645020 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/script/soundmanager2-jsmin.js @@ -0,0 +1,110 @@ +/** @license + + + SoundManager 2: JavaScript Sound for the Web + ---------------------------------------------- + http://schillmania.com/projects/soundmanager2/ + + Copyright (c) 2007, Scott Schiller. All rights reserved. + Code provided under the BSD License: + http://schillmania.com/projects/soundmanager2/license.txt + + V2.97a.20131201 +*/ +(function(k,g){function fa(fa,wa){function ga(b){return c.preferFlash&&F&&!c.ignoreFlash&&c.flash[b]!==g&&c.flash[b]}function s(b){return function(d){var e=this._s;!e||!e._a?(e&&e.id?c._wD(e.id+": Ignoring "+d.type):c._wD(sb+"Ignoring "+d.type),d=null):d=b.call(this,d);return d}}this.setupOptions={url:fa||null,flashVersion:8,debugMode:!0,debugFlash:!1,useConsole:!0,consoleOnly:!0,waitForWindowLoad:!1,bgColor:"#ffffff",useHighPerformance:!1,flashPollingInterval:null,html5PollingInterval:null,flashLoadTimeout:1E3, +wmode:null,allowScriptAccess:"always",useFlashBlock:!1,useHTML5Audio:!0,html5Test:/^(probably|maybe)$/i,preferFlash:!1,noSWFCache:!1,idPrefix:"sound"};this.defaultOptions={autoLoad:!1,autoPlay:!1,from:null,loops:1,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onposition:null,onstop:null,onfailure:null,onfinish:null,multiShot:!0,multiShotEvents:!1,position:null,pan:0,stream:!0,to:null,type:null,usePolicyFile:!1,volume:100};this.flash9Options={isMovieStar:null, +usePeakData:!1,useWaveformData:!1,useEQData:!1,onbufferchange:null,ondataerror:null};this.movieStarOptions={bufferTime:3,serverURL:null,onconnect:null,duration:null};this.audioFormats={mp3:{type:['audio/mpeg; codecs\x3d"mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:!0},mp4:{related:["aac","m4a","m4b"],type:['audio/mp4; codecs\x3d"mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:!1},ogg:{type:["audio/ogg; codecs\x3dvorbis"],required:!1}, +opus:{type:["audio/ogg; codecs\x3dopus","audio/opus"],required:!1},wav:{type:['audio/wav; codecs\x3d"1"',"audio/wav","audio/wave","audio/x-wav"],required:!1}};this.movieID="sm2-container";this.id=wa||"sm2movie";this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.versionNumber="V2.97a.20131201";this.altURL=this.movieURL=this.version=null;this.enabled=this.swfLoaded=!1;this.oMC=null;this.sounds={};this.soundIDs=[];this.didFlashBlock=this.muted=!1;this.filePattern=null;this.filePatterns= +{flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.features={buffering:!1,peakData:!1,waveformData:!1,eqData:!1,movieStar:!1};this.sandbox={type:null,types:{remote:"remote (domain-based) rules",localWithFile:"local with file access (no internet access)",localWithNetwork:"local with network (internet access only, no local access)",localTrusted:"local, trusted (local+internet access)"},description:null,noRemote:null,noLocal:null};this.html5={usingFlash:null};this.flash={};this.ignoreFlash=this.html5Only= +!1;var Va,c=this,Wa=null,l=null,sb="HTML5::",A,u=navigator.userAgent,U=k.location.href.toString(),p=document,xa,Xa,ya,m,G=[],za=!0,C,V=!1,W=!1,q=!1,t=!1,ha=!1,n,tb=0,X,B,Aa,O,Ba,M,P,Q,Ya,Ca,Da,ia,I,ja,Ea,R,Fa,Y,ka,la,S,Za,Ga,$a=["log","info","warn","error"],ab,Ha,bb,Z=null,Ia=null,r,Ja,T,cb,ma,na,J,w,$=!1,Ka=!1,db,eb,fb,oa=0,aa=null,pa,N=[],ba,z=null,gb,qa,ca,K,ra,La,hb,x,ib=Array.prototype.slice,E=!1,Ma,F,Na,jb,H,kb,Oa,sa,lb=0,ta=u.match(/(ipad|iphone|ipod)/i),mb=u.match(/android/i),L=u.match(/msie/i), +ub=u.match(/webkit/i),ua=u.match(/safari/i)&&!u.match(/chrome/i),Pa=u.match(/opera/i),Qa=u.match(/(mobile|pre\/|xoom)/i)||ta||mb,Ra=!U.match(/usehtml5audio/i)&&!U.match(/sm2\-ignorebadua/i)&&ua&&!u.match(/silk/i)&&u.match(/OS X 10_6_([3-7])/i),da=k.console!==g&&console.log!==g,Sa=p.hasFocus!==g?p.hasFocus():null,va=ua&&(p.hasFocus===g||!p.hasFocus()),nb=!va,ob=/(mp3|mp4|mpa|m4a|m4b)/i,ea=p.location?p.location.protocol.match(/http/i):null,pb=!ea?"http://":"",qb=/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i, +rb="mpeg4 aac flv mov mp4 m4v f4v m4a m4b mp4v 3gp 3g2".split(" "),vb=RegExp("\\.("+rb.join("|")+")(\\?.*)?$","i");this.mimePattern=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;this.useAltURL=!ea;var Ta;try{Ta=Audio!==g&&(Pa&&opera!==g&&10>opera.version()?new Audio(null):new Audio).canPlayType!==g}catch(wb){Ta=!1}this.hasHTML5=Ta;this.setup=function(b){var d=!c.url;b!==g&&(q&&z&&c.ok()&&(b.flashVersion!==g||b.url!==g||b.html5Test!==g))&&J(r("setupLate"));Aa(b);b&&(d&&(Y&&b.url!==g)&&c.beginDelayedInit(), +!Y&&(b.url!==g&&"complete"===p.readyState)&&setTimeout(R,1));return c};this.supported=this.ok=function(){return z?q&&!t:c.useHTML5Audio&&c.hasHTML5};this.getMovie=function(c){return A(c)||p[c]||k[c]};this.createSound=function(b,d){function e(){f=ma(f);c.sounds[f.id]=new Va(f);c.soundIDs.push(f.id);return c.sounds[f.id]}var a,f;a=null;a="soundManager.createSound(): "+r(!q?"notReady":"notOK");if(!q||!c.ok())return J(a),!1;d!==g&&(b={id:b,url:d});f=B(b);f.url=pa(f.url);void 0===f.id&&(f.id=c.setupOptions.idPrefix+ +lb++);f.id.toString().charAt(0).match(/^[0-9]$/)&&c._wD("soundManager.createSound(): "+r("badID",f.id),2);c._wD("soundManager.createSound(): "+f.id+(f.url?" ("+f.url+")":""),1);if(w(f.id,!0))return c._wD("soundManager.createSound(): "+f.id+" exists",1),c.sounds[f.id];if(qa(f))a=e(),c._wD(f.id+": Using HTML5"),a._setup_html5(f);else{if(c.html5Only)return c._wD(f.id+": No HTML5 support for this sound, and no Flash. Exiting."),e();if(c.html5.usingFlash&&f.url&&f.url.match(/data\:/i))return c._wD(f.id+ +": data: URIs not supported via Flash. Exiting."),e();8a.instanceCount?(p(),e=a._setup_html5(),a.setPosition(a._iO.position),e.play()):(c._wD(a.id+": Cloning Audio() for instance #"+a.instanceCount+"..."),h=new Audio(a._iO.url),v=function(){x.remove(h,"ended",v);a._onfinish(a);ra(h);h=null},k=function(){x.remove(h,"canplay",k);try{h.currentTime=a._iO.position/1E3}catch(c){J(a.id+": multiShot play() failed to apply position of "+a._iO.position/1E3)}h.play()},x.add(h,"ended",v),void 0!==a._iO.volume&&(h.volume=Math.max(0,Math.min(1,a._iO.volume/ +100))),a.muted&&(h.muted=!0),a._iO.position?x.add(h,"canplay",k):h.play()):(y=l._start(a.id,a._iO.loops||1,9===m?a.position:a.position/1E3,a._iO.multiShot||!1),9===m&&!y&&(c._wD(e+"No sound hardware, or 32-sound ceiling hit",2),a._iO.onplayerror&&a._iO.onplayerror.apply(a)))}return a};this.stop=function(b){var d=a._iO;1===a.playState&&(c._wD(a.id+": stop()"),a._onbufferchange(0),a._resetOnPosition(0),a.paused=!1,a.isHTML5||(a.playState=0),Ua(),d.to&&a.clearOnPosition(d.to),a.isHTML5?a._a&&(b=a.position, +a.setPosition(0),a.position=b,a._a.pause(),a.playState=0,a._onTimer(),v()):(l._stop(a.id,b),d.serverURL&&a.unload()),a.instanceCount=0,a._iO={},d.onstop&&d.onstop.apply(a));return a};this.setAutoPlay=function(b){c._wD(a.id+": Autoplay turned "+(b?"on":"off"));a._iO.autoPlay=b;a.isHTML5||(l._setAutoPlay(a.id,b),b&&(!a.instanceCount&&1===a.readyState)&&(a.instanceCount++,c._wD(a.id+": Incremented instance count to "+a.instanceCount)))};this.getAutoPlay=function(){return a._iO.autoPlay};this.setPosition= +function(b){b===g&&(b=0);var d=a.isHTML5?Math.max(b,0):Math.min(a.duration||a._iO.duration,Math.max(b,0));a.position=d;b=a.position/1E3;a._resetOnPosition(a.position);a._iO.position=d;if(a.isHTML5){if(a._a){if(a._html5_canplay){if(a._a.currentTime!==b){c._wD(a.id+": setPosition("+b+")");try{a._a.currentTime=b,(0===a.playState||a.paused)&&a._a.pause()}catch(e){c._wD(a.id+": setPosition("+b+") failed: "+e.message,2)}}}else if(b)return c._wD(a.id+": setPosition("+b+"): Cannot seek yet, sound not ready", +2),a;a.paused&&a._onTimer(!0)}}else b=9===m?a.position:b,a.readyState&&2!==a.readyState&&l._setPosition(a.id,b,a.paused||!a.playState,a._iO.multiShot);return a};this.pause=function(b){if(a.paused||0===a.playState&&1!==a.readyState)return a;c._wD(a.id+": pause()");a.paused=!0;a.isHTML5?(a._setup_html5().pause(),v()):(b||b===g)&&l._pause(a.id,a._iO.multiShot);a._iO.onpause&&a._iO.onpause.apply(a);return a};this.resume=function(){var b=a._iO;if(!a.paused)return a;c._wD(a.id+": resume()");a.paused=!1; +a.playState=1;a.isHTML5?(a._setup_html5().play(),p()):(b.isMovieStar&&!b.serverURL&&a.setPosition(a.position),l._pause(a.id,b.multiShot));!s&&b.onplay?(b.onplay.apply(a),s=!0):b.onresume&&b.onresume.apply(a);return a};this.togglePause=function(){c._wD(a.id+": togglePause()");if(0===a.playState)return a.play({position:9===m&&!a.isHTML5?a.position:a.position/1E3}),a;a.paused?a.resume():a.pause();return a};this.setPan=function(b,c){b===g&&(b=0);c===g&&(c=!1);a.isHTML5||l._setPan(a.id,b);a._iO.pan=b; +c||(a.pan=b,a.options.pan=b);return a};this.setVolume=function(b,d){b===g&&(b=100);d===g&&(d=!1);a.isHTML5?a._a&&(c.muted&&!a.muted&&(a.muted=!0,a._a.muted=!0),a._a.volume=Math.max(0,Math.min(1,b/100))):l._setVolume(a.id,c.muted&&!a.muted||a.muted?0:b);a._iO.volume=b;d||(a.volume=b,a.options.volume=b);return a};this.mute=function(){a.muted=!0;a.isHTML5?a._a&&(a._a.muted=!0):l._setVolume(a.id,0);return a};this.unmute=function(){a.muted=!1;var b=a._iO.volume!==g;a.isHTML5?a._a&&(a._a.muted=!1):l._setVolume(a.id, +b?a._iO.volume:a.options.volume);return a};this.toggleMute=function(){return a.muted?a.unmute():a.mute()};this.onposition=this.onPosition=function(b,c,d){D.push({position:parseInt(b,10),method:c,scope:d!==g?d:a,fired:!1});return a};this.clearOnPosition=function(a,b){var c;a=parseInt(a,10);if(isNaN(a))return!1;for(c=0;c=b)return!1;for(b-= +1;0<=b;b--)c=D[b],!c.fired&&a.position>=c.position&&(c.fired=!0,u++,c.method.apply(c.scope,[c.position]));return!0};this._resetOnPosition=function(a){var b,c;b=D.length;if(!b)return!1;for(b-=1;0<=b;b--)c=D[b],c.fired&&a<=c.position&&(c.fired=!1,u--);return!0};z=function(){var b=a._iO,d=b.from,e=b.to,f,g;g=function(){c._wD(a.id+': "To" time of '+e+" reached.");a.clearOnPosition(e,g);a.stop()};f=function(){c._wD(a.id+': Playing "from" '+d);if(null!==e&&!isNaN(e))a.onPosition(e,g)};null!==d&&!isNaN(d)&& +(b.position=d,b.multiShot=!1,f());return b};q=function(){var b,c=a._iO.onposition;if(c)for(b in c)if(c.hasOwnProperty(b))a.onPosition(parseInt(b,10),c[b])};Ua=function(){var b,c=a._iO.onposition;if(c)for(b in c)c.hasOwnProperty(b)&&a.clearOnPosition(parseInt(b,10))};p=function(){a.isHTML5&&db(a)};v=function(){a.isHTML5&&eb(a)};f=function(b){b||(D=[],u=0);s=!1;a._hasTimer=null;a._a=null;a._html5_canplay=!1;a.bytesLoaded=null;a.bytesTotal=null;a.duration=a._iO&&a._iO.duration?a._iO.duration:null;a.durationEstimate= +null;a.buffered=[];a.eqData=[];a.eqData.left=[];a.eqData.right=[];a.failures=0;a.isBuffering=!1;a.instanceOptions={};a.instanceCount=0;a.loaded=!1;a.metadata={};a.readyState=0;a.muted=!1;a.paused=!1;a.peakData={left:0,right:0};a.waveformData={left:[],right:[]};a.playState=0;a.position=null;a.id3={}};f();this._onTimer=function(b){var c,f=!1,g={};if(a._hasTimer||b){if(a._a&&(b||(0opera.version()?new Audio(null):new Audio,c=a._a,c._called_load=!1,E&&(Wa=c);a.isHTML5=!0;a._a=c;c._s=a;k();a._apply_loop(c,b.loops);b.autoLoad||b.autoPlay?a.load():(c.autobuffer=!1,c.preload="auto");return c};k=function(){if(a._a._added_events)return!1; +var b;a._a._added_events=!0;for(b in H)H.hasOwnProperty(b)&&a._a&&a._a.addEventListener(b,H[b],!1);return!0};h=function(){var b;c._wD(a.id+": Removing event listeners");a._a._added_events=!1;for(b in H)H.hasOwnProperty(b)&&a._a&&a._a.removeEventListener(b,H[b],!1)};this._onload=function(b){var d=!!b||!a.isHTML5&&8===m&&a.duration;b=a.id+": ";c._wD(b+(d?"onload()":"Failed to load / invalid sound?"+(!a.duration?" Zero-length duration reported.":" -")+" ("+a.url+")"),d?1:2);!d&&!a.isHTML5&&(!0===c.sandbox.noRemote&& +c._wD(b+r("noNet"),1),!0===c.sandbox.noLocal&&c._wD(b+r("noLocal"),1));a.loaded=d;a.readyState=d?3:2;a._onbufferchange(0);a._iO.onload&&sa(a,function(){a._iO.onload.apply(a,[d])});return!0};this._onbufferchange=function(b){if(0===a.playState||b&&a.isBuffering||!b&&!a.isBuffering)return!1;a.isBuffering=1===b;a._iO.onbufferchange&&(c._wD(a.id+": Buffer state change: "+b),a._iO.onbufferchange.apply(a));return!0};this._onsuspend=function(){a._iO.onsuspend&&(c._wD(a.id+": Playback suspended"),a._iO.onsuspend.apply(a)); +return!0};this._onfailure=function(b,d,e){a.failures++;c._wD(a.id+": Failures \x3d "+a.failures);if(a._iO.onfailure&&1===a.failures)a._iO.onfailure(a,b,d,e);else c._wD(a.id+": Ignoring failure")};this._onfinish=function(){var b=a._iO.onfinish;a._onbufferchange(0);a._resetOnPosition(0);if(a.instanceCount&&(a.instanceCount--,a.instanceCount||(Ua(),a.playState=0,a.paused=!1,a.instanceCount=0,a.instanceOptions={},a._iO={},v(),a.isHTML5&&(a.position=0)),(!a.instanceCount||a._iO.multiShotEvents)&&b))c._wD(a.id+ +": onfinish()"),sa(a,function(){b.apply(a)})};this._whileloading=function(b,c,d,e){var f=a._iO;a.bytesLoaded=b;a.bytesTotal=c;a.duration=Math.floor(d);a.bufferLength=e;a.durationEstimate=!a.isHTML5&&!f.isMovieStar?f.duration?a.duration>f.duration?a.duration:f.duration:parseInt(a.bytesTotal/a.bytesLoaded*a.duration,10):a.duration;a.isHTML5||(a.buffered=[{start:0,end:a.duration}]);(3!==a.readyState||a.isHTML5)&&f.whileloading&&f.whileloading.apply(a)};this._whileplaying=function(b,c,d,e,f){var h=a._iO; +if(isNaN(b)||null===b)return!1;a.position=Math.max(0,b);a._processOnPosition();!a.isHTML5&&8opera.version()? +new Audio(null):new Audio:null,e,a,f={},k,h;k=c.audioFormats;for(e in k)if(k.hasOwnProperty(e)&&(a="audio/"+e,f[e]=b(k[e].type),f[a]=f[e],e.match(ob)?(c.flash[e]=!0,c.flash[a]=!0):(c.flash[e]=!1,c.flash[a]=!1),k[e]&&k[e].related))for(h=k[e].related.length-1;0<=h;h--)f["audio/"+k[e].related[h]]=f[e],c.html5[k[e].related[h]]=f[e],c.flash[k[e].related[h]]=f[e];f.canPlayType=d?b:null;c.html5=B(c.html5,f);c.html5.usingFlash=gb();z=c.html5.usingFlash;return!0};I={notReady:"Unavailable - wait until onready() has fired.", +notOK:"Audio support is not available.",domError:"soundManagerexception caught while appending SWF to DOM.",spcWmode:"Removing wmode, preventing known SWF loading issue(s)",swf404:"soundManager: Verify that %s is a valid path.",tryDebug:"Try soundManager.debugFlash \x3d true for more security details (output goes to SWF.)",checkSWF:"See SWF output for more debug info.",localFail:"soundManager: Non-HTTP page ("+p.location.protocol+" URL?) Review Flash player security settings for this special case:\nhttp://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html\nMay need to add/allow path, eg. c:/sm2/ or /users/me/sm2/", +waitFocus:"soundManager: Special case: Waiting for SWF to load with window focus...",waitForever:"soundManager: Waiting indefinitely for Flash (will recover if unblocked)...",waitSWF:"soundManager: Waiting for 100% SWF load...",needFunction:"soundManager: Function object expected for %s",badID:'Sound ID "%s" should be a string, starting with a non-numeric character',currentObj:"soundManager: _debug(): Current sound objects",waitOnload:"soundManager: Waiting for window.onload()",docLoaded:"soundManager: Document already loaded", +onload:"soundManager: initComplete(): calling soundManager.onload()",onloadOK:"soundManager.onload() complete",didInit:"soundManager: init(): Already called?",secNote:"Flash security note: Network/internet URLs will not load due to security restrictions. Access can be configured via Flash Player Global Security Settings Page: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html",badRemove:"soundManager: Failed to remove Flash node.",shutdown:"soundManager.disable(): Shutting down", +queue:"soundManager: Queueing %s handler",smError:"SMSound.load(): Exception: JS-Flash communication failed, or JS error.",fbTimeout:"No flash response, applying .swf_timedout CSS...",fbLoaded:"Flash loaded",fbHandler:"soundManager: flashBlockHandler()",manURL:"SMSound.load(): Using manually-assigned URL",onURL:"soundManager.load(): current URL already assigned.",badFV:'soundManager.flashVersion must be 8 or 9. "%s" is invalid. Reverting to %s.',as2loop:"Note: Setting stream:false so looping can work (flash 8 limitation)", +noNSLoop:"Note: Looping not implemented for MovieStar formats",needfl9:"Note: Switching to flash 9, required for MP4 formats.",mfTimeout:"Setting flashLoadTimeout \x3d 0 (infinite) for off-screen, mobile flash case",needFlash:"soundManager: Fatal error: Flash is needed to play some required formats, but is not available.",gotFocus:"soundManager: Got window focus.",policy:"Enabling usePolicyFile for data access",setup:"soundManager.setup(): allowed parameters: %s",setupError:'soundManager.setup(): "%s" cannot be assigned with this method.', +setupUndef:'soundManager.setup(): Could not find option "%s"',setupLate:"soundManager.setup(): url, flashVersion and html5Test property changes will not take effect until reboot().",noURL:"soundManager: Flash URL required. Call soundManager.setup({url:...}) to get started.",sm2Loaded:"SoundManager 2: Ready.",reset:"soundManager.reset(): Removing event callbacks",mobileUA:"Mobile UA detected, preferring HTML5 by default.",globalHTML5:"Using singleton HTML5 Audio() pattern for this device."};r=function(){var b, +c,e,a;b=ib.call(arguments);c=b.shift();if((a=I&&I[c]?I[c]:"")&&b&&b.length){c=0;for(e=b.length;cm)&&(c._wD(r("needfl9")),c.flashVersion=m=9);c.version=c.versionNumber+(c.html5Only?" (HTML5-only mode)":9===m?" (AS3/Flash 9)":" (AS2/Flash 8)");8b&&(d=!0));setTimeout(function(){b=c.getMoviePercent();if(d)return $=!1,c._wD(r("waitSWF")),k.setTimeout(Q,1),!1;q||(c._wD("soundManager: No Flash response within expected time. Likely causes: "+(0===b?"SWF load failed, ":"")+"Flash blocked or JS-Flash security error."+(c.debugFlash? +" "+r("checkSWF"):""),2),!ea&&b&&(n("localFail",2),c.debugFlash||n("tryDebug",2)),0===b&&c._wD(r("swf404",c.url),1),C("flashtojs",!1,": Timed out"+ea?" (Check flash security or flash blockers)":" (No plugin/missing SWF?)"));!q&&nb&&(null===b?c.useFlashBlock||0===c.flashLoadTimeout?(c.useFlashBlock&&Ja(),n("waitForever")):!c.useFlashBlock&&ba?Ca():(n("waitForever"),M({type:"ontimeout",ignoreInit:!0,error:{type:"INIT_FLASHBLOCK"}})):0===c.flashLoadTimeout?n("waitForever"):!c.useFlashBlock&&ba?Ca(): +Ha(!0))},c.flashLoadTimeout)};ia=function(){if(Sa||!va)return x.remove(k,"focus",ia),!0;Sa=nb=!0;n("gotFocus");$=!1;Q();x.remove(k,"focus",ia);return!0};Oa=function(){N.length&&(c._wD("SoundManager 2: "+N.join(" "),1),N=[])};kb=function(){Oa();var b,d=[];if(c.useHTML5Audio&&c.hasHTML5){for(b in c.audioFormats)c.audioFormats.hasOwnProperty(b)&&d.push(b+" \x3d "+c.html5[b]+(!c.html5[b]&&z&&c.flash[b]?" (using flash)":c.preferFlash&&c.flash[b]&&z?" (preferring flash)":!c.html5[b]?" ("+(c.audioFormats[b].required? +"required, ":"")+"and no flash support)":""));c._wD("SoundManager 2 HTML5 support: "+d.join(", "),1)}};X=function(b){if(q)return!1;if(c.html5Only)return n("sm2Loaded"),q=!0,P(),C("onload",!0),!0;var d=!0,e;if(!c.useFlashBlock||!c.flashLoadTimeout||c.getMoviePercent())q=!0;e={type:!F&&z?"NO_FLASH":"INIT_TIMEOUT"};c._wD("SoundManager 2 "+(t?"failed to load":"loaded")+" ("+(t?"Flash security/load error":"OK")+")",t?2:1);t||b?(c.useFlashBlock&&c.oMC&&(c.oMC.className=T()+" "+(null===c.getMoviePercent()? +"swf_timedout":"swf_error")),M({type:"ontimeout",error:e,ignoreInit:!0}),C("onload",!1),S(e),d=!1):C("onload",!0);t||(c.waitForWindowLoad&&!ha?(n("waitOnload"),x.add(k,"load",P)):(c.waitForWindowLoad&&ha&&n("docLoaded"),P()));return d};Xa=function(){var b,d=c.setupOptions;for(b in d)d.hasOwnProperty(b)&&(c[b]===g?c[b]=d[b]:c[b]!==d[b]&&(c.setupOptions[b]=c[b]))};ya=function(){if(q)return n("didInit"),!1;if(c.html5Only)return q||(x.remove(k,"load",c.beginDelayedInit),c.enabled=!0,X()),!0;ja();try{l._externalInterfaceTest(!1), +Za(!0,c.flashPollingInterval||(c.useHighPerformance?10:50)),c.debugMode||l._disableDebug(),c.enabled=!0,C("jstoflash",!0),c.html5Only||x.add(k,"unload",xa)}catch(b){return c._wD("js/flash exception: "+b.toString()),C("jstoflash",!1),S({type:"JS_TO_FLASH_EXCEPTION",fatal:!0}),Ha(!0),X(),!1}X();x.remove(k,"load",c.beginDelayedInit);return!0};R=function(){if(Y)return!1;Y=!0;Xa();Ga();var b=null,b=null,d=U.toLowerCase();-1!==d.indexOf("sm2-usehtml5audio\x3d")&&(b="1"===d.charAt(d.indexOf("sm2-usehtml5audio\x3d")+ +18),da&&console.log((b?"Enabling ":"Disabling ")+"useHTML5Audio via URL parameter"),c.setup({useHTML5Audio:b}));-1!==d.indexOf("sm2-preferflash\x3d")&&(b="1"===d.charAt(d.indexOf("sm2-preferflash\x3d")+16),da&&console.log((b?"Enabling ":"Disabling ")+"preferFlash via URL parameter"),c.setup({preferFlash:b}));!F&&c.hasHTML5&&(c._wD("SoundManager 2: No Flash detected"+(!c.useHTML5Audio?", enabling HTML5.":". Trying HTML5-only mode."),1),c.setup({useHTML5Audio:!0,preferFlash:!1}));hb();!F&&z&&(N.push(I.needFlash), +c.setup({flashLoadTimeout:1}));p.removeEventListener&&p.removeEventListener("DOMContentLoaded",R,!1);ja();return!0};La=function(){"complete"===p.readyState&&(R(),p.detachEvent("onreadystatechange",La));return!0};Fa=function(){ha=!0;x.remove(k,"load",Fa)};Ea=function(){if(Qa&&((!c.setupOptions.useHTML5Audio||c.setupOptions.preferFlash)&&N.push(I.mobileUA),c.setupOptions.useHTML5Audio=!0,c.setupOptions.preferFlash=!1,ta||mb&&!u.match(/android\s2\.3/i)))N.push(I.globalHTML5),ta&&(c.ignoreFlash=!0),E= +!0};Ea();Na();x.add(k,"focus",ia);x.add(k,"load",Q);x.add(k,"load",Fa);p.addEventListener?p.addEventListener("DOMContentLoaded",R,!1):p.attachEvent?p.attachEvent("onreadystatechange",La):(C("onload",!1),S({type:"NO_DOM2_EVENTS",fatal:!0}))}var wa=null;if(void 0===k.SM2_DEFER||!SM2_DEFER)wa=new fa;k.SoundManager=fa;k.soundManager=wa})(window); \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/script/soundmanager2-nodebug-jsmin.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/script/soundmanager2-nodebug-jsmin.js new file mode 100755 index 00000000..d7227094 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/script/soundmanager2-nodebug-jsmin.js @@ -0,0 +1,81 @@ +/** @license + * + * SoundManager 2: JavaScript Sound for the Web + * ---------------------------------------------- + * http://schillmania.com/projects/soundmanager2/ + * + * Copyright (c) 2007, Scott Schiller. All rights reserved. + * Code provided under the BSD License: + * http://schillmania.com/projects/soundmanager2/license.txt + * + * V2.97a.20131201 + */ +(function(g,k){function U(U,ka){function V(b){return c.preferFlash&&v&&!c.ignoreFlash&&c.flash[b]!==k&&c.flash[b]}function q(b){return function(c){var d=this._s;return!d||!d._a?null:b.call(this,c)}}this.setupOptions={url:U||null,flashVersion:8,debugMode:!0,debugFlash:!1,useConsole:!0,consoleOnly:!0,waitForWindowLoad:!1,bgColor:"#ffffff",useHighPerformance:!1,flashPollingInterval:null,html5PollingInterval:null,flashLoadTimeout:1E3,wmode:null,allowScriptAccess:"always",useFlashBlock:!1,useHTML5Audio:!0, +html5Test:/^(probably|maybe)$/i,preferFlash:!1,noSWFCache:!1,idPrefix:"sound"};this.defaultOptions={autoLoad:!1,autoPlay:!1,from:null,loops:1,onid3:null,onload:null,whileloading:null,onplay:null,onpause:null,onresume:null,whileplaying:null,onposition:null,onstop:null,onfailure:null,onfinish:null,multiShot:!0,multiShotEvents:!1,position:null,pan:0,stream:!0,to:null,type:null,usePolicyFile:!1,volume:100};this.flash9Options={isMovieStar:null,usePeakData:!1,useWaveformData:!1,useEQData:!1,onbufferchange:null, +ondataerror:null};this.movieStarOptions={bufferTime:3,serverURL:null,onconnect:null,duration:null};this.audioFormats={mp3:{type:['audio/mpeg; codecs\x3d"mp3"',"audio/mpeg","audio/mp3","audio/MPA","audio/mpa-robust"],required:!0},mp4:{related:["aac","m4a","m4b"],type:['audio/mp4; codecs\x3d"mp4a.40.2"',"audio/aac","audio/x-m4a","audio/MP4A-LATM","audio/mpeg4-generic"],required:!1},ogg:{type:["audio/ogg; codecs\x3dvorbis"],required:!1},opus:{type:["audio/ogg; codecs\x3dopus","audio/opus"],required:!1}, +wav:{type:['audio/wav; codecs\x3d"1"',"audio/wav","audio/wave","audio/x-wav"],required:!1}};this.movieID="sm2-container";this.id=ka||"sm2movie";this.debugID="soundmanager-debug";this.debugURLParam=/([#?&])debug=1/i;this.versionNumber="V2.97a.20131201";this.altURL=this.movieURL=this.version=null;this.enabled=this.swfLoaded=!1;this.oMC=null;this.sounds={};this.soundIDs=[];this.didFlashBlock=this.muted=!1;this.filePattern=null;this.filePatterns={flash8:/\.mp3(\?.*)?$/i,flash9:/\.mp3(\?.*)?$/i};this.features= +{buffering:!1,peakData:!1,waveformData:!1,eqData:!1,movieStar:!1};this.sandbox={};this.html5={usingFlash:null};this.flash={};this.ignoreFlash=this.html5Only=!1;var Ja,c=this,Ka=null,l=null,W,s=navigator.userAgent,La=g.location.href.toString(),n=document,la,Ma,ma,m,x=[],K=!1,L=!1,p=!1,y=!1,na=!1,M,w,oa,X,pa,D,E,F,Na,qa,ra,Y,sa,Z,ta,G,ua,N,va,$,H,Oa,wa,Pa,xa,Qa,O=null,ya=null,P,za,I,aa,ba,r,Q=!1,Aa=!1,Ra,Sa,Ta,ca=0,R=null,da,Ua=[],S,u=null,Va,ea,T,z,fa,Ba,Wa,t,fb=Array.prototype.slice,A=!1,Ca,v,Da, +Xa,B,ga,Ya=0,ha=s.match(/(ipad|iphone|ipod)/i),Za=s.match(/android/i),C=s.match(/msie/i),gb=s.match(/webkit/i),ia=s.match(/safari/i)&&!s.match(/chrome/i),Ea=s.match(/opera/i),Fa=s.match(/(mobile|pre\/|xoom)/i)||ha||Za,$a=!La.match(/usehtml5audio/i)&&!La.match(/sm2\-ignorebadua/i)&&ia&&!s.match(/silk/i)&&s.match(/OS X 10_6_([3-7])/i),Ga=n.hasFocus!==k?n.hasFocus():null,ja=ia&&(n.hasFocus===k||!n.hasFocus()),ab=!ja,bb=/(mp3|mp4|mpa|m4a|m4b)/i,Ha=n.location?n.location.protocol.match(/http/i):null,cb= +!Ha?"http://":"",db=/^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i,eb="mpeg4 aac flv mov mp4 m4v f4v m4a m4b mp4v 3gp 3g2".split(" "),hb=RegExp("\\.("+eb.join("|")+")(\\?.*)?$","i");this.mimePattern=/^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i;this.useAltURL=!Ha;var Ia;try{Ia=Audio!==k&&(Ea&&opera!==k&&10>opera.version()?new Audio(null):new Audio).canPlayType!==k}catch(ib){Ia=!1}this.hasHTML5=Ia;this.setup=function(b){var e=!c.url;b!==k&&p&&u&&c.ok();oa(b);b&& +(e&&(N&&b.url!==k)&&c.beginDelayedInit(),!N&&(b.url!==k&&"complete"===n.readyState)&&setTimeout(G,1));return c};this.supported=this.ok=function(){return u?p&&!y:c.useHTML5Audio&&c.hasHTML5};this.getMovie=function(b){return W(b)||n[b]||g[b]};this.createSound=function(b,e){function d(){a=aa(a);c.sounds[a.id]=new Ja(a);c.soundIDs.push(a.id);return c.sounds[a.id]}var a,f=null;if(!p||!c.ok())return!1;e!==k&&(b={id:b,url:e});a=w(b);a.url=da(a.url);void 0===a.id&&(a.id=c.setupOptions.idPrefix+Ya++);if(r(a.id, +!0))return c.sounds[a.id];if(ea(a))f=d(),f._setup_html5(a);else{if(c.html5Only||c.html5.usingFlash&&a.url&&a.url.match(/data\:/i))return d();8a.instanceCount?(n(),f=a._setup_html5(),a.setPosition(a._iO.position),f.play()):(h=new Audio(a._iO.url),g=function(){t.remove(h,"ended",g);a._onfinish(a);fa(h);h=null},J=function(){t.remove(h,"canplay",J);try{h.currentTime=a._iO.position/1E3}catch(b){}h.play()},t.add(h,"ended",g),void 0!==a._iO.volume&&(h.volume=Math.max(0,Math.min(1,a._iO.volume/100))),a.muted&&(h.muted=!0),a._iO.position? +t.add(h,"canplay",J):h.play()):(f=l._start(a.id,a._iO.loops||1,9===m?a.position:a.position/1E3,a._iO.multiShot||!1),9===m&&!f&&a._iO.onplayerror&&a._iO.onplayerror.apply(a))}return a};this.stop=function(b){var c=a._iO;1===a.playState&&(a._onbufferchange(0),a._resetOnPosition(0),a.paused=!1,a.isHTML5||(a.playState=0),x(),c.to&&a.clearOnPosition(c.to),a.isHTML5?a._a&&(b=a.position,a.setPosition(0),a.position=b,a._a.pause(),a.playState=0,a._onTimer(),g()):(l._stop(a.id,b),c.serverURL&&a.unload()),a.instanceCount= +0,a._iO={},c.onstop&&c.onstop.apply(a));return a};this.setAutoPlay=function(b){a._iO.autoPlay=b;a.isHTML5||(l._setAutoPlay(a.id,b),b&&!a.instanceCount&&1===a.readyState&&a.instanceCount++)};this.getAutoPlay=function(){return a._iO.autoPlay};this.setPosition=function(b){b===k&&(b=0);var c=a.isHTML5?Math.max(b,0):Math.min(a.duration||a._iO.duration,Math.max(b,0));a.position=c;b=a.position/1E3;a._resetOnPosition(a.position);a._iO.position=c;if(a.isHTML5){if(a._a){if(a._html5_canplay){if(a._a.currentTime!== +b)try{a._a.currentTime=b,(0===a.playState||a.paused)&&a._a.pause()}catch(e){}}else if(b)return a;a.paused&&a._onTimer(!0)}}else b=9===m?a.position:b,a.readyState&&2!==a.readyState&&l._setPosition(a.id,b,a.paused||!a.playState,a._iO.multiShot);return a};this.pause=function(b){if(a.paused||0===a.playState&&1!==a.readyState)return a;a.paused=!0;a.isHTML5?(a._setup_html5().pause(),g()):(b||b===k)&&l._pause(a.id,a._iO.multiShot);a._iO.onpause&&a._iO.onpause.apply(a);return a};this.resume=function(){var b= +a._iO;if(!a.paused)return a;a.paused=!1;a.playState=1;a.isHTML5?(a._setup_html5().play(),n()):(b.isMovieStar&&!b.serverURL&&a.setPosition(a.position),l._pause(a.id,b.multiShot));!s&&b.onplay?(b.onplay.apply(a),s=!0):b.onresume&&b.onresume.apply(a);return a};this.togglePause=function(){if(0===a.playState)return a.play({position:9===m&&!a.isHTML5?a.position:a.position/1E3}),a;a.paused?a.resume():a.pause();return a};this.setPan=function(b,c){b===k&&(b=0);c===k&&(c=!1);a.isHTML5||l._setPan(a.id,b);a._iO.pan= +b;c||(a.pan=b,a.options.pan=b);return a};this.setVolume=function(b,e){b===k&&(b=100);e===k&&(e=!1);a.isHTML5?a._a&&(c.muted&&!a.muted&&(a.muted=!0,a._a.muted=!0),a._a.volume=Math.max(0,Math.min(1,b/100))):l._setVolume(a.id,c.muted&&!a.muted||a.muted?0:b);a._iO.volume=b;e||(a.volume=b,a.options.volume=b);return a};this.mute=function(){a.muted=!0;a.isHTML5?a._a&&(a._a.muted=!0):l._setVolume(a.id,0);return a};this.unmute=function(){a.muted=!1;var b=a._iO.volume!==k;a.isHTML5?a._a&&(a._a.muted=!1):l._setVolume(a.id, +b?a._iO.volume:a.options.volume);return a};this.toggleMute=function(){return a.muted?a.unmute():a.mute()};this.onposition=this.onPosition=function(b,c,e){p.push({position:parseInt(b,10),method:c,scope:e!==k?e:a,fired:!1});return a};this.clearOnPosition=function(a,b){var c;a=parseInt(a,10);if(isNaN(a))return!1;for(c=0;c=b)return!1;for(b-= +1;0<=b;b--)c=p[b],!c.fired&&a.position>=c.position&&(c.fired=!0,u++,c.method.apply(c.scope,[c.position]));return!0};this._resetOnPosition=function(a){var b,c;b=p.length;if(!b)return!1;for(b-=1;0<=b;b--)c=p[b],c.fired&&a<=c.position&&(c.fired=!1,u--);return!0};y=function(){var b=a._iO,c=b.from,e=b.to,d,f;f=function(){a.clearOnPosition(e,f);a.stop()};d=function(){if(null!==e&&!isNaN(e))a.onPosition(e,f)};null!==c&&!isNaN(c)&&(b.position=c,b.multiShot=!1,d());return b};q=function(){var b,c=a._iO.onposition; +if(c)for(b in c)if(c.hasOwnProperty(b))a.onPosition(parseInt(b,10),c[b])};x=function(){var b,c=a._iO.onposition;if(c)for(b in c)c.hasOwnProperty(b)&&a.clearOnPosition(parseInt(b,10))};n=function(){a.isHTML5&&Ra(a)};g=function(){a.isHTML5&&Sa(a)};f=function(b){b||(p=[],u=0);s=!1;a._hasTimer=null;a._a=null;a._html5_canplay=!1;a.bytesLoaded=null;a.bytesTotal=null;a.duration=a._iO&&a._iO.duration?a._iO.duration:null;a.durationEstimate=null;a.buffered=[];a.eqData=[];a.eqData.left=[];a.eqData.right=[]; +a.failures=0;a.isBuffering=!1;a.instanceOptions={};a.instanceCount=0;a.loaded=!1;a.metadata={};a.readyState=0;a.muted=!1;a.paused=!1;a.peakData={left:0,right:0};a.waveformData={left:[],right:[]};a.playState=0;a.position=null;a.id3={}};f();this._onTimer=function(b){var c,f=!1,h={};if(a._hasTimer||b){if(a._a&&(b||(0opera.version()?new Audio(null):new Audio,c=a._a,c._called_load=!1,A&&(Ka=c);a.isHTML5=!0;a._a=c;c._s=a;h();a._apply_loop(c,b.loops);b.autoLoad||b.autoPlay?a.load():(c.autobuffer=!1,c.preload="auto");return c};h=function(){if(a._a._added_events)return!1;var b;a._a._added_events=!0;for(b in B)B.hasOwnProperty(b)&&a._a&&a._a.addEventListener(b,B[b],!1);return!0};J=function(){var b;a._a._added_events= +!1;for(b in B)B.hasOwnProperty(b)&&a._a&&a._a.removeEventListener(b,B[b],!1)};this._onload=function(b){var c=!!b||!a.isHTML5&&8===m&&a.duration;a.loaded=c;a.readyState=c?3:2;a._onbufferchange(0);a._iO.onload&&ga(a,function(){a._iO.onload.apply(a,[c])});return!0};this._onbufferchange=function(b){if(0===a.playState||b&&a.isBuffering||!b&&!a.isBuffering)return!1;a.isBuffering=1===b;a._iO.onbufferchange&&a._iO.onbufferchange.apply(a);return!0};this._onsuspend=function(){a._iO.onsuspend&&a._iO.onsuspend.apply(a); +return!0};this._onfailure=function(b,c,e){a.failures++;if(a._iO.onfailure&&1===a.failures)a._iO.onfailure(a,b,c,e)};this._onfinish=function(){var b=a._iO.onfinish;a._onbufferchange(0);a._resetOnPosition(0);a.instanceCount&&(a.instanceCount--,a.instanceCount||(x(),a.playState=0,a.paused=!1,a.instanceCount=0,a.instanceOptions={},a._iO={},g(),a.isHTML5&&(a.position=0)),(!a.instanceCount||a._iO.multiShotEvents)&&b&&ga(a,function(){b.apply(a)}))};this._whileloading=function(b,c,e,d){var f=a._iO;a.bytesLoaded= +b;a.bytesTotal=c;a.duration=Math.floor(e);a.bufferLength=d;a.durationEstimate=!a.isHTML5&&!f.isMovieStar?f.duration?a.duration>f.duration?a.duration:f.duration:parseInt(a.bytesTotal/a.bytesLoaded*a.duration,10):a.duration;a.isHTML5||(a.buffered=[{start:0,end:a.duration}]);(3!==a.readyState||a.isHTML5)&&f.whileloading&&f.whileloading.apply(a)};this._whileplaying=function(b,c,e,d,f){var h=a._iO;if(isNaN(b)||null===b)return!1;a.position=Math.max(0,b);a._processOnPosition();!a.isHTML5&&8opera.version()?new Audio(null):new Audio:null,d,a,f={},h,g;h=c.audioFormats;for(d in h)if(h.hasOwnProperty(d)&&(a="audio/"+d,f[d]=b(h[d].type),f[a]=f[d],d.match(bb)?(c.flash[d]=!0,c.flash[a]=!0):(c.flash[d]=!1,c.flash[a]=!1),h[d]&&h[d].related))for(g=h[d].related.length-1;0<=g;g--)f["audio/"+h[d].related[g]]=f[d],c.html5[h[d].related[g]]=f[d],c.flash[h[d].related[g]]=f[d];f.canPlayType=e?b:null;c.html5=w(c.html5,f);c.html5.usingFlash= +Va();u=c.html5.usingFlash;return!0};sa={};P=function(){};aa=function(b){8===m&&(1m)&&(c.flashVersion=m=9);c.version=c.versionNumber+(c.html5Only?" (HTML5-only mode)":9===m?" (AS3/Flash 9)": +" (AS2/Flash 8)");8b&&(e=!0));setTimeout(function(){b=c.getMoviePercent();if(e)return Q=!1,g.setTimeout(F,1),!1;!p&&ab&&(null===b?c.useFlashBlock||0===c.flashLoadTimeout?c.useFlashBlock&&za():!c.useFlashBlock&&S?qa():D({type:"ontimeout",ignoreInit:!0,error:{type:"INIT_FLASHBLOCK"}}):0!==c.flashLoadTimeout&&(!c.useFlashBlock&&S?qa():xa(!0)))},c.flashLoadTimeout)};Y=function(){if(Ga||!ja)return t.remove(g,"focus", +Y),!0;Ga=ab=!0;Q=!1;F();t.remove(g,"focus",Y);return!0};M=function(b){if(p)return!1;if(c.html5Only)return p=!0,E(),!0;var e=!0,d;if(!c.useFlashBlock||!c.flashLoadTimeout||c.getMoviePercent())p=!0;d={type:!v&&u?"NO_FLASH":"INIT_TIMEOUT"};if(y||b)c.useFlashBlock&&c.oMC&&(c.oMC.className=I()+" "+(null===c.getMoviePercent()?"swf_timedout":"swf_error")),D({type:"ontimeout",error:d,ignoreInit:!0}),H(d),e=!1;y||(c.waitForWindowLoad&&!na?t.add(g,"load",E):E());return e};Ma=function(){var b,e=c.setupOptions; +for(b in e)e.hasOwnProperty(b)&&(c[b]===k?c[b]=e[b]:c[b]!==e[b]&&(c.setupOptions[b]=c[b]))};ma=function(){if(p)return!1;if(c.html5Only)return p||(t.remove(g,"load",c.beginDelayedInit),c.enabled=!0,M()),!0;Z();try{l._externalInterfaceTest(!1),Oa(!0,c.flashPollingInterval||(c.useHighPerformance?10:50)),c.debugMode||l._disableDebug(),c.enabled=!0,c.html5Only||t.add(g,"unload",la)}catch(b){return H({type:"JS_TO_FLASH_EXCEPTION",fatal:!0}),xa(!0),M(),!1}M();t.remove(g,"load",c.beginDelayedInit);return!0}; +G=function(){if(N)return!1;N=!0;Ma();wa();!v&&c.hasHTML5&&c.setup({useHTML5Audio:!0,preferFlash:!1});Wa();!v&&u&&(Ua.push(sa.needFlash),c.setup({flashLoadTimeout:1}));n.removeEventListener&&n.removeEventListener("DOMContentLoaded",G,!1);Z();return!0};Ba=function(){"complete"===n.readyState&&(G(),n.detachEvent("onreadystatechange",Ba));return!0};ua=function(){na=!0;t.remove(g,"load",ua)};ta=function(){if(Fa&&(c.setupOptions.useHTML5Audio=!0,c.setupOptions.preferFlash=!1,ha||Za&&!s.match(/android\s2\.3/i)))ha&& +(c.ignoreFlash=!0),A=!0};ta();Da();t.add(g,"focus",Y);t.add(g,"load",F);t.add(g,"load",ua);n.addEventListener?n.addEventListener("DOMContentLoaded",G,!1):n.attachEvent?n.attachEvent("onreadystatechange",Ba):H({type:"NO_DOM2_EVENTS",fatal:!0})}var ka=null;if(void 0===g.SM2_DEFER||!SM2_DEFER)ka=new U;g.SoundManager=U;g.soundManager=ka})(window); \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/script/soundmanager2-nodebug.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/script/soundmanager2-nodebug.js new file mode 100755 index 00000000..12b30e2b --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/script/soundmanager2-nodebug.js @@ -0,0 +1,2660 @@ +/** @license + * + * SoundManager 2: JavaScript Sound for the Web + * ---------------------------------------------- + * http://schillmania.com/projects/soundmanager2/ + * + * Copyright (c) 2007, Scott Schiller. All rights reserved. + * Code provided under the BSD License: + * http://schillmania.com/projects/soundmanager2/license.txt + * + * V2.97a.20131201 + */ + +/*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio, opera */ +/*jslint regexp: true, sloppy: true, white: true, nomen: true, plusplus: true, todo: true */ + +(function(window, _undefined) { +"use strict"; +var soundManager = null; +function SoundManager(smURL, smID) { + this.setupOptions = { + 'url': (smURL || null), + 'flashVersion': 8, + 'debugMode': true, + 'debugFlash': false, + 'useConsole': true, + 'consoleOnly': true, + 'waitForWindowLoad': false, + 'bgColor': '#ffffff', + 'useHighPerformance': false, + 'flashPollingInterval': null, + 'html5PollingInterval': null, + 'flashLoadTimeout': 1000, + 'wmode': null, + 'allowScriptAccess': 'always', + 'useFlashBlock': false, + 'useHTML5Audio': true, + 'html5Test': /^(probably|maybe)$/i, + 'preferFlash': false, + 'noSWFCache': false, + 'idPrefix': 'sound' + }; + this.defaultOptions = { + 'autoLoad': false, + 'autoPlay': false, + 'from': null, + 'loops': 1, + 'onid3': null, + 'onload': null, + 'whileloading': null, + 'onplay': null, + 'onpause': null, + 'onresume': null, + 'whileplaying': null, + 'onposition': null, + 'onstop': null, + 'onfailure': null, + 'onfinish': null, + 'multiShot': true, + 'multiShotEvents': false, + 'position': null, + 'pan': 0, + 'stream': true, + 'to': null, + 'type': null, + 'usePolicyFile': false, + 'volume': 100 + }; + this.flash9Options = { + 'isMovieStar': null, + 'usePeakData': false, + 'useWaveformData': false, + 'useEQData': false, + 'onbufferchange': null, + 'ondataerror': null + }; + this.movieStarOptions = { + 'bufferTime': 3, + 'serverURL': null, + 'onconnect': null, + 'duration': null + }; + this.audioFormats = { + 'mp3': { + 'type': ['audio/mpeg; codecs="mp3"', 'audio/mpeg', 'audio/mp3', 'audio/MPA', 'audio/mpa-robust'], + 'required': true + }, + 'mp4': { + 'related': ['aac','m4a','m4b'], + 'type': ['audio/mp4; codecs="mp4a.40.2"', 'audio/aac', 'audio/x-m4a', 'audio/MP4A-LATM', 'audio/mpeg4-generic'], + 'required': false + }, + 'ogg': { + 'type': ['audio/ogg; codecs=vorbis'], + 'required': false + }, + 'opus': { + 'type': ['audio/ogg; codecs=opus', 'audio/opus'], + 'required': false + }, + 'wav': { + 'type': ['audio/wav; codecs="1"', 'audio/wav', 'audio/wave', 'audio/x-wav'], + 'required': false + } + }; + this.movieID = 'sm2-container'; + this.id = (smID || 'sm2movie'); + this.debugID = 'soundmanager-debug'; + this.debugURLParam = /([#?&])debug=1/i; + this.versionNumber = 'V2.97a.20131201'; + this.version = null; + this.movieURL = null; + this.altURL = null; + this.swfLoaded = false; + this.enabled = false; + this.oMC = null; + this.sounds = {}; + this.soundIDs = []; + this.muted = false; + this.didFlashBlock = false; + this.filePattern = null; + this.filePatterns = { + 'flash8': /\.mp3(\?.*)?$/i, + 'flash9': /\.mp3(\?.*)?$/i + }; + this.features = { + 'buffering': false, + 'peakData': false, + 'waveformData': false, + 'eqData': false, + 'movieStar': false + }; + this.sandbox = { + }; + this.html5 = { + 'usingFlash': null + }; + this.flash = {}; + this.html5Only = false; + this.ignoreFlash = false; + var SMSound, + 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, preInit, domContentLoaded, winOnLoad, didDCLoaded, getDocument, createMovie, catchError, setPolling, initDebug, debugLevels = ['log', 'info', 'warn', 'error'], defaultFlashVersion = 8, disableObject, failSafely, normalizeMovieURL, oRemoved = null, oRemovedHTML = null, str, flashBlockHandler, getSWFCSS, swfCSS, toggleDebug, loopFix, policyFix, complain, idCheck, waitingForEI = false, initPending = false, startTimer, stopTimer, timerExecute, h5TimerCount = 0, h5IntervalTimer = null, parseURL, messages = [], + 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, + is_iDevice = ua.match(/(ipad|iphone|ipod)/i), isAndroid = ua.match(/android/i), isIE = ua.match(/msie/i), isWebkit = ua.match(/webkit/i), isSafari = (ua.match(/safari/i) && !ua.match(/chrome/i)), isOpera = (ua.match(/opera/i)), + mobileHTML5 = (ua.match(/(mobile|pre\/|xoom)/i) || is_iDevice || isAndroid), + isBadSafari = (!wl.match(/usehtml5audio/i) && !wl.match(/sm2\-ignorebadua/i) && isSafari && !ua.match(/silk/i) && ua.match(/OS X 10_6_([3-7])/i)), + hasConsole = (window.console !== _undefined && console.log !== _undefined), isFocused = (doc.hasFocus !== _undefined?doc.hasFocus():null), tryInitOnFocus = (isSafari && (doc.hasFocus === _undefined || !doc.hasFocus())), okToDisable = !tryInitOnFocus, flashMIME = /(mp3|mp4|mpa|m4a|m4b)/i, msecScale = 1000, + emptyURL = 'about:blank', + emptyWAV = 'data:audio/wave;base64,/UklGRiYAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQIAAAD//w==', + overHTTP = (doc.location?doc.location.protocol.match(/http/i):null), + http = (!overHTTP ? 'http:/'+'/' : ''), + netStreamMimeTypes = /^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i, + netStreamTypes = ['mpeg4', 'aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', 'm4b', 'mp4v', '3gp', '3g2'], + netStreamPattern = new RegExp('\\.(' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i'); + this.mimePattern = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i; + this.useAltURL = !overHTTP; + swfCSS = { + 'swfBox': 'sm2-object-box', + 'swfDefault': 'movieContainer', + 'swfError': 'swf_error', + 'swfTimedout': 'swf_timedout', + 'swfLoaded': 'swf_loaded', + 'swfUnblocked': 'swf_unblocked', + 'sm2Debug': 'sm2_debug', + 'highPerf': 'high_performance', + 'flashDebug': 'flash_debug' + }; + this.hasHTML5 = (function() { + try { + return (Audio !== _undefined && (isOpera && opera !== _undefined && opera.version() < 10 ? new Audio(null) : new Audio()).canPlayType !== _undefined); + } catch(e) { + return false; + } + }()); + this.setup = function(options) { + var noURL = (!sm2.url); + if (options !== _undefined && didInit && needsFlash && sm2.ok() && (options.flashVersion !== _undefined || options.url !== _undefined || options.html5Test !== _undefined)) { + } + assign(options); + if (options) { + if (noURL && didDCLoaded && options.url !== _undefined) { + sm2.beginDelayedInit(); + } + if (!didDCLoaded && options.url !== _undefined && doc.readyState === 'complete') { + setTimeout(domContentLoaded, 1); + } + } + return sm2; + }; + this.ok = function() { + return (needsFlash ? (didInit && !disabled) : (sm2.useHTML5Audio && sm2.hasHTML5)); + }; + this.supported = this.ok; + this.getMovie = function(smID) { + return id(smID) || doc[smID] || window[smID]; + }; + this.createSound = function(oOptions, _url) { + var cs, cs_string, options, oSound = null; + if (!didInit || !sm2.ok()) { + return false; + } + if (_url !== _undefined) { + oOptions = { + 'id': oOptions, + 'url': _url + }; + } + options = mixin(oOptions); + options.url = parseURL(options.url); + if (options.id === undefined) { + options.id = sm2.setupOptions.idPrefix + (idCounter++); + } + if (idCheck(options.id, true)) { + return sm2.sounds[options.id]; + } + function make() { + options = loopFix(options); + sm2.sounds[options.id] = new SMSound(options); + sm2.soundIDs.push(options.id); + return sm2.sounds[options.id]; + } + if (html5OK(options)) { + oSound = make(); + oSound._setup_html5(options); + } else { + if (sm2.html5Only) { + return make(); + } + if (sm2.html5.usingFlash && options.url && options.url.match(/data\:/i)) { + return make(); + } + if (fV > 8) { + if (options.isMovieStar === null) { + options.isMovieStar = !!(options.serverURL || (options.type ? options.type.match(netStreamMimeTypes) : false) || (options.url && options.url.match(netStreamPattern))); + } + } + options = policyFix(options, cs); + oSound = make(); + if (fV === 8) { + flash._createSound(options.id, options.loops||1, options.usePolicyFile); + } else { + 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); + if (!options.serverURL) { + oSound.connected = true; + if (options.onconnect) { + options.onconnect.apply(oSound); + } + } + } + if (!options.serverURL && (options.autoLoad || options.autoPlay)) { + oSound.load(options); + } + } + if (!options.serverURL && options.autoPlay) { + oSound.play(); + } + return oSound; + }; + this.destroySound = function(sID, _bFromSound) { + if (!idCheck(sID)) { + return false; + } + var oS = sm2.sounds[sID], i; + oS._iO = {}; + oS.stop(); + oS.unload(); + for (i = 0; i < sm2.soundIDs.length; i++) { + if (sm2.soundIDs[i] === sID) { + sm2.soundIDs.splice(i, 1); + break; + } + } + if (!_bFromSound) { + oS.destruct(true); + } + oS = null; + delete sm2.sounds[sID]; + return true; + }; + this.load = function(sID, oOptions) { + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].load(oOptions); + }; + this.unload = function(sID) { + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].unload(); + }; + this.onPosition = function(sID, nPosition, oMethod, oScope) { + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].onposition(nPosition, oMethod, oScope); + }; + this.onposition = this.onPosition; + this.clearOnPosition = function(sID, nPosition, oMethod) { + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].clearOnPosition(nPosition, oMethod); + }; + this.play = function(sID, oOptions) { + var result = null, + overloaded = (oOptions && !(oOptions instanceof Object)); + if (!didInit || !sm2.ok()) { + return false; + } + if (!idCheck(sID, overloaded)) { + if (!overloaded) { + return false; + } + if (overloaded) { + oOptions = { + url: oOptions + }; + } + if (oOptions && oOptions.url) { + oOptions.id = sID; + result = sm2.createSound(oOptions).play(); + } + } else if (overloaded) { + oOptions = { + url: oOptions + }; + } + if (result === null) { + result = sm2.sounds[sID].play(oOptions); + } + return result; + }; + this.start = this.play; + this.setPosition = function(sID, nMsecOffset) { + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].setPosition(nMsecOffset); + }; + this.stop = function(sID) { + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].stop(); + }; + this.stopAll = function() { + var oSound; + for (oSound in sm2.sounds) { + if (sm2.sounds.hasOwnProperty(oSound)) { + sm2.sounds[oSound].stop(); + } + } + }; + this.pause = function(sID) { + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].pause(); + }; + this.pauseAll = function() { + var i; + for (i = sm2.soundIDs.length-1; i >= 0; i--) { + sm2.sounds[sm2.soundIDs[i]].pause(); + } + }; + this.resume = function(sID) { + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].resume(); + }; + this.resumeAll = function() { + var i; + for (i = sm2.soundIDs.length-1; i >= 0; i--) { + sm2.sounds[sm2.soundIDs[i]].resume(); + } + }; + this.togglePause = function(sID) { + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].togglePause(); + }; + this.setPan = function(sID, nPan) { + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].setPan(nPan); + }; + this.setVolume = function(sID, nVol) { + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].setVolume(nVol); + }; + this.mute = function(sID) { + var i = 0; + if (sID instanceof String) { + sID = null; + } + if (!sID) { + for (i = sm2.soundIDs.length-1; i >= 0; i--) { + sm2.sounds[sm2.soundIDs[i]].mute(); + } + sm2.muted = true; + } else { + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].mute(); + } + return true; + }; + this.muteAll = function() { + sm2.mute(); + }; + this.unmute = function(sID) { + var i; + if (sID instanceof String) { + sID = null; + } + if (!sID) { + for (i = sm2.soundIDs.length-1; i >= 0; i--) { + sm2.sounds[sm2.soundIDs[i]].unmute(); + } + sm2.muted = false; + } else { + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].unmute(); + } + return true; + }; + this.unmuteAll = function() { + sm2.unmute(); + }; + this.toggleMute = function(sID) { + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].toggleMute(); + }; + this.getMemoryUse = function() { + var ram = 0; + if (flash && fV !== 8) { + ram = parseInt(flash._getMemoryUse(), 10); + } + return ram; + }; + this.disable = function(bNoDisable) { + var i; + if (bNoDisable === _undefined) { + bNoDisable = false; + } + if (disabled) { + return false; + } + disabled = true; + for (i = sm2.soundIDs.length-1; i >= 0; i--) { + disableObject(sm2.sounds[sm2.soundIDs[i]]); + } + initComplete(bNoDisable); + event.remove(window, 'load', initUserOnload); + return true; + }; + this.canPlayMIME = function(sMIME) { + var result; + if (sm2.hasHTML5) { + result = html5CanPlay({type:sMIME}); + } + if (!result && needsFlash) { + result = (sMIME && sm2.ok() ? !!((fV > 8 ? sMIME.match(netStreamMimeTypes) : null) || sMIME.match(sm2.mimePattern)) : null); + } + return result; + }; + this.canPlayURL = function(sURL) { + var result; + if (sm2.hasHTML5) { + result = html5CanPlay({url: sURL}); + } + if (!result && needsFlash) { + result = (sURL && sm2.ok() ? !!(sURL.match(sm2.filePattern)) : null); + } + return result; + }; + this.canPlayLink = function(oLink) { + if (oLink.type !== _undefined && oLink.type) { + if (sm2.canPlayMIME(oLink.type)) { + return true; + } + } + return sm2.canPlayURL(oLink.href); + }; + this.getSoundById = function(sID, _suppressDebug) { + if (!sID) { + return null; + } + var result = sm2.sounds[sID]; + return result; + }; + this.onready = function(oMethod, oScope) { + var sType = 'onready', + result = false; + if (typeof oMethod === 'function') { + if (!oScope) { + oScope = window; + } + addOnEvent(sType, oMethod, oScope); + processOnEvents(); + result = true; + } else { + throw str('needFunction', sType); + } + return result; + }; + this.ontimeout = function(oMethod, oScope) { + var sType = 'ontimeout', + result = false; + if (typeof oMethod === 'function') { + if (!oScope) { + oScope = window; + } + addOnEvent(sType, oMethod, oScope); + processOnEvents({type:sType}); + result = true; + } else { + throw str('needFunction', sType); + } + return result; + }; + this._writeDebug = function(sText, sTypeOrObject) { + return true; + }; + this._wD = this._writeDebug; + this._debug = function() { + }; + this.reboot = function(resetEvents, excludeInit) { + var i, j, k; + for (i = sm2.soundIDs.length-1; i >= 0; i--) { + sm2.sounds[sm2.soundIDs[i]].destruct(); + } + if (flash) { + try { + if (isIE) { + oRemovedHTML = flash.innerHTML; + } + oRemoved = flash.parentNode.removeChild(flash); + } catch(e) { + } + } + oRemovedHTML = oRemoved = needsFlash = flash = null; + sm2.enabled = didDCLoaded = didInit = waitingForEI = initPending = didAppend = appendSuccess = disabled = useGlobalHTML5Audio = sm2.swfLoaded = false; + sm2.soundIDs = []; + sm2.sounds = {}; + idCounter = 0; + if (!resetEvents) { + for (i in on_queue) { + if (on_queue.hasOwnProperty(i)) { + for (j = 0, k = on_queue[i].length; j < k; j++) { + on_queue[i][j].fired = false; + } + } + } + } else { + on_queue = []; + } + sm2.html5 = { + 'usingFlash': null + }; + sm2.flash = {}; + sm2.html5Only = false; + sm2.ignoreFlash = false; + window.setTimeout(function() { + preInit(); + if (!excludeInit) { + sm2.beginDelayedInit(); + } + }, 20); + return sm2; + }; + this.reset = function() { + return sm2.reboot(true, true); + }; + this.getMoviePercent = function() { + return (flash && 'PercentLoaded' in flash ? flash.PercentLoaded() : null); + }; + this.beginDelayedInit = function() { + windowLoaded = true; + domContentLoaded(); + setTimeout(function() { + if (initPending) { + return false; + } + createMovie(); + initMovie(); + initPending = true; + return true; + }, 20); + delayWaitForEI(); + }; + this.destruct = function() { + sm2.disable(true); + }; + SMSound = function(oOptions) { + 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; + lastHTML5State = { + duration: null, + time: null + }; + this.id = oOptions.id; + this.sID = this.id; + this.url = oOptions.url; + this.options = mixin(oOptions); + this.instanceOptions = this.options; + this._iO = this.instanceOptions; + this.pan = this.options.pan; + this.volume = this.options.volume; + this.isHTML5 = false; + this._a = null; + urlOmitted = (this.url ? false : true); + this.id3 = {}; + this._debug = function() { + }; + this.load = function(oOptions) { + var oSound = null, instanceOptions; + if (oOptions !== _undefined) { + s._iO = mixin(oOptions, s.options); + } else { + oOptions = s.options; + s._iO = oOptions; + if (lastURL && lastURL !== s.url) { + s._iO.url = s.url; + s.url = null; + } + } + if (!s._iO.url) { + s._iO.url = s.url; + } + s._iO.url = parseURL(s._iO.url); + s.instanceOptions = s._iO; + instanceOptions = s._iO; + if (!instanceOptions.url && !s.url) { + return s; + } + if (instanceOptions.url === s.url && s.readyState !== 0 && s.readyState !== 2) { + if (s.readyState === 3 && instanceOptions.onload) { + wrapCallback(s, function() { + instanceOptions.onload.apply(s, [(!!s.duration)]); + }); + } + return s; + } + s.loaded = false; + s.readyState = 1; + s.playState = 0; + s.id3 = {}; + if (html5OK(instanceOptions)) { + oSound = s._setup_html5(instanceOptions); + if (!oSound._called_load) { + s._html5_canplay = false; + if (s.url !== instanceOptions.url) { + s._a.src = instanceOptions.url; + s.setPosition(0); + } + s._a.autobuffer = 'auto'; + s._a.preload = 'auto'; + s._a._called_load = true; + } else { + } + } else { + if (sm2.html5Only) { + return s; + } + if (s._iO.url && s._iO.url.match(/data\:/i)) { + return s; + } + try { + s.isHTML5 = false; + s._iO = policyFix(loopFix(instanceOptions)); + instanceOptions = s._iO; + if (fV === 8) { + flash._load(s.id, instanceOptions.url, instanceOptions.stream, instanceOptions.autoPlay, instanceOptions.usePolicyFile); + } else { + flash._load(s.id, instanceOptions.url, !!(instanceOptions.stream), !!(instanceOptions.autoPlay), instanceOptions.loops||1, !!(instanceOptions.autoLoad), instanceOptions.usePolicyFile); + } + } catch(e) { + catchError({type:'SMSOUND_LOAD_JS_EXCEPTION', fatal:true}); + } + } + s.url = instanceOptions.url; + return s; + }; + this.unload = function() { + if (s.readyState !== 0) { + if (!s.isHTML5) { + if (fV === 8) { + flash._unload(s.id, emptyURL); + } else { + flash._unload(s.id); + } + } else { + stop_html5_timer(); + if (s._a) { + s._a.pause(); + lastURL = html5Unload(s._a); + } + } + resetProperties(); + } + return s; + }; + this.destruct = function(_bFromSM) { + if (!s.isHTML5) { + s._iO.onfailure = null; + flash._destroySound(s.id); + } else { + stop_html5_timer(); + if (s._a) { + s._a.pause(); + html5Unload(s._a); + if (!useGlobalHTML5Audio) { + remove_html5_events(); + } + s._a._s = null; + s._a = null; + } + } + if (!_bFromSM) { + sm2.destroySound(s.id, true); + } + }; + this.play = function(oOptions, _updatePlayState) { + var fN, allowMulti, a, onready, + audioClone, onended, oncanplay, + startOK = true, + exit = null; + _updatePlayState = (_updatePlayState === _undefined ? true : _updatePlayState); + if (!oOptions) { + oOptions = {}; + } + if (s.url) { + s._iO.url = s.url; + } + s._iO = mixin(s._iO, s.options); + s._iO = mixin(oOptions, s._iO); + s._iO.url = parseURL(s._iO.url); + s.instanceOptions = s._iO; + if (!s.isHTML5 && s._iO.serverURL && !s.connected) { + if (!s.getAutoPlay()) { + s.setAutoPlay(true); + } + return s; + } + if (html5OK(s._iO)) { + s._setup_html5(s._iO); + start_html5_timer(); + } + if (s.playState === 1 && !s.paused) { + allowMulti = s._iO.multiShot; + if (!allowMulti) { + if (s.isHTML5) { + s.setPosition(s._iO.position); + } + exit = s; + } else { + } + } + if (exit !== null) { + return exit; + } + if (oOptions.url && oOptions.url !== s.url) { + if (!s.readyState && !s.isHTML5 && fV === 8 && urlOmitted) { + urlOmitted = false; + } else { + s.load(s._iO); + } + } + if (!s.loaded) { + if (s.readyState === 0) { + if (!s.isHTML5 && !sm2.html5Only) { + s._iO.autoPlay = true; + s.load(s._iO); + } else if (s.isHTML5) { + s.load(s._iO); + } else { + exit = s; + } + s.instanceOptions = s._iO; + } else if (s.readyState === 2) { + exit = s; + } else { + } + } else { + } + if (exit !== null) { + return exit; + } + if (!s.isHTML5 && fV === 9 && s.position > 0 && s.position === s.duration) { + oOptions.position = 0; + } + if (s.paused && s.position >= 0 && (!s._iO.serverURL || s.position > 0)) { + s.resume(); + } else { + s._iO = mixin(oOptions, s._iO); + if (s._iO.from !== null && s._iO.to !== null && s.instanceCount === 0 && s.playState === 0 && !s._iO.serverURL) { + onready = function() { + s._iO = mixin(oOptions, s._iO); + s.play(s._iO); + }; + if (s.isHTML5 && !s._html5_canplay) { + s.load({ + _oncanplay: onready + }); + exit = false; + } else if (!s.isHTML5 && !s.loaded && (!s.readyState || s.readyState !== 2)) { + s.load({ + onload: onready + }); + exit = false; + } + if (exit !== null) { + return exit; + } + s._iO = applyFromTo(); + } + if (!s.instanceCount || s._iO.multiShotEvents || (s.isHTML5 && s._iO.multiShot && !useGlobalHTML5Audio) || (!s.isHTML5 && fV > 8 && !s.getAutoPlay())) { + s.instanceCount++; + } + if (s._iO.onposition && s.playState === 0) { + attachOnPosition(s); + } + s.playState = 1; + s.paused = false; + s.position = (s._iO.position !== _undefined && !isNaN(s._iO.position) ? s._iO.position : 0); + if (!s.isHTML5) { + s._iO = policyFix(loopFix(s._iO)); + } + if (s._iO.onplay && _updatePlayState) { + s._iO.onplay.apply(s); + onplay_called = true; + } + s.setVolume(s._iO.volume, true); + s.setPan(s._iO.pan, true); + if (!s.isHTML5) { + startOK = flash._start(s.id, s._iO.loops || 1, (fV === 9 ? s.position : s.position / msecScale), s._iO.multiShot || false); + if (fV === 9 && !startOK) { + if (s._iO.onplayerror) { + s._iO.onplayerror.apply(s); + } + } + } else { + if (s.instanceCount < 2) { + start_html5_timer(); + a = s._setup_html5(); + s.setPosition(s._iO.position); + a.play(); + } else { + audioClone = new Audio(s._iO.url); + onended = function() { + event.remove(audioClone, 'ended', onended); + s._onfinish(s); + html5Unload(audioClone); + audioClone = null; + }; + oncanplay = function() { + event.remove(audioClone, 'canplay', oncanplay); + try { + audioClone.currentTime = s._iO.position/msecScale; + } catch(err) { + } + audioClone.play(); + }; + event.add(audioClone, 'ended', onended); + if (s._iO.volume !== undefined) { + audioClone.volume = Math.max(0, Math.min(1, s._iO.volume/100)); + } + if (s.muted) { + audioClone.muted = true; + } + if (s._iO.position) { + event.add(audioClone, 'canplay', oncanplay); + } else { + audioClone.play(); + } + } + } + } + return s; + }; + this.start = this.play; + this.stop = function(bAll) { + var instanceOptions = s._iO, + originalPosition; + if (s.playState === 1) { + s._onbufferchange(0); + s._resetOnPosition(0); + s.paused = false; + if (!s.isHTML5) { + s.playState = 0; + } + detachOnPosition(); + if (instanceOptions.to) { + s.clearOnPosition(instanceOptions.to); + } + if (!s.isHTML5) { + flash._stop(s.id, bAll); + if (instanceOptions.serverURL) { + s.unload(); + } + } else { + if (s._a) { + originalPosition = s.position; + s.setPosition(0); + s.position = originalPosition; + s._a.pause(); + s.playState = 0; + s._onTimer(); + stop_html5_timer(); + } + } + s.instanceCount = 0; + s._iO = {}; + if (instanceOptions.onstop) { + instanceOptions.onstop.apply(s); + } + } + return s; + }; + this.setAutoPlay = function(autoPlay) { + s._iO.autoPlay = autoPlay; + if (!s.isHTML5) { + flash._setAutoPlay(s.id, autoPlay); + if (autoPlay) { + if (!s.instanceCount && s.readyState === 1) { + s.instanceCount++; + } + } + } + }; + this.getAutoPlay = function() { + return s._iO.autoPlay; + }; + this.setPosition = function(nMsecOffset) { + if (nMsecOffset === _undefined) { + nMsecOffset = 0; + } + var position, position1K, + offset = (s.isHTML5 ? Math.max(nMsecOffset, 0) : Math.min(s.duration || s._iO.duration, Math.max(nMsecOffset, 0))); + s.position = offset; + position1K = s.position/msecScale; + s._resetOnPosition(s.position); + s._iO.position = offset; + if (!s.isHTML5) { + position = (fV === 9 ? s.position : position1K); + if (s.readyState && s.readyState !== 2) { + flash._setPosition(s.id, position, (s.paused || !s.playState), s._iO.multiShot); + } + } else if (s._a) { + if (s._html5_canplay) { + if (s._a.currentTime !== position1K) { + try { + s._a.currentTime = position1K; + if (s.playState === 0 || s.paused) { + s._a.pause(); + } + } catch(e) { + } + } + } else if (position1K) { + return s; + } + if (s.paused) { + s._onTimer(true); + } + } + return s; + }; + this.pause = function(_bCallFlash) { + if (s.paused || (s.playState === 0 && s.readyState !== 1)) { + return s; + } + s.paused = true; + if (!s.isHTML5) { + if (_bCallFlash || _bCallFlash === _undefined) { + flash._pause(s.id, s._iO.multiShot); + } + } else { + s._setup_html5().pause(); + stop_html5_timer(); + } + if (s._iO.onpause) { + s._iO.onpause.apply(s); + } + return s; + }; + this.resume = function() { + var instanceOptions = s._iO; + if (!s.paused) { + return s; + } + s.paused = false; + s.playState = 1; + if (!s.isHTML5) { + if (instanceOptions.isMovieStar && !instanceOptions.serverURL) { + s.setPosition(s.position); + } + flash._pause(s.id, instanceOptions.multiShot); + } else { + s._setup_html5().play(); + start_html5_timer(); + } + if (!onplay_called && instanceOptions.onplay) { + instanceOptions.onplay.apply(s); + onplay_called = true; + } else if (instanceOptions.onresume) { + instanceOptions.onresume.apply(s); + } + return s; + }; + this.togglePause = function() { + if (s.playState === 0) { + s.play({ + position: (fV === 9 && !s.isHTML5 ? s.position : s.position / msecScale) + }); + return s; + } + if (s.paused) { + s.resume(); + } else { + s.pause(); + } + return s; + }; + this.setPan = function(nPan, bInstanceOnly) { + if (nPan === _undefined) { + nPan = 0; + } + if (bInstanceOnly === _undefined) { + bInstanceOnly = false; + } + if (!s.isHTML5) { + flash._setPan(s.id, nPan); + } + s._iO.pan = nPan; + if (!bInstanceOnly) { + s.pan = nPan; + s.options.pan = nPan; + } + return s; + }; + this.setVolume = function(nVol, _bInstanceOnly) { + if (nVol === _undefined) { + nVol = 100; + } + if (_bInstanceOnly === _undefined) { + _bInstanceOnly = false; + } + if (!s.isHTML5) { + flash._setVolume(s.id, (sm2.muted && !s.muted) || s.muted?0:nVol); + } else if (s._a) { + if (sm2.muted && !s.muted) { + s.muted = true; + s._a.muted = true; + } + s._a.volume = Math.max(0, Math.min(1, nVol/100)); + } + s._iO.volume = nVol; + if (!_bInstanceOnly) { + s.volume = nVol; + s.options.volume = nVol; + } + return s; + }; + this.mute = function() { + s.muted = true; + if (!s.isHTML5) { + flash._setVolume(s.id, 0); + } else if (s._a) { + s._a.muted = true; + } + return s; + }; + this.unmute = function() { + s.muted = false; + var hasIO = (s._iO.volume !== _undefined); + if (!s.isHTML5) { + flash._setVolume(s.id, hasIO?s._iO.volume:s.options.volume); + } else if (s._a) { + s._a.muted = false; + } + return s; + }; + this.toggleMute = function() { + return (s.muted?s.unmute():s.mute()); + }; + this.onPosition = function(nPosition, oMethod, oScope) { + onPositionItems.push({ + position: parseInt(nPosition, 10), + method: oMethod, + scope: (oScope !== _undefined ? oScope : s), + fired: false + }); + return s; + }; + this.onposition = this.onPosition; + this.clearOnPosition = function(nPosition, oMethod) { + var i; + nPosition = parseInt(nPosition, 10); + if (isNaN(nPosition)) { + return false; + } + for (i=0; i < onPositionItems.length; i++) { + if (nPosition === onPositionItems[i].position) { + if (!oMethod || (oMethod === onPositionItems[i].method)) { + if (onPositionItems[i].fired) { + onPositionFired--; + } + onPositionItems.splice(i, 1); + } + } + } + }; + this._processOnPosition = function() { + var i, item, j = onPositionItems.length; + if (!j || !s.playState || onPositionFired >= j) { + return false; + } + for (i=j-1; i >= 0; i--) { + item = onPositionItems[i]; + if (!item.fired && s.position >= item.position) { + item.fired = true; + onPositionFired++; + item.method.apply(item.scope, [item.position]); + j = onPositionItems.length; + } + } + return true; + }; + this._resetOnPosition = function(nPosition) { + var i, item, j = onPositionItems.length; + if (!j) { + return false; + } + for (i=j-1; i >= 0; i--) { + item = onPositionItems[i]; + if (item.fired && nPosition <= item.position) { + item.fired = false; + onPositionFired--; + } + } + return true; + }; + applyFromTo = function() { + var instanceOptions = s._iO, + f = instanceOptions.from, + t = instanceOptions.to, + start, end; + end = function() { + s.clearOnPosition(t, end); + s.stop(); + }; + start = function() { + if (t !== null && !isNaN(t)) { + s.onPosition(t, end); + } + }; + if (f !== null && !isNaN(f)) { + instanceOptions.position = f; + instanceOptions.multiShot = false; + start(); + } + return instanceOptions; + }; + attachOnPosition = function() { + var item, + op = s._iO.onposition; + if (op) { + for (item in op) { + if (op.hasOwnProperty(item)) { + s.onPosition(parseInt(item, 10), op[item]); + } + } + } + }; + detachOnPosition = function() { + var item, + op = s._iO.onposition; + if (op) { + for (item in op) { + if (op.hasOwnProperty(item)) { + s.clearOnPosition(parseInt(item, 10)); + } + } + } + }; + start_html5_timer = function() { + if (s.isHTML5) { + startTimer(s); + } + }; + stop_html5_timer = function() { + if (s.isHTML5) { + stopTimer(s); + } + }; + resetProperties = function(retainPosition) { + if (!retainPosition) { + onPositionItems = []; + onPositionFired = 0; + } + onplay_called = false; + s._hasTimer = null; + s._a = null; + s._html5_canplay = false; + s.bytesLoaded = null; + s.bytesTotal = null; + s.duration = (s._iO && s._iO.duration ? s._iO.duration : null); + s.durationEstimate = null; + s.buffered = []; + s.eqData = []; + s.eqData.left = []; + s.eqData.right = []; + s.failures = 0; + s.isBuffering = false; + s.instanceOptions = {}; + s.instanceCount = 0; + s.loaded = false; + s.metadata = {}; + s.readyState = 0; + s.muted = false; + s.paused = false; + s.peakData = { + left: 0, + right: 0 + }; + s.waveformData = { + left: [], + right: [] + }; + s.playState = 0; + s.position = null; + s.id3 = {}; + }; + resetProperties(); + this._onTimer = function(bForce) { + var duration, isNew = false, time, x = {}; + if (s._hasTimer || bForce) { + if (s._a && (bForce || ((s.playState > 0 || s.readyState === 1) && !s.paused))) { + duration = s._get_html5_duration(); + if (duration !== lastHTML5State.duration) { + lastHTML5State.duration = duration; + s.duration = duration; + isNew = true; + } + s.durationEstimate = s.duration; + time = (s._a.currentTime * msecScale || 0); + if (time !== lastHTML5State.time) { + lastHTML5State.time = time; + isNew = true; + } + if (isNew || bForce) { + s._whileplaying(time,x,x,x,x); + } + } + return isNew; + } + }; + this._get_html5_duration = function() { + var instanceOptions = s._iO, + d = (s._a && s._a.duration ? s._a.duration*msecScale : (instanceOptions && instanceOptions.duration ? instanceOptions.duration : null)), + result = (d && !isNaN(d) && d !== Infinity ? d : null); + return result; + }; + this._apply_loop = function(a, nLoops) { + a.loop = (nLoops > 1 ? 'loop' : ''); + }; + this._setup_html5 = function(oOptions) { + var instanceOptions = mixin(s._iO, oOptions), + a = useGlobalHTML5Audio ? globalHTML5Audio : s._a, + dURL = decodeURI(instanceOptions.url), + sameURL; + if (useGlobalHTML5Audio) { + if (dURL === decodeURI(lastGlobalHTML5URL)) { + sameURL = true; + } + } else if (dURL === decodeURI(lastURL)) { + sameURL = true; + } + if (a) { + if (a._s) { + if (useGlobalHTML5Audio) { + if (a._s && a._s.playState && !sameURL) { + a._s.stop(); + } + } else if (!useGlobalHTML5Audio && dURL === decodeURI(lastURL)) { + s._apply_loop(a, instanceOptions.loops); + return a; + } + } + if (!sameURL) { + if (lastURL) { + resetProperties(false); + } + a.src = instanceOptions.url; + s.url = instanceOptions.url; + lastURL = instanceOptions.url; + lastGlobalHTML5URL = instanceOptions.url; + a._called_load = false; + } + } else { + if (instanceOptions.autoLoad || instanceOptions.autoPlay) { + s._a = new Audio(instanceOptions.url); + s._a.load(); + } else { + s._a = (isOpera && opera.version() < 10 ? new Audio(null) : new Audio()); + } + a = s._a; + a._called_load = false; + if (useGlobalHTML5Audio) { + globalHTML5Audio = a; + } + } + s.isHTML5 = true; + s._a = a; + a._s = s; + add_html5_events(); + s._apply_loop(a, instanceOptions.loops); + if (instanceOptions.autoLoad || instanceOptions.autoPlay) { + s.load(); + } else { + a.autobuffer = false; + a.preload = 'auto'; + } + return a; + }; + add_html5_events = function() { + if (s._a._added_events) { + return false; + } + var f; + function add(oEvt, oFn, bCapture) { + return s._a ? s._a.addEventListener(oEvt, oFn, bCapture||false) : null; + } + s._a._added_events = true; + for (f in html5_events) { + if (html5_events.hasOwnProperty(f)) { + add(f, html5_events[f]); + } + } + return true; + }; + remove_html5_events = function() { + var f; + function remove(oEvt, oFn, bCapture) { + return (s._a ? s._a.removeEventListener(oEvt, oFn, bCapture||false) : null); + } + s._a._added_events = false; + for (f in html5_events) { + if (html5_events.hasOwnProperty(f)) { + remove(f, html5_events[f]); + } + } + }; + this._onload = function(nSuccess) { + var fN, + loadOK = !!nSuccess || (!s.isHTML5 && fV === 8 && s.duration); + s.loaded = loadOK; + s.readyState = loadOK?3:2; + s._onbufferchange(0); + if (s._iO.onload) { + wrapCallback(s, function() { + s._iO.onload.apply(s, [loadOK]); + }); + } + return true; + }; + this._onbufferchange = function(nIsBuffering) { + if (s.playState === 0) { + return false; + } + if ((nIsBuffering && s.isBuffering) || (!nIsBuffering && !s.isBuffering)) { + return false; + } + s.isBuffering = (nIsBuffering === 1); + if (s._iO.onbufferchange) { + s._iO.onbufferchange.apply(s); + } + return true; + }; + this._onsuspend = function() { + if (s._iO.onsuspend) { + s._iO.onsuspend.apply(s); + } + return true; + }; + this._onfailure = function(msg, level, code) { + s.failures++; + if (s._iO.onfailure && s.failures === 1) { + s._iO.onfailure(s, msg, level, code); + } else { + } + }; + this._onfinish = function() { + var io_onfinish = s._iO.onfinish; + s._onbufferchange(0); + s._resetOnPosition(0); + if (s.instanceCount) { + s.instanceCount--; + if (!s.instanceCount) { + detachOnPosition(); + s.playState = 0; + s.paused = false; + s.instanceCount = 0; + s.instanceOptions = {}; + s._iO = {}; + stop_html5_timer(); + if (s.isHTML5) { + s.position = 0; + } + } + if (!s.instanceCount || s._iO.multiShotEvents) { + if (io_onfinish) { + wrapCallback(s, function() { + io_onfinish.apply(s); + }); + } + } + } + }; + this._whileloading = function(nBytesLoaded, nBytesTotal, nDuration, nBufferLength) { + var instanceOptions = s._iO; + s.bytesLoaded = nBytesLoaded; + s.bytesTotal = nBytesTotal; + s.duration = Math.floor(nDuration); + s.bufferLength = nBufferLength; + if (!s.isHTML5 && !instanceOptions.isMovieStar) { + if (instanceOptions.duration) { + s.durationEstimate = (s.duration > instanceOptions.duration) ? s.duration : instanceOptions.duration; + } else { + s.durationEstimate = parseInt((s.bytesTotal / s.bytesLoaded) * s.duration, 10); + } + } else { + s.durationEstimate = s.duration; + } + if (!s.isHTML5) { + s.buffered = [{ + 'start': 0, + 'end': s.duration + }]; + } + if ((s.readyState !== 3 || s.isHTML5) && instanceOptions.whileloading) { + instanceOptions.whileloading.apply(s); + } + }; + this._whileplaying = function(nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) { + var instanceOptions = s._iO, + eqLeft; + if (isNaN(nPosition) || nPosition === null) { + return false; + } + s.position = Math.max(0, nPosition); + s._processOnPosition(); + if (!s.isHTML5 && fV > 8) { + if (instanceOptions.usePeakData && oPeakData !== _undefined && oPeakData) { + s.peakData = { + left: oPeakData.leftPeak, + right: oPeakData.rightPeak + }; + } + if (instanceOptions.useWaveformData && oWaveformDataLeft !== _undefined && oWaveformDataLeft) { + s.waveformData = { + left: oWaveformDataLeft.split(','), + right: oWaveformDataRight.split(',') + }; + } + if (instanceOptions.useEQData) { + if (oEQData !== _undefined && oEQData && oEQData.leftEQ) { + eqLeft = oEQData.leftEQ.split(','); + s.eqData = eqLeft; + s.eqData.left = eqLeft; + if (oEQData.rightEQ !== _undefined && oEQData.rightEQ) { + s.eqData.right = oEQData.rightEQ.split(','); + } + } + } + } + if (s.playState === 1) { + if (!s.isHTML5 && fV === 8 && !s.position && s.isBuffering) { + s._onbufferchange(0); + } + if (instanceOptions.whileplaying) { + instanceOptions.whileplaying.apply(s); + } + } + return true; + }; + this._oncaptiondata = function(oData) { + s.captiondata = oData; + if (s._iO.oncaptiondata) { + s._iO.oncaptiondata.apply(s, [oData]); + } + }; + this._onmetadata = function(oMDProps, oMDData) { + var oData = {}, i, j; + for (i = 0, j = oMDProps.length; i < j; i++) { + oData[oMDProps[i]] = oMDData[i]; + } + s.metadata = oData; + if (s._iO.onmetadata) { + s._iO.onmetadata.apply(s); + } + }; + this._onid3 = function(oID3Props, oID3Data) { + var oData = [], i, j; + for (i = 0, j = oID3Props.length; i < j; i++) { + oData[oID3Props[i]] = oID3Data[i]; + } + s.id3 = mixin(s.id3, oData); + if (s._iO.onid3) { + s._iO.onid3.apply(s); + } + }; + this._onconnect = function(bSuccess) { + bSuccess = (bSuccess === 1); + s.connected = bSuccess; + if (bSuccess) { + s.failures = 0; + if (idCheck(s.id)) { + if (s.getAutoPlay()) { + s.play(_undefined, s.getAutoPlay()); + } else if (s._iO.autoLoad) { + s.load(); + } + } + if (s._iO.onconnect) { + s._iO.onconnect.apply(s, [bSuccess]); + } + } + }; + this._ondataerror = function(sError) { + if (s.playState > 0) { + if (s._iO.ondataerror) { + s._iO.ondataerror.apply(s); + } + } + }; + }; + getDocument = function() { + return (doc.body || doc.getElementsByTagName('div')[0]); + }; + id = function(sID) { + return doc.getElementById(sID); + }; + mixin = function(oMain, oAdd) { + var o1 = (oMain || {}), o2, o; + o2 = (oAdd === _undefined ? sm2.defaultOptions : oAdd); + for (o in o2) { + if (o2.hasOwnProperty(o) && o1[o] === _undefined) { + if (typeof o2[o] !== 'object' || o2[o] === null) { + o1[o] = o2[o]; + } else { + o1[o] = mixin(o1[o], o2[o]); + } + } + } + return o1; + }; + wrapCallback = function(oSound, callback) { + if (!oSound.isHTML5 && fV === 8) { + window.setTimeout(callback, 0); + } else { + callback(); + } + }; + extraOptions = { + 'onready': 1, + 'ontimeout': 1, + 'defaultOptions': 1, + 'flash9Options': 1, + 'movieStarOptions': 1 + }; + assign = function(o, oParent) { + var i, + result = true, + hasParent = (oParent !== _undefined), + setupOptions = sm2.setupOptions, + bonusOptions = extraOptions; + for (i in o) { + if (o.hasOwnProperty(i)) { + if (typeof o[i] !== 'object' || o[i] === null || o[i] instanceof Array || o[i] instanceof RegExp) { + if (hasParent && bonusOptions[oParent] !== _undefined) { + sm2[oParent][i] = o[i]; + } else if (setupOptions[i] !== _undefined) { + sm2.setupOptions[i] = o[i]; + sm2[i] = o[i]; + } else if (bonusOptions[i] === _undefined) { + result = false; + } else { + if (sm2[i] instanceof Function) { + sm2[i].apply(sm2, (o[i] instanceof Array? o[i] : [o[i]])); + } else { + sm2[i] = o[i]; + } + } + } else { + if (bonusOptions[i] === _undefined) { + result = false; + } else { + return assign(o[i], i); + } + } + } + } + return result; + }; + function preferFlashCheck(kind) { + return (sm2.preferFlash && hasFlash && !sm2.ignoreFlash && (sm2.flash[kind] !== _undefined && sm2.flash[kind])); + } + event = (function() { + var old = (window.attachEvent), + evt = { + add: (old?'attachEvent':'addEventListener'), + remove: (old?'detachEvent':'removeEventListener') + }; + function getArgs(oArgs) { + var args = slice.call(oArgs), + len = args.length; + if (old) { + args[1] = 'on' + args[1]; + if (len > 3) { + args.pop(); + } + } else if (len === 3) { + args.push(false); + } + return args; + } + function apply(args, sType) { + var element = args.shift(), + method = [evt[sType]]; + if (old) { + element[method](args[0], args[1]); + } else { + element[method].apply(element, args); + } + } + function add() { + apply(getArgs(arguments), 'add'); + } + function remove() { + apply(getArgs(arguments), 'remove'); + } + return { + 'add': add, + 'remove': remove + }; + }()); + function html5_event(oFn) { + return function(e) { + var s = this._s, + result; + if (!s || !s._a) { + result = null; + } else { + result = oFn.call(this, e); + } + return result; + }; + } + html5_events = { + abort: html5_event(function() { + }), + canplay: html5_event(function() { + var s = this._s, + position1K; + if (s._html5_canplay) { + return true; + } + s._html5_canplay = true; + s._onbufferchange(0); + position1K = (s._iO.position !== _undefined && !isNaN(s._iO.position)?s._iO.position/msecScale:null); + if (s.position && this.currentTime !== position1K) { + try { + this.currentTime = position1K; + } catch(ee) { + } + } + if (s._iO._oncanplay) { + s._iO._oncanplay(); + } + }), + canplaythrough: html5_event(function() { + var s = this._s; + if (!s.loaded) { + s._onbufferchange(0); + s._whileloading(s.bytesLoaded, s.bytesTotal, s._get_html5_duration()); + s._onload(true); + } + }), + ended: html5_event(function() { + var s = this._s; + s._onfinish(); + }), + error: html5_event(function() { + this._s._onload(false); + }), + loadeddata: html5_event(function() { + var s = this._s; + if (!s._loaded && !isSafari) { + s.duration = s._get_html5_duration(); + } + }), + loadedmetadata: html5_event(function() { + }), + loadstart: html5_event(function() { + this._s._onbufferchange(1); + }), + play: html5_event(function() { + this._s._onbufferchange(0); + }), + playing: html5_event(function() { + this._s._onbufferchange(0); + }), + progress: html5_event(function(e) { + var s = this._s, + i, j, progStr, buffered = 0, + isProgress = (e.type === 'progress'), + ranges = e.target.buffered, + loaded = (e.loaded||0), + total = (e.total||1); + s.buffered = []; + if (ranges && ranges.length) { + for (i=0, j=ranges.length; i= 0; i--) { + support['audio/'+aF[item].related[i]] = support[item]; + sm2.html5[aF[item].related[i]] = support[item]; + sm2.flash[aF[item].related[i]] = support[item]; + } + } + } + } + support.canPlayType = (a?cp:null); + sm2.html5 = mixin(sm2.html5, support); + sm2.html5.usingFlash = featureCheck(); + needsFlash = sm2.html5.usingFlash; + return true; + }; + strings = { + }; + str = function() { + }; + loopFix = function(sOpt) { + if (fV === 8 && sOpt.loops > 1 && sOpt.stream) { + sOpt.stream = false; + } + return sOpt; + }; + policyFix = function(sOpt, sPre) { + if (sOpt && !sOpt.usePolicyFile && (sOpt.onid3 || sOpt.usePeakData || sOpt.useWaveformData || sOpt.useEQData)) { + sOpt.usePolicyFile = true; + } + return sOpt; + }; + complain = function(sMsg) { + }; + doNothing = function() { + return false; + }; + disableObject = function(o) { + var oProp; + for (oProp in o) { + if (o.hasOwnProperty(oProp) && typeof o[oProp] === 'function') { + o[oProp] = doNothing; + } + } + oProp = null; + }; + failSafely = function(bNoDisable) { + if (bNoDisable === _undefined) { + bNoDisable = false; + } + if (disabled || bNoDisable) { + sm2.disable(bNoDisable); + } + }; + normalizeMovieURL = function(smURL) { + var urlParams = null, url; + if (smURL) { + if (smURL.match(/\.swf(\?.*)?$/i)) { + urlParams = smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?') + 4); + if (urlParams) { + return smURL; + } + } else if (smURL.lastIndexOf('/') !== smURL.length - 1) { + smURL += '/'; + } + } + url = (smURL && smURL.lastIndexOf('/') !== - 1 ? smURL.substr(0, smURL.lastIndexOf('/') + 1) : './') + sm2.movieURL; + if (sm2.noSWFCache) { + url += ('?ts=' + new Date().getTime()); + } + return url; + }; + setVersionInfo = function() { + fV = parseInt(sm2.flashVersion, 10); + if (fV !== 8 && fV !== 9) { + sm2.flashVersion = fV = defaultFlashVersion; + } + var isDebug = (sm2.debugMode || sm2.debugFlash?'_debug.swf':'.swf'); + if (sm2.useHTML5Audio && !sm2.html5Only && sm2.audioFormats.mp4.required && fV < 9) { + sm2.flashVersion = fV = 9; + } + sm2.version = sm2.versionNumber + (sm2.html5Only?' (HTML5-only mode)':(fV === 9?' (AS3/Flash 9)':' (AS2/Flash 8)')); + if (fV > 8) { + sm2.defaultOptions = mixin(sm2.defaultOptions, sm2.flash9Options); + sm2.features.buffering = true; + sm2.defaultOptions = mixin(sm2.defaultOptions, sm2.movieStarOptions); + sm2.filePatterns.flash9 = new RegExp('\\.(mp3|' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i'); + sm2.features.movieStar = true; + } else { + sm2.features.movieStar = false; + } + sm2.filePattern = sm2.filePatterns[(fV !== 8?'flash9':'flash8')]; + sm2.movieURL = (fV === 8?'soundmanager2.swf':'soundmanager2_flash9.swf').replace('.swf', isDebug); + sm2.features.peakData = sm2.features.waveformData = sm2.features.eqData = (fV > 8); + }; + setPolling = function(bPolling, bHighPerformance) { + if (!flash) { + return false; + } + flash._setPolling(bPolling, bHighPerformance); + }; + initDebug = function() { + }; + idCheck = this.getSoundById; + getSWFCSS = function() { + var css = []; + if (sm2.debugMode) { + css.push(swfCSS.sm2Debug); + } + if (sm2.debugFlash) { + css.push(swfCSS.flashDebug); + } + if (sm2.useHighPerformance) { + css.push(swfCSS.highPerf); + } + return css.join(' '); + }; + flashBlockHandler = function() { + var name = str('fbHandler'), + p = sm2.getMoviePercent(), + css = swfCSS, + error = {type:'FLASHBLOCK'}; + if (sm2.html5Only) { + return false; + } + if (!sm2.ok()) { + if (needsFlash) { + sm2.oMC.className = getSWFCSS() + ' ' + css.swfDefault + ' ' + (p === null?css.swfTimedout:css.swfError); + } + sm2.didFlashBlock = true; + processOnEvents({type:'ontimeout', ignoreInit:true, error:error}); + catchError(error); + } else { + if (sm2.oMC) { + sm2.oMC.className = [getSWFCSS(), css.swfDefault, css.swfLoaded + (sm2.didFlashBlock?' '+css.swfUnblocked:'')].join(' '); + } + } + }; + addOnEvent = function(sType, oMethod, oScope) { + if (on_queue[sType] === _undefined) { + on_queue[sType] = []; + } + on_queue[sType].push({ + 'method': oMethod, + 'scope': (oScope || null), + 'fired': false + }); + }; + processOnEvents = function(oOptions) { + if (!oOptions) { + oOptions = { + type: (sm2.ok() ? 'onready' : 'ontimeout') + }; + } + if (!didInit && oOptions && !oOptions.ignoreInit) { + return false; + } + if (oOptions.type === 'ontimeout' && (sm2.ok() || (disabled && !oOptions.ignoreInit))) { + return false; + } + var status = { + success: (oOptions && oOptions.ignoreInit?sm2.ok():!disabled) + }, + srcQueue = (oOptions && oOptions.type?on_queue[oOptions.type]||[]:[]), + queue = [], i, j, + args = [status], + canRetry = (needsFlash && !sm2.ok()); + if (oOptions.error) { + args[0].error = oOptions.error; + } + for (i = 0, j = srcQueue.length; i < j; i++) { + if (srcQueue[i].fired !== true) { + queue.push(srcQueue[i]); + } + } + if (queue.length) { + for (i = 0, j = queue.length; i < j; i++) { + if (queue[i].scope) { + queue[i].method.apply(queue[i].scope, args); + } else { + queue[i].method.apply(this, args); + } + if (!canRetry) { + queue[i].fired = true; + } + } + } + return true; + }; + initUserOnload = function() { + window.setTimeout(function() { + if (sm2.useFlashBlock) { + flashBlockHandler(); + } + processOnEvents(); + if (typeof sm2.onload === 'function') { + sm2.onload.apply(window); + } + if (sm2.waitForWindowLoad) { + event.add(window, 'load', initUserOnload); + } + },1); + }; + detectFlash = function() { + if (hasFlash !== _undefined) { + return hasFlash; + } + var hasPlugin = false, n = navigator, nP = n.plugins, obj, type, types, AX = window.ActiveXObject; + if (nP && nP.length) { + type = 'application/x-shockwave-flash'; + types = n.mimeTypes; + if (types && types[type] && types[type].enabledPlugin && types[type].enabledPlugin.description) { + hasPlugin = true; + } + } else if (AX !== _undefined && !ua.match(/MSAppHost/i)) { + try { + obj = new AX('ShockwaveFlash.ShockwaveFlash'); + } catch(e) { + obj = null; + } + hasPlugin = (!!obj); + obj = null; + } + hasFlash = hasPlugin; + return hasPlugin; + }; + featureCheck = function() { + var flashNeeded, + item, + formats = sm2.audioFormats, + isSpecial = (is_iDevice && !!(ua.match(/os (1|2|3_0|3_1)/i))); + if (isSpecial) { + sm2.hasHTML5 = false; + sm2.html5Only = true; + if (sm2.oMC) { + sm2.oMC.style.display = 'none'; + } + } else { + if (sm2.useHTML5Audio) { + if (!sm2.html5 || !sm2.html5.canPlayType) { + sm2.hasHTML5 = false; + } + } + } + if (sm2.useHTML5Audio && sm2.hasHTML5) { + canIgnoreFlash = true; + for (item in formats) { + if (formats.hasOwnProperty(item)) { + if (formats[item].required) { + if (!sm2.html5.canPlayType(formats[item].type)) { + canIgnoreFlash = false; + flashNeeded = true; + } else if (sm2.preferFlash && (sm2.flash[item] || sm2.flash[formats[item].type])) { + flashNeeded = true; + } + } + } + } + } + if (sm2.ignoreFlash) { + flashNeeded = false; + canIgnoreFlash = true; + } + sm2.html5Only = (sm2.hasHTML5 && sm2.useHTML5Audio && !flashNeeded); + return (!sm2.html5Only); + }; + parseURL = function(url) { + var i, j, urlResult = 0, result; + if (url instanceof Array) { + for (i=0, j=url.length; i= 0; i--) { + if (sm2.sounds[sm2.soundIDs[i]].isHTML5 && sm2.sounds[sm2.soundIDs[i]]._hasTimer) { + sm2.sounds[sm2.soundIDs[i]]._onTimer(); + } + } + }; + catchError = function(options) { + options = (options !== _undefined ? options : {}); + if (typeof sm2.onerror === 'function') { + sm2.onerror.apply(window, [{type:(options.type !== _undefined ? options.type : null)}]); + } + if (options.fatal !== _undefined && options.fatal) { + sm2.disable(); + } + }; + badSafariFix = function() { + if (!isBadSafari || !detectFlash()) { + return false; + } + var aF = sm2.audioFormats, i, item; + for (item in aF) { + if (aF.hasOwnProperty(item)) { + if (item === 'mp3' || item === 'mp4') { + sm2.html5[item] = false; + if (aF[item] && aF[item].related) { + for (i = aF[item].related.length-1; i >= 0; i--) { + sm2.html5[aF[item].related[i]] = false; + } + } + } + } + } + }; + this._setSandboxType = function(sandboxType) { + }; + this._externalInterfaceOK = function(swfVersion) { + if (sm2.swfLoaded) { + return false; + } + var e; + sm2.swfLoaded = true; + tryInitOnFocus = false; + if (isBadSafari) { + badSafariFix(); + } + setTimeout(init, isIE ? 100 : 1); + }; + createMovie = function(smID, smURL) { + if (didAppend && appendSuccess) { + return false; + } + function initMsg() { + } + if (sm2.html5Only) { + setVersionInfo(); + initMsg(); + sm2.oMC = id(sm2.movieID); + init(); + didAppend = true; + appendSuccess = true; + return false; + } + var remoteURL = (smURL || sm2.url), + localURL = (sm2.altURL || remoteURL), + swfTitle = 'JS/Flash audio component (SoundManager 2)', + oTarget = getDocument(), + extraClass = getSWFCSS(), + isRTL = null, + html = doc.getElementsByTagName('html')[0], + oEmbed, oMovie, tmp, movieHTML, oEl, s, x, sClass; + isRTL = (html && html.dir && html.dir.match(/rtl/i)); + smID = (smID === _undefined?sm2.id:smID); + function param(name, value) { + return ''; + } + setVersionInfo(); + sm2.url = normalizeMovieURL(overHTTP?remoteURL:localURL); + smURL = sm2.url; + sm2.wmode = (!sm2.wmode && sm2.useHighPerformance ? 'transparent' : sm2.wmode); + if (sm2.wmode !== null && (ua.match(/msie 8/i) || (!isIE && !sm2.useHighPerformance)) && navigator.platform.match(/win32|win64/i)) { + messages.push(strings.spcWmode); + sm2.wmode = null; + } + oEmbed = { + 'name': smID, + 'id': smID, + 'src': smURL, + 'quality': 'high', + 'allowScriptAccess': sm2.allowScriptAccess, + 'bgcolor': sm2.bgColor, + 'pluginspage': http+'www.macromedia.com/go/getflashplayer', + 'title': swfTitle, + 'type': 'application/x-shockwave-flash', + 'wmode': sm2.wmode, + 'hasPriority': 'true' + }; + if (sm2.debugFlash) { + oEmbed.FlashVars = 'debug=1'; + } + if (!sm2.wmode) { + delete oEmbed.wmode; + } + if (isIE) { + oMovie = doc.createElement('div'); + movieHTML = [ + '', + param('movie', smURL), + param('AllowScriptAccess', sm2.allowScriptAccess), + param('quality', oEmbed.quality), + (sm2.wmode? param('wmode', sm2.wmode): ''), + param('bgcolor', sm2.bgColor), + param('hasPriority', 'true'), + (sm2.debugFlash ? param('FlashVars', oEmbed.FlashVars) : ''), + '' + ].join(''); + } else { + oMovie = doc.createElement('embed'); + for (tmp in oEmbed) { + if (oEmbed.hasOwnProperty(tmp)) { + oMovie.setAttribute(tmp, oEmbed[tmp]); + } + } + } + initDebug(); + extraClass = getSWFCSS(); + oTarget = getDocument(); + if (oTarget) { + sm2.oMC = (id(sm2.movieID) || doc.createElement('div')); + if (!sm2.oMC.id) { + sm2.oMC.id = sm2.movieID; + sm2.oMC.className = swfCSS.swfDefault + ' ' + extraClass; + s = null; + oEl = null; + if (!sm2.useFlashBlock) { + if (sm2.useHighPerformance) { + s = { + 'position': 'fixed', + 'width': '8px', + 'height': '8px', + 'bottom': '0px', + 'left': '0px', + 'overflow': 'hidden' + }; + } else { + s = { + 'position': 'absolute', + 'width': '6px', + 'height': '6px', + 'top': '-9999px', + 'left': '-9999px' + }; + if (isRTL) { + s.left = Math.abs(parseInt(s.left,10))+'px'; + } + } + } + if (isWebkit) { + sm2.oMC.style.zIndex = 10000; + } + if (!sm2.debugFlash) { + for (x in s) { + if (s.hasOwnProperty(x)) { + sm2.oMC.style[x] = s[x]; + } + } + } + try { + if (!isIE) { + sm2.oMC.appendChild(oMovie); + } + oTarget.appendChild(sm2.oMC); + if (isIE) { + oEl = sm2.oMC.appendChild(doc.createElement('div')); + oEl.className = swfCSS.swfBox; + oEl.innerHTML = movieHTML; + } + appendSuccess = true; + } catch(e) { + throw new Error(str('domError')+' \n'+e.toString()); + } + } else { + sClass = sm2.oMC.className; + sm2.oMC.className = (sClass?sClass+' ':swfCSS.swfDefault) + (extraClass?' '+extraClass:''); + sm2.oMC.appendChild(oMovie); + if (isIE) { + oEl = sm2.oMC.appendChild(doc.createElement('div')); + oEl.className = swfCSS.swfBox; + oEl.innerHTML = movieHTML; + } + appendSuccess = true; + } + } + didAppend = true; + initMsg(); + return true; + }; + initMovie = function() { + if (sm2.html5Only) { + createMovie(); + return false; + } + if (flash) { + return false; + } + if (!sm2.url) { + return false; + } + flash = sm2.getMovie(sm2.id); + if (!flash) { + if (!oRemoved) { + createMovie(sm2.id, sm2.url); + } else { + if (!isIE) { + sm2.oMC.appendChild(oRemoved); + } else { + sm2.oMC.innerHTML = oRemovedHTML; + } + oRemoved = null; + didAppend = true; + } + flash = sm2.getMovie(sm2.id); + } + if (typeof sm2.oninitmovie === 'function') { + setTimeout(sm2.oninitmovie, 1); + } + return true; + }; + delayWaitForEI = function() { + setTimeout(waitForEI, 1000); + }; + rebootIntoHTML5 = function() { + window.setTimeout(function() { + sm2.setup({ + preferFlash: false + }).reboot(); + sm2.didFlashBlock = true; + sm2.beginDelayedInit(); + }, 1); + }; + waitForEI = function() { + var p, + loadIncomplete = false; + if (!sm2.url) { + return false; + } + if (waitingForEI) { + return false; + } + waitingForEI = true; + event.remove(window, 'load', delayWaitForEI); + if (hasFlash && tryInitOnFocus && !isFocused) { + return false; + } + if (!didInit) { + p = sm2.getMoviePercent(); + if (p > 0 && p < 100) { + loadIncomplete = true; + } + } + setTimeout(function() { + p = sm2.getMoviePercent(); + if (loadIncomplete) { + waitingForEI = false; + window.setTimeout(delayWaitForEI, 1); + return false; + } + if (!didInit && okToDisable) { + if (p === null) { + if (sm2.useFlashBlock || sm2.flashLoadTimeout === 0) { + if (sm2.useFlashBlock) { + flashBlockHandler(); + } + } else { + if (!sm2.useFlashBlock && canIgnoreFlash) { + rebootIntoHTML5(); + } else { + processOnEvents({type:'ontimeout', ignoreInit: true, error: {type: 'INIT_FLASHBLOCK'}}); + } + } + } else { + if (sm2.flashLoadTimeout === 0) { + } else { + if (!sm2.useFlashBlock && canIgnoreFlash) { + rebootIntoHTML5(); + } else { + failSafely(true); + } + } + } + } + }, sm2.flashLoadTimeout); + }; + handleFocus = function() { + function cleanup() { + event.remove(window, 'focus', handleFocus); + } + if (isFocused || !tryInitOnFocus) { + cleanup(); + return true; + } + okToDisable = true; + isFocused = true; + waitingForEI = false; + delayWaitForEI(); + cleanup(); + return true; + }; + flushMessages = function() { + }; + showSupport = function() { + }; + initComplete = function(bNoDisable) { + if (didInit) { + return false; + } + if (sm2.html5Only) { + didInit = true; + initUserOnload(); + return true; + } + var wasTimeout = (sm2.useFlashBlock && sm2.flashLoadTimeout && !sm2.getMoviePercent()), + result = true, + error; + if (!wasTimeout) { + didInit = true; + } + error = {type: (!hasFlash && needsFlash ? 'NO_FLASH' : 'INIT_TIMEOUT')}; + if (disabled || bNoDisable) { + if (sm2.useFlashBlock && sm2.oMC) { + sm2.oMC.className = getSWFCSS() + ' ' + (sm2.getMoviePercent() === null?swfCSS.swfTimedout:swfCSS.swfError); + } + processOnEvents({type:'ontimeout', error:error, ignoreInit: true}); + catchError(error); + result = false; + } else { + } + if (!disabled) { + if (sm2.waitForWindowLoad && !windowLoaded) { + event.add(window, 'load', initUserOnload); + } else { + initUserOnload(); + } + } + return result; + }; + setProperties = function() { + var i, + o = sm2.setupOptions; + for (i in o) { + if (o.hasOwnProperty(i)) { + if (sm2[i] === _undefined) { + sm2[i] = o[i]; + } else if (sm2[i] !== o[i]) { + sm2.setupOptions[i] = sm2[i]; + } + } + } + }; + init = function() { + if (didInit) { + return false; + } + function cleanup() { + event.remove(window, 'load', sm2.beginDelayedInit); + } + if (sm2.html5Only) { + if (!didInit) { + cleanup(); + sm2.enabled = true; + initComplete(); + } + return true; + } + initMovie(); + try { + flash._externalInterfaceTest(false); + setPolling(true, (sm2.flashPollingInterval || (sm2.useHighPerformance ? 10 : 50))); + if (!sm2.debugMode) { + flash._disableDebug(); + } + sm2.enabled = true; + if (!sm2.html5Only) { + event.add(window, 'unload', doNothing); + } + } catch(e) { + catchError({type:'JS_TO_FLASH_EXCEPTION', fatal:true}); + failSafely(true); + initComplete(); + return false; + } + initComplete(); + cleanup(); + return true; + }; + domContentLoaded = function() { + if (didDCLoaded) { + return false; + } + didDCLoaded = true; + setProperties(); + initDebug(); + if (!hasFlash && sm2.hasHTML5) { + sm2.setup({ + 'useHTML5Audio': true, + 'preferFlash': false + }); + } + testHTML5(); + if (!hasFlash && needsFlash) { + messages.push(strings.needFlash); + sm2.setup({ + 'flashLoadTimeout': 1 + }); + } + if (doc.removeEventListener) { + doc.removeEventListener('DOMContentLoaded', domContentLoaded, false); + } + initMovie(); + return true; + }; + domContentLoadedIE = function() { + if (doc.readyState === 'complete') { + domContentLoaded(); + doc.detachEvent('onreadystatechange', domContentLoadedIE); + } + return true; + }; + winOnLoad = function() { + windowLoaded = true; + event.remove(window, 'load', winOnLoad); + }; + preInit = function() { + if (mobileHTML5) { + sm2.setupOptions.useHTML5Audio = true; + sm2.setupOptions.preferFlash = false; + if (is_iDevice || (isAndroid && !ua.match(/android\s2\.3/i))) { + if (is_iDevice) { + sm2.ignoreFlash = true; + } + useGlobalHTML5Audio = true; + } + } + }; + preInit(); + detectFlash(); + event.add(window, 'focus', handleFocus); + event.add(window, 'load', delayWaitForEI); + event.add(window, 'load', winOnLoad); + if (doc.addEventListener) { + doc.addEventListener('DOMContentLoaded', domContentLoaded, false); + } else if (doc.attachEvent) { + doc.attachEvent('onreadystatechange', domContentLoadedIE); + } else { + catchError({type:'NO_DOM2_EVENTS', fatal:true}); + } +} +// SM2_DEFER details: http://www.schillmania.com/projects/soundmanager2/doc/getstarted/#lazy-loading +if (window.SM2_DEFER === undefined || !SM2_DEFER) { + soundManager = new SoundManager(); +} +window.SoundManager = SoundManager; +window.soundManager = soundManager; +}(window)); diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/script/soundmanager2.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/script/soundmanager2.js new file mode 100755 index 00000000..ddbe3420 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/script/soundmanager2.js @@ -0,0 +1,5989 @@ +/** @license + * + * SoundManager 2: JavaScript Sound for the Web + * ---------------------------------------------- + * http://schillmania.com/projects/soundmanager2/ + * + * Copyright (c) 2007, Scott Schiller. All rights reserved. + * Code provided under the BSD License: + * http://schillmania.com/projects/soundmanager2/license.txt + * + * V2.97a.20131201 + */ + +/*global window, SM2_DEFER, sm2Debugger, console, document, navigator, setTimeout, setInterval, clearInterval, Audio, opera */ +/*jslint regexp: true, sloppy: true, white: true, nomen: true, plusplus: true, todo: true */ + +/** + * About this file + * ------------------------------------------------------------------------------------- + * This is the fully-commented source version of the SoundManager 2 API, + * recommended for use during development and testing. + * + * See soundmanager2-nodebug-jsmin.js for an optimized build (~11KB with gzip.) + * http://schillmania.com/projects/soundmanager2/doc/getstarted/#basic-inclusion + * Alternately, serve this file with gzip for 75% compression savings (~30KB over HTTP.) + * + * You may notice and comments in this source; these are delimiters for + * debug blocks which are removed in the -nodebug builds, further optimizing code size. + * + * Also, as you may note: Whoa, reliable cross-platform/device audio support is hard! ;) + */ + +(function(window, _undefined) { + +"use strict"; + +var soundManager = null; + +/** + * The SoundManager constructor. + * + * @constructor + * @param {string} smURL Optional: Path to SWF files + * @param {string} smID Optional: The ID to use for the SWF container element + * @this {SoundManager} + * @return {SoundManager} The new SoundManager instance + */ + +function SoundManager(smURL, smID) { + + /** + * soundManager configuration options list + * defines top-level configuration properties to be applied to the soundManager instance (eg. soundManager.flashVersion) + * to set these properties, use the setup() method - eg., soundManager.setup({url: '/swf/', flashVersion: 9}) + */ + + this.setupOptions = { + + 'url': (smURL || null), // path (directory) where SoundManager 2 SWFs exist, eg., /path/to/swfs/ + 'flashVersion': 8, // flash build to use (8 or 9.) Some API features require 9. + 'debugMode': true, // enable debugging output (console.log() with HTML fallback) + 'debugFlash': false, // enable debugging output inside SWF, troubleshoot Flash/browser issues + 'useConsole': true, // use console.log() if available (otherwise, writes to #soundmanager-debug element) + 'consoleOnly': true, // if console is being used, do not create/write to #soundmanager-debug + 'waitForWindowLoad': false, // force SM2 to wait for window.onload() before trying to call soundManager.onload() + 'bgColor': '#ffffff', // SWF background color. N/A when wmode = 'transparent' + 'useHighPerformance': false, // position:fixed flash movie can help increase js/flash speed, minimize lag + 'flashPollingInterval': null, // msec affecting whileplaying/loading callback frequency. If null, default of 50 msec is used. + 'html5PollingInterval': null, // msec affecting whileplaying() for HTML5 audio, excluding mobile devices. If null, native HTML5 update events are used. + 'flashLoadTimeout': 1000, // msec to wait for flash movie to load before failing (0 = infinity) + 'wmode': null, // flash rendering mode - null, 'transparent', or 'opaque' (last two allow z-index to work) + 'allowScriptAccess': 'always', // for scripting the SWF (object/embed property), 'always' or 'sameDomain' + 'useFlashBlock': false, // *requires flashblock.css, see demos* - allow recovery from flash blockers. Wait indefinitely and apply timeout CSS to SWF, if applicable. + 'useHTML5Audio': true, // use HTML5 Audio() where API is supported (most Safari, Chrome versions), Firefox (no MP3/MP4.) Ideally, transparent vs. Flash API where possible. + 'html5Test': /^(probably|maybe)$/i, // HTML5 Audio() format support test. Use /^probably$/i; if you want to be more conservative. + 'preferFlash': false, // overrides useHTML5audio, will use Flash for MP3/MP4/AAC if present. Potential option if HTML5 playback with these formats is quirky. + 'noSWFCache': false, // if true, appends ?ts={date} to break aggressive SWF caching. + 'idPrefix': 'sound' // if an id is not provided to createSound(), this prefix is used for generated IDs - 'sound0', 'sound1' etc. + + }; + + this.defaultOptions = { + + /** + * the default configuration for sound objects made with createSound() and related methods + * eg., volume, auto-load behaviour and so forth + */ + + 'autoLoad': false, // enable automatic loading (otherwise .load() will be called on demand with .play(), the latter being nicer on bandwidth - if you want to .load yourself, you also can) + 'autoPlay': false, // enable playing of file as soon as possible (much faster if "stream" is true) + 'from': null, // position to start playback within a sound (msec), default = beginning + 'loops': 1, // how many times to repeat the sound (position will wrap around to 0, setPosition() will break out of loop when >0) + 'onid3': null, // callback function for "ID3 data is added/available" + 'onload': null, // callback function for "load finished" + 'whileloading': null, // callback function for "download progress update" (X of Y bytes received) + 'onplay': null, // callback for "play" start + 'onpause': null, // callback for "pause" + 'onresume': null, // callback for "resume" (pause toggle) + 'whileplaying': null, // callback during play (position update) + 'onposition': null, // object containing times and function callbacks for positions of interest + 'onstop': null, // callback for "user stop" + 'onfailure': null, // callback function for when playing fails + 'onfinish': null, // callback function for "sound finished playing" + 'multiShot': true, // let sounds "restart" or layer on top of each other when played multiple times, rather than one-shot/one at a time + 'multiShotEvents': false, // fire multiple sound events (currently onfinish() only) when multiShot is enabled + 'position': null, // offset (milliseconds) to seek to within loaded sound data. + 'pan': 0, // "pan" settings, left-to-right, -100 to 100 + 'stream': true, // allows playing before entire file has loaded (recommended) + 'to': null, // position to end playback within a sound (msec), default = end + 'type': null, // MIME-like hint for file pattern / canPlay() tests, eg. audio/mp3 + 'usePolicyFile': false, // enable crossdomain.xml request for audio on remote domains (for ID3/waveform access) + 'volume': 100 // self-explanatory. 0-100, the latter being the max. + + }; + + this.flash9Options = { + + /** + * flash 9-only options, + * merged into defaultOptions if flash 9 is being used + */ + + 'isMovieStar': null, // "MovieStar" MPEG4 audio mode. Null (default) = auto detect MP4, AAC etc. based on URL. true = force on, ignore URL + 'usePeakData': false, // enable left/right channel peak (level) data + 'useWaveformData': false, // enable sound spectrum (raw waveform data) - NOTE: May increase CPU load. + 'useEQData': false, // enable sound EQ (frequency spectrum data) - NOTE: May increase CPU load. + 'onbufferchange': null, // callback for "isBuffering" property change + 'ondataerror': null // callback for waveform/eq data access error (flash playing audio in other tabs/domains) + + }; + + this.movieStarOptions = { + + /** + * flash 9.0r115+ MPEG4 audio options, + * merged into defaultOptions if flash 9+movieStar mode is enabled + */ + + 'bufferTime': 3, // seconds of data to buffer before playback begins (null = flash default of 0.1 seconds - if AAC playback is gappy, try increasing.) + 'serverURL': null, // rtmp: FMS or FMIS server to connect to, required when requesting media via RTMP or one of its variants + 'onconnect': null, // rtmp: callback for connection to flash media server + 'duration': null // rtmp: song duration (msec) + + }; + + this.audioFormats = { + + /** + * determines HTML5 support + flash requirements. + * if no support (via flash and/or HTML5) for a "required" format, SM2 will fail to start. + * flash fallback is used for MP3 or MP4 if HTML5 can't play it (or if preferFlash = true) + */ + + 'mp3': { + 'type': ['audio/mpeg; codecs="mp3"', 'audio/mpeg', 'audio/mp3', 'audio/MPA', 'audio/mpa-robust'], + 'required': true + }, + + 'mp4': { + 'related': ['aac','m4a','m4b'], // additional formats under the MP4 container + 'type': ['audio/mp4; codecs="mp4a.40.2"', 'audio/aac', 'audio/x-m4a', 'audio/MP4A-LATM', 'audio/mpeg4-generic'], + 'required': false + }, + + 'ogg': { + 'type': ['audio/ogg; codecs=vorbis'], + 'required': false + }, + + 'opus': { + 'type': ['audio/ogg; codecs=opus', 'audio/opus'], + 'required': false + }, + + 'wav': { + 'type': ['audio/wav; codecs="1"', 'audio/wav', 'audio/wave', 'audio/x-wav'], + 'required': false + } + + }; + + // HTML attributes (id + class names) for the SWF container + + this.movieID = 'sm2-container'; + this.id = (smID || 'sm2movie'); + + this.debugID = 'soundmanager-debug'; + this.debugURLParam = /([#?&])debug=1/i; + + // dynamic attributes + + this.versionNumber = 'V2.97a.20131201'; + this.version = null; + this.movieURL = null; + this.altURL = null; + this.swfLoaded = false; + this.enabled = false; + this.oMC = null; + this.sounds = {}; + this.soundIDs = []; + this.muted = false; + this.didFlashBlock = false; + this.filePattern = null; + + this.filePatterns = { + + 'flash8': /\.mp3(\?.*)?$/i, + 'flash9': /\.mp3(\?.*)?$/i + + }; + + // support indicators, set at init + + this.features = { + + 'buffering': false, + 'peakData': false, + 'waveformData': false, + 'eqData': false, + 'movieStar': false + + }; + + // flash sandbox info, used primarily in troubleshooting + + this.sandbox = { + + // + 'type': null, + 'types': { + 'remote': 'remote (domain-based) rules', + 'localWithFile': 'local with file access (no internet access)', + 'localWithNetwork': 'local with network (internet access only, no local access)', + 'localTrusted': 'local, trusted (local+internet access)' + }, + 'description': null, + 'noRemote': null, + 'noLocal': null + // + + }; + + /** + * format support (html5/flash) + * stores canPlayType() results based on audioFormats. + * eg. { mp3: boolean, mp4: boolean } + * treat as read-only. + */ + + this.html5 = { + 'usingFlash': null // set if/when flash fallback is needed + }; + + // file type support hash + this.flash = {}; + + // determined at init time + this.html5Only = false; + + // used for special cases (eg. iPad/iPhone/palm OS?) + this.ignoreFlash = false; + + /** + * a few private internals (OK, a lot. :D) + */ + + var SMSound, + 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, preInit, domContentLoaded, winOnLoad, didDCLoaded, getDocument, createMovie, catchError, setPolling, initDebug, debugLevels = ['log', 'info', 'warn', 'error'], defaultFlashVersion = 8, disableObject, failSafely, normalizeMovieURL, oRemoved = null, oRemovedHTML = null, str, flashBlockHandler, getSWFCSS, swfCSS, toggleDebug, loopFix, policyFix, complain, idCheck, waitingForEI = false, initPending = false, startTimer, stopTimer, timerExecute, h5TimerCount = 0, h5IntervalTimer = null, parseURL, messages = [], + 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, + is_iDevice = ua.match(/(ipad|iphone|ipod)/i), isAndroid = ua.match(/android/i), isIE = ua.match(/msie/i), isWebkit = ua.match(/webkit/i), isSafari = (ua.match(/safari/i) && !ua.match(/chrome/i)), isOpera = (ua.match(/opera/i)), + mobileHTML5 = (ua.match(/(mobile|pre\/|xoom)/i) || is_iDevice || isAndroid), + isBadSafari = (!wl.match(/usehtml5audio/i) && !wl.match(/sm2\-ignorebadua/i) && isSafari && !ua.match(/silk/i) && ua.match(/OS X 10_6_([3-7])/i)), // Safari 4 and 5 (excluding Kindle Fire, "Silk") occasionally fail to load/play HTML5 audio on Snow Leopard 10.6.3 through 10.6.7 due to bug(s) in QuickTime X and/or other underlying frameworks. :/ Confirmed bug. https://bugs.webkit.org/show_bug.cgi?id=32159 + hasConsole = (window.console !== _undefined && console.log !== _undefined), isFocused = (doc.hasFocus !== _undefined?doc.hasFocus():null), tryInitOnFocus = (isSafari && (doc.hasFocus === _undefined || !doc.hasFocus())), okToDisable = !tryInitOnFocus, flashMIME = /(mp3|mp4|mpa|m4a|m4b)/i, msecScale = 1000, + emptyURL = 'about:blank', // safe URL to unload, or load nothing from (flash 8 + most HTML5 UAs) + emptyWAV = 'data:audio/wave;base64,/UklGRiYAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQIAAAD//w==', // tiny WAV for HTML5 unloading + overHTTP = (doc.location?doc.location.protocol.match(/http/i):null), + http = (!overHTTP ? 'http:/'+'/' : ''), + // mp3, mp4, aac etc. + netStreamMimeTypes = /^\s*audio\/(?:x-)?(?:mpeg4|aac|flv|mov|mp4||m4v|m4a|m4b|mp4v|3gp|3g2)\s*(?:$|;)/i, + // Flash v9.0r115+ "moviestar" formats + netStreamTypes = ['mpeg4', 'aac', 'flv', 'mov', 'mp4', 'm4v', 'f4v', 'm4a', 'm4b', 'mp4v', '3gp', '3g2'], + netStreamPattern = new RegExp('\\.(' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i'); + + this.mimePattern = /^\s*audio\/(?:x-)?(?:mp(?:eg|3))\s*(?:$|;)/i; // default mp3 set + + // use altURL if not "online" + this.useAltURL = !overHTTP; + + swfCSS = { + + 'swfBox': 'sm2-object-box', + 'swfDefault': 'movieContainer', + 'swfError': 'swf_error', // SWF loaded, but SM2 couldn't start (other error) + 'swfTimedout': 'swf_timedout', + 'swfLoaded': 'swf_loaded', + 'swfUnblocked': 'swf_unblocked', // or loaded OK + 'sm2Debug': 'sm2_debug', + 'highPerf': 'high_performance', + 'flashDebug': 'flash_debug' + + }; + + /** + * basic HTML5 Audio() support test + * try...catch because of IE 9 "not implemented" nonsense + * https://github.com/Modernizr/Modernizr/issues/224 + */ + + this.hasHTML5 = (function() { + try { + // new Audio(null) for stupid Opera 9.64 case, which throws not_enough_arguments exception otherwise. + return (Audio !== _undefined && (isOpera && opera !== _undefined && opera.version() < 10 ? new Audio(null) : new Audio()).canPlayType !== _undefined); + } catch(e) { + return false; + } + }()); + + /** + * Public SoundManager API + * ----------------------- + */ + + /** + * Configures top-level soundManager properties. + * + * @param {object} options Option parameters, eg. { flashVersion: 9, url: '/path/to/swfs/' } + * onready and ontimeout are also accepted parameters. call soundManager.setup() to see the full list. + */ + + this.setup = function(options) { + + var noURL = (!sm2.url); + + // warn if flash options have already been applied + + if (options !== _undefined && didInit && needsFlash && sm2.ok() && (options.flashVersion !== _undefined || options.url !== _undefined || options.html5Test !== _undefined)) { + complain(str('setupLate')); + } + + // TODO: defer: true? + + assign(options); + + // special case 1: "Late setup". SM2 loaded normally, but user didn't assign flash URL eg., setup({url:...}) before SM2 init. Treat as delayed init. + + if (options) { + + if (noURL && didDCLoaded && options.url !== _undefined) { + sm2.beginDelayedInit(); + } + + // special case 2: If lazy-loading SM2 (DOMContentLoaded has already happened) and user calls setup() with url: parameter, try to init ASAP. + + if (!didDCLoaded && options.url !== _undefined && doc.readyState === 'complete') { + setTimeout(domContentLoaded, 1); + } + + } + + return sm2; + + }; + + this.ok = function() { + + return (needsFlash ? (didInit && !disabled) : (sm2.useHTML5Audio && sm2.hasHTML5)); + + }; + + this.supported = this.ok; // legacy + + this.getMovie = function(smID) { + + // safety net: some old browsers differ on SWF references, possibly related to ExternalInterface / flash version + return id(smID) || doc[smID] || window[smID]; + + }; + + /** + * Creates a SMSound sound object instance. + * + * @param {object} oOptions Sound options (at minimum, id and url parameters are required.) + * @return {object} SMSound The new SMSound object. + */ + + this.createSound = function(oOptions, _url) { + + var cs, cs_string, options, oSound = null; + + // + cs = sm + '.createSound(): '; + cs_string = cs + str(!didInit?'notReady':'notOK'); + // + + if (!didInit || !sm2.ok()) { + complain(cs_string); + return false; + } + + if (_url !== _undefined) { + // function overloading in JS! :) ..assume simple createSound(id, url) use case + oOptions = { + 'id': oOptions, + 'url': _url + }; + } + + // inherit from defaultOptions + options = mixin(oOptions); + + options.url = parseURL(options.url); + + // generate an id, if needed. + if (options.id === undefined) { + options.id = sm2.setupOptions.idPrefix + (idCounter++); + } + + // + if (options.id.toString().charAt(0).match(/^[0-9]$/)) { + sm2._wD(cs + str('badID', options.id), 2); + } + + sm2._wD(cs + options.id + (options.url ? ' (' + options.url + ')' : ''), 1); + // + + if (idCheck(options.id, true)) { + sm2._wD(cs + options.id + ' exists', 1); + return sm2.sounds[options.id]; + } + + function make() { + + options = loopFix(options); + sm2.sounds[options.id] = new SMSound(options); + sm2.soundIDs.push(options.id); + return sm2.sounds[options.id]; + + } + + if (html5OK(options)) { + + oSound = make(); + sm2._wD(options.id + ': Using HTML5'); + oSound._setup_html5(options); + + } else { + + if (sm2.html5Only) { + sm2._wD(options.id + ': No HTML5 support for this sound, and no Flash. Exiting.'); + return make(); + } + + // TODO: Move HTML5/flash checks into generic URL parsing/handling function. + + if (sm2.html5.usingFlash && options.url && options.url.match(/data\:/i)) { + // data: URIs not supported by Flash, either. + sm2._wD(options.id + ': data: URIs not supported via Flash. Exiting.'); + return make(); + } + + if (fV > 8) { + if (options.isMovieStar === null) { + // attempt to detect MPEG-4 formats + options.isMovieStar = !!(options.serverURL || (options.type ? options.type.match(netStreamMimeTypes) : false) || (options.url && options.url.match(netStreamPattern))); + } + // + if (options.isMovieStar) { + sm2._wD(cs + 'using MovieStar handling'); + if (options.loops > 1) { + _wDS('noNSLoop'); + } + } + // + } + + options = policyFix(options, cs); + oSound = make(); + + if (fV === 8) { + flash._createSound(options.id, options.loops||1, options.usePolicyFile); + } else { + 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); + if (!options.serverURL) { + // We are connected immediately + oSound.connected = true; + if (options.onconnect) { + options.onconnect.apply(oSound); + } + } + } + + if (!options.serverURL && (options.autoLoad || options.autoPlay)) { + // call load for non-rtmp streams + oSound.load(options); + } + + } + + // rtmp will play in onconnect + if (!options.serverURL && options.autoPlay) { + oSound.play(); + } + + return oSound; + + }; + + /** + * Destroys a SMSound sound object instance. + * + * @param {string} sID The ID of the sound to destroy + */ + + this.destroySound = function(sID, _bFromSound) { + + // explicitly destroy a sound before normal page unload, etc. + + if (!idCheck(sID)) { + return false; + } + + var oS = sm2.sounds[sID], i; + + // Disable all callbacks while the sound is being destroyed + oS._iO = {}; + + oS.stop(); + oS.unload(); + + for (i = 0; i < sm2.soundIDs.length; i++) { + if (sm2.soundIDs[i] === sID) { + sm2.soundIDs.splice(i, 1); + break; + } + } + + if (!_bFromSound) { + // ignore if being called from SMSound instance + oS.destruct(true); + } + + oS = null; + delete sm2.sounds[sID]; + + return true; + + }; + + /** + * Calls the load() method of a SMSound object by ID. + * + * @param {string} sID The ID of the sound + * @param {object} oOptions Optional: Sound options + */ + + this.load = function(sID, oOptions) { + + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].load(oOptions); + + }; + + /** + * Calls the unload() method of a SMSound object by ID. + * + * @param {string} sID The ID of the sound + */ + + this.unload = function(sID) { + + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].unload(); + + }; + + /** + * Calls the onPosition() method of a SMSound object by ID. + * + * @param {string} sID The ID of the sound + * @param {number} nPosition The position to watch for + * @param {function} oMethod The relevant callback to fire + * @param {object} oScope Optional: The scope to apply the callback to + * @return {SMSound} The SMSound object + */ + + this.onPosition = function(sID, nPosition, oMethod, oScope) { + + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].onposition(nPosition, oMethod, oScope); + + }; + + // legacy/backwards-compability: lower-case method name + this.onposition = this.onPosition; + + /** + * Calls the clearOnPosition() method of a SMSound object by ID. + * + * @param {string} sID The ID of the sound + * @param {number} nPosition The position to watch for + * @param {function} oMethod Optional: The relevant callback to fire + * @return {SMSound} The SMSound object + */ + + this.clearOnPosition = function(sID, nPosition, oMethod) { + + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].clearOnPosition(nPosition, oMethod); + + }; + + /** + * Calls the play() method of a SMSound object by ID. + * + * @param {string} sID The ID of the sound + * @param {object} oOptions Optional: Sound options + * @return {SMSound} The SMSound object + */ + + this.play = function(sID, oOptions) { + + var result = null, + // legacy function-overloading use case: play('mySound', '/path/to/some.mp3'); + overloaded = (oOptions && !(oOptions instanceof Object)); + + if (!didInit || !sm2.ok()) { + complain(sm + '.play(): ' + str(!didInit?'notReady':'notOK')); + return false; + } + + if (!idCheck(sID, overloaded)) { + + if (!overloaded) { + // no sound found for the given ID. Bail. + return false; + } + + if (overloaded) { + oOptions = { + url: oOptions + }; + } + + if (oOptions && oOptions.url) { + // overloading use case, create+play: .play('someID', {url:'/path/to.mp3'}); + sm2._wD(sm + '.play(): Attempting to create "' + sID + '"', 1); + oOptions.id = sID; + result = sm2.createSound(oOptions).play(); + } + + } else if (overloaded) { + + // existing sound object case + oOptions = { + url: oOptions + }; + + } + + if (result === null) { + // default case + result = sm2.sounds[sID].play(oOptions); + } + + return result; + + }; + + this.start = this.play; // just for convenience + + /** + * Calls the setPosition() method of a SMSound object by ID. + * + * @param {string} sID The ID of the sound + * @param {number} nMsecOffset Position (milliseconds) + * @return {SMSound} The SMSound object + */ + + this.setPosition = function(sID, nMsecOffset) { + + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].setPosition(nMsecOffset); + + }; + + /** + * Calls the stop() method of a SMSound object by ID. + * + * @param {string} sID The ID of the sound + * @return {SMSound} The SMSound object + */ + + this.stop = function(sID) { + + if (!idCheck(sID)) { + return false; + } + + sm2._wD(sm + '.stop(' + sID + ')', 1); + return sm2.sounds[sID].stop(); + + }; + + /** + * Stops all currently-playing sounds. + */ + + this.stopAll = function() { + + var oSound; + sm2._wD(sm + '.stopAll()', 1); + + for (oSound in sm2.sounds) { + if (sm2.sounds.hasOwnProperty(oSound)) { + // apply only to sound objects + sm2.sounds[oSound].stop(); + } + } + + }; + + /** + * Calls the pause() method of a SMSound object by ID. + * + * @param {string} sID The ID of the sound + * @return {SMSound} The SMSound object + */ + + this.pause = function(sID) { + + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].pause(); + + }; + + /** + * Pauses all currently-playing sounds. + */ + + this.pauseAll = function() { + + var i; + for (i = sm2.soundIDs.length-1; i >= 0; i--) { + sm2.sounds[sm2.soundIDs[i]].pause(); + } + + }; + + /** + * Calls the resume() method of a SMSound object by ID. + * + * @param {string} sID The ID of the sound + * @return {SMSound} The SMSound object + */ + + this.resume = function(sID) { + + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].resume(); + + }; + + /** + * Resumes all currently-paused sounds. + */ + + this.resumeAll = function() { + + var i; + for (i = sm2.soundIDs.length-1; i >= 0; i--) { + sm2.sounds[sm2.soundIDs[i]].resume(); + } + + }; + + /** + * Calls the togglePause() method of a SMSound object by ID. + * + * @param {string} sID The ID of the sound + * @return {SMSound} The SMSound object + */ + + this.togglePause = function(sID) { + + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].togglePause(); + + }; + + /** + * Calls the setPan() method of a SMSound object by ID. + * + * @param {string} sID The ID of the sound + * @param {number} nPan The pan value (-100 to 100) + * @return {SMSound} The SMSound object + */ + + this.setPan = function(sID, nPan) { + + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].setPan(nPan); + + }; + + /** + * Calls the setVolume() method of a SMSound object by ID. + * + * @param {string} sID The ID of the sound + * @param {number} nVol The volume value (0 to 100) + * @return {SMSound} The SMSound object + */ + + this.setVolume = function(sID, nVol) { + + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].setVolume(nVol); + + }; + + /** + * Calls the mute() method of either a single SMSound object by ID, or all sound objects. + * + * @param {string} sID Optional: The ID of the sound (if omitted, all sounds will be used.) + */ + + this.mute = function(sID) { + + var i = 0; + + if (sID instanceof String) { + sID = null; + } + + if (!sID) { + + sm2._wD(sm + '.mute(): Muting all sounds'); + for (i = sm2.soundIDs.length-1; i >= 0; i--) { + sm2.sounds[sm2.soundIDs[i]].mute(); + } + sm2.muted = true; + + } else { + + if (!idCheck(sID)) { + return false; + } + sm2._wD(sm + '.mute(): Muting "' + sID + '"'); + return sm2.sounds[sID].mute(); + + } + + return true; + + }; + + /** + * Mutes all sounds. + */ + + this.muteAll = function() { + + sm2.mute(); + + }; + + /** + * Calls the unmute() method of either a single SMSound object by ID, or all sound objects. + * + * @param {string} sID Optional: The ID of the sound (if omitted, all sounds will be used.) + */ + + this.unmute = function(sID) { + + var i; + + if (sID instanceof String) { + sID = null; + } + + if (!sID) { + + sm2._wD(sm + '.unmute(): Unmuting all sounds'); + for (i = sm2.soundIDs.length-1; i >= 0; i--) { + sm2.sounds[sm2.soundIDs[i]].unmute(); + } + sm2.muted = false; + + } else { + + if (!idCheck(sID)) { + return false; + } + sm2._wD(sm + '.unmute(): Unmuting "' + sID + '"'); + return sm2.sounds[sID].unmute(); + + } + + return true; + + }; + + /** + * Unmutes all sounds. + */ + + this.unmuteAll = function() { + + sm2.unmute(); + + }; + + /** + * Calls the toggleMute() method of a SMSound object by ID. + * + * @param {string} sID The ID of the sound + * @return {SMSound} The SMSound object + */ + + this.toggleMute = function(sID) { + + if (!idCheck(sID)) { + return false; + } + return sm2.sounds[sID].toggleMute(); + + }; + + /** + * Retrieves the memory used by the flash plugin. + * + * @return {number} The amount of memory in use + */ + + this.getMemoryUse = function() { + + // flash-only + var ram = 0; + + if (flash && fV !== 8) { + ram = parseInt(flash._getMemoryUse(), 10); + } + + return ram; + + }; + + /** + * Undocumented: NOPs soundManager and all SMSound objects. + */ + + this.disable = function(bNoDisable) { + + // destroy all functions + var i; + + if (bNoDisable === _undefined) { + bNoDisable = false; + } + + if (disabled) { + return false; + } + + disabled = true; + _wDS('shutdown', 1); + + for (i = sm2.soundIDs.length-1; i >= 0; i--) { + disableObject(sm2.sounds[sm2.soundIDs[i]]); + } + + // fire "complete", despite fail + initComplete(bNoDisable); + event.remove(window, 'load', initUserOnload); + + return true; + + }; + + /** + * Determines playability of a MIME type, eg. 'audio/mp3'. + */ + + this.canPlayMIME = function(sMIME) { + + var result; + + if (sm2.hasHTML5) { + result = html5CanPlay({type:sMIME}); + } + + if (!result && needsFlash) { + // if flash 9, test netStream (movieStar) types as well. + result = (sMIME && sm2.ok() ? !!((fV > 8 ? sMIME.match(netStreamMimeTypes) : null) || sMIME.match(sm2.mimePattern)) : null); // TODO: make less "weird" (per JSLint) + } + + return result; + + }; + + /** + * Determines playability of a URL based on audio support. + * + * @param {string} sURL The URL to test + * @return {boolean} URL playability + */ + + this.canPlayURL = function(sURL) { + + var result; + + if (sm2.hasHTML5) { + result = html5CanPlay({url: sURL}); + } + + if (!result && needsFlash) { + result = (sURL && sm2.ok() ? !!(sURL.match(sm2.filePattern)) : null); + } + + return result; + + }; + + /** + * Determines playability of an HTML DOM <a> object (or similar object literal) based on audio support. + * + * @param {object} oLink an HTML DOM <a> object or object literal including href and/or type attributes + * @return {boolean} URL playability + */ + + this.canPlayLink = function(oLink) { + + if (oLink.type !== _undefined && oLink.type) { + if (sm2.canPlayMIME(oLink.type)) { + return true; + } + } + + return sm2.canPlayURL(oLink.href); + + }; + + /** + * Retrieves a SMSound object by ID. + * + * @param {string} sID The ID of the sound + * @return {SMSound} The SMSound object + */ + + this.getSoundById = function(sID, _suppressDebug) { + + if (!sID) { + return null; + } + + var result = sm2.sounds[sID]; + + // + if (!result && !_suppressDebug) { + sm2._wD(sm + '.getSoundById(): Sound "' + sID + '" not found.', 2); + } + // + + return result; + + }; + + /** + * Queues a callback for execution when SoundManager has successfully initialized. + * + * @param {function} oMethod The callback method to fire + * @param {object} oScope Optional: The scope to apply to the callback + */ + + this.onready = function(oMethod, oScope) { + + var sType = 'onready', + result = false; + + if (typeof oMethod === 'function') { + + // + if (didInit) { + sm2._wD(str('queue', sType)); + } + // + + if (!oScope) { + oScope = window; + } + + addOnEvent(sType, oMethod, oScope); + processOnEvents(); + + result = true; + + } else { + + throw str('needFunction', sType); + + } + + return result; + + }; + + /** + * Queues a callback for execution when SoundManager has failed to initialize. + * + * @param {function} oMethod The callback method to fire + * @param {object} oScope Optional: The scope to apply to the callback + */ + + this.ontimeout = function(oMethod, oScope) { + + var sType = 'ontimeout', + result = false; + + if (typeof oMethod === 'function') { + + // + if (didInit) { + sm2._wD(str('queue', sType)); + } + // + + if (!oScope) { + oScope = window; + } + + addOnEvent(sType, oMethod, oScope); + processOnEvents({type:sType}); + + result = true; + + } else { + + throw str('needFunction', sType); + + } + + return result; + + }; + + /** + * Writes console.log()-style debug output to a console or in-browser element. + * Applies when debugMode = true + * + * @param {string} sText The console message + * @param {object} nType Optional log level (number), or object. Number case: Log type/style where 0 = 'info', 1 = 'warn', 2 = 'error'. Object case: Object to be dumped. + */ + + this._writeDebug = function(sText, sTypeOrObject) { + + // pseudo-private console.log()-style output + // + + var sDID = 'soundmanager-debug', o, oItem; + + if (!sm2.debugMode) { + return false; + } + + if (hasConsole && sm2.useConsole) { + if (sTypeOrObject && typeof sTypeOrObject === 'object') { + // object passed; dump to console. + console.log(sText, sTypeOrObject); + } else if (debugLevels[sTypeOrObject] !== _undefined) { + console[debugLevels[sTypeOrObject]](sText); + } else { + console.log(sText); + } + if (sm2.consoleOnly) { + return true; + } + } + + o = id(sDID); + + if (!o) { + return false; + } + + oItem = doc.createElement('div'); + + if (++wdCount % 2 === 0) { + oItem.className = 'sm2-alt'; + } + + if (sTypeOrObject === _undefined) { + sTypeOrObject = 0; + } else { + sTypeOrObject = parseInt(sTypeOrObject, 10); + } + + oItem.appendChild(doc.createTextNode(sText)); + + if (sTypeOrObject) { + if (sTypeOrObject >= 2) { + oItem.style.fontWeight = 'bold'; + } + if (sTypeOrObject === 3) { + oItem.style.color = '#ff3333'; + } + } + + // top-to-bottom + // o.appendChild(oItem); + + // bottom-to-top + o.insertBefore(oItem, o.firstChild); + + o = null; + // + + return true; + + }; + + // + // last-resort debugging option + if (wl.indexOf('sm2-debug=alert') !== -1) { + this._writeDebug = function(sText) { + window.alert(sText); + }; + } + // + + // alias + this._wD = this._writeDebug; + + /** + * Provides debug / state information on all SMSound objects. + */ + + this._debug = function() { + + // + var i, j; + _wDS('currentObj', 1); + + for (i = 0, j = sm2.soundIDs.length; i < j; i++) { + sm2.sounds[sm2.soundIDs[i]]._debug(); + } + // + + }; + + /** + * Restarts and re-initializes the SoundManager instance. + * + * @param {boolean} resetEvents Optional: When true, removes all registered onready and ontimeout event callbacks. + * @param {boolean} excludeInit Options: When true, does not call beginDelayedInit() (which would restart SM2). + * @return {object} soundManager The soundManager instance. + */ + + this.reboot = function(resetEvents, excludeInit) { + + // reset some (or all) state, and re-init unless otherwise specified. + + // + if (sm2.soundIDs.length) { + sm2._wD('Destroying ' + sm2.soundIDs.length + ' SMSound object' + (sm2.soundIDs.length !== 1 ? 's' : '') + '...'); + } + // + + var i, j, k; + + for (i = sm2.soundIDs.length-1; i >= 0; i--) { + sm2.sounds[sm2.soundIDs[i]].destruct(); + } + + // trash ze flash (remove from the DOM) + + if (flash) { + + try { + + if (isIE) { + oRemovedHTML = flash.innerHTML; + } + + oRemoved = flash.parentNode.removeChild(flash); + + } catch(e) { + + // Remove failed? May be due to flash blockers silently removing the SWF object/embed node from the DOM. Warn and continue. + + _wDS('badRemove', 2); + + } + + } + + // actually, force recreate of movie. + + oRemovedHTML = oRemoved = needsFlash = flash = null; + + sm2.enabled = didDCLoaded = didInit = waitingForEI = initPending = didAppend = appendSuccess = disabled = useGlobalHTML5Audio = sm2.swfLoaded = false; + + sm2.soundIDs = []; + sm2.sounds = {}; + + idCounter = 0; + + if (!resetEvents) { + // reset callbacks for onready, ontimeout etc. so that they will fire again on re-init + for (i in on_queue) { + if (on_queue.hasOwnProperty(i)) { + for (j = 0, k = on_queue[i].length; j < k; j++) { + on_queue[i][j].fired = false; + } + } + } + } else { + // remove all callbacks entirely + on_queue = []; + } + + // + if (!excludeInit) { + sm2._wD(sm + ': Rebooting...'); + } + // + + // reset HTML5 and flash canPlay test results + + sm2.html5 = { + 'usingFlash': null + }; + + sm2.flash = {}; + + // reset device-specific HTML/flash mode switches + + sm2.html5Only = false; + sm2.ignoreFlash = false; + + window.setTimeout(function() { + + preInit(); + + // by default, re-init + + if (!excludeInit) { + sm2.beginDelayedInit(); + } + + }, 20); + + return sm2; + + }; + + this.reset = function() { + + /** + * Shuts down and restores the SoundManager instance to its original loaded state, without an explicit reboot. All onready/ontimeout handlers are removed. + * After this call, SM2 may be re-initialized via soundManager.beginDelayedInit(). + * @return {object} soundManager The soundManager instance. + */ + + _wDS('reset'); + return sm2.reboot(true, true); + + }; + + /** + * Undocumented: Determines the SM2 flash movie's load progress. + * + * @return {number or null} Percent loaded, or if invalid/unsupported, null. + */ + + this.getMoviePercent = function() { + + /** + * Interesting syntax notes... + * Flash/ExternalInterface (ActiveX/NPAPI) bridge methods are not typeof "function" nor instanceof Function, but are still valid. + * Additionally, JSLint dislikes ('PercentLoaded' in flash)-style syntax and recommends hasOwnProperty(), which does not work in this case. + * Furthermore, using (flash && flash.PercentLoaded) causes IE to throw "object doesn't support this property or method". + * Thus, 'in' syntax must be used. + */ + + return (flash && 'PercentLoaded' in flash ? flash.PercentLoaded() : null); // Yes, JSLint. See nearby comment in source for explanation. + + }; + + /** + * Additional helper for manually invoking SM2's init process after DOM Ready / window.onload(). + */ + + this.beginDelayedInit = function() { + + windowLoaded = true; + domContentLoaded(); + + setTimeout(function() { + + if (initPending) { + return false; + } + + createMovie(); + initMovie(); + initPending = true; + + return true; + + }, 20); + + delayWaitForEI(); + + }; + + /** + * Destroys the SoundManager instance and all SMSound instances. + */ + + this.destruct = function() { + + sm2._wD(sm + '.destruct()'); + sm2.disable(true); + + }; + + /** + * SMSound() (sound object) constructor + * ------------------------------------ + * + * @param {object} oOptions Sound options (id and url are required attributes) + * @return {SMSound} The new SMSound object + */ + + SMSound = function(oOptions) { + + 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; + + lastHTML5State = { + // tracks duration + position (time) + duration: null, + time: null + }; + + this.id = oOptions.id; + + // legacy + this.sID = this.id; + + this.url = oOptions.url; + this.options = mixin(oOptions); + + // per-play-instance-specific options + this.instanceOptions = this.options; + + // short alias + this._iO = this.instanceOptions; + + // assign property defaults + this.pan = this.options.pan; + this.volume = this.options.volume; + + // whether or not this object is using HTML5 + this.isHTML5 = false; + + // internal HTML5 Audio() object reference + this._a = null; + + // for flash 8 special-case createSound() without url, followed by load/play with url case + urlOmitted = (this.url ? false : true); + + /** + * SMSound() public methods + * ------------------------ + */ + + this.id3 = {}; + + /** + * Writes SMSound object parameters to debug console + */ + + this._debug = function() { + + // + sm2._wD(s.id + ': Merged options:', s.options); + // + + }; + + /** + * Begins loading a sound per its *url*. + * + * @param {object} oOptions Optional: Sound options + * @return {SMSound} The SMSound object + */ + + this.load = function(oOptions) { + + var oSound = null, instanceOptions; + + if (oOptions !== _undefined) { + s._iO = mixin(oOptions, s.options); + } else { + oOptions = s.options; + s._iO = oOptions; + if (lastURL && lastURL !== s.url) { + _wDS('manURL'); + s._iO.url = s.url; + s.url = null; + } + } + + if (!s._iO.url) { + s._iO.url = s.url; + } + + s._iO.url = parseURL(s._iO.url); + + // ensure we're in sync + s.instanceOptions = s._iO; + + // local shortcut + instanceOptions = s._iO; + + sm2._wD(s.id + ': load (' + instanceOptions.url + ')'); + + if (!instanceOptions.url && !s.url) { + sm2._wD(s.id + ': load(): url is unassigned. Exiting.', 2); + return s; + } + + // + if (!s.isHTML5 && fV === 8 && !s.url && !instanceOptions.autoPlay) { + // flash 8 load() -> play() won't work before onload has fired. + sm2._wD(s.id + ': Flash 8 load() limitation: Wait for onload() before calling play().', 1); + } + // + + if (instanceOptions.url === s.url && s.readyState !== 0 && s.readyState !== 2) { + _wDS('onURL', 1); + // if loaded and an onload() exists, fire immediately. + if (s.readyState === 3 && instanceOptions.onload) { + // assume success based on truthy duration. + wrapCallback(s, function() { + instanceOptions.onload.apply(s, [(!!s.duration)]); + }); + } + return s; + } + + // reset a few state properties + + s.loaded = false; + s.readyState = 1; + s.playState = 0; + s.id3 = {}; + + // TODO: If switching from HTML5 -> flash (or vice versa), stop currently-playing audio. + + if (html5OK(instanceOptions)) { + + oSound = s._setup_html5(instanceOptions); + + if (!oSound._called_load) { + + s._html5_canplay = false; + + // TODO: review called_load / html5_canplay logic + + // if url provided directly to load(), assign it here. + + if (s.url !== instanceOptions.url) { + + sm2._wD(_wDS('manURL') + ': ' + instanceOptions.url); + + s._a.src = instanceOptions.url; + + // TODO: review / re-apply all relevant options (volume, loop, onposition etc.) + + // reset position for new URL + s.setPosition(0); + + } + + // given explicit load call, try to preload. + + // early HTML5 implementation (non-standard) + s._a.autobuffer = 'auto'; + + // standard property, values: none / metadata / auto + // reference: http://msdn.microsoft.com/en-us/library/ie/ff974759%28v=vs.85%29.aspx + s._a.preload = 'auto'; + + s._a._called_load = true; + + } else { + + sm2._wD(s.id + ': Ignoring request to load again'); + + } + + } else { + + if (sm2.html5Only) { + sm2._wD(s.id + ': No flash support. Exiting.'); + return s; + } + + if (s._iO.url && s._iO.url.match(/data\:/i)) { + // data: URIs not supported by Flash, either. + sm2._wD(s.id + ': data: URIs not supported via Flash. Exiting.'); + return s; + } + + try { + s.isHTML5 = false; + s._iO = policyFix(loopFix(instanceOptions)); + // re-assign local shortcut + instanceOptions = s._iO; + if (fV === 8) { + flash._load(s.id, instanceOptions.url, instanceOptions.stream, instanceOptions.autoPlay, instanceOptions.usePolicyFile); + } else { + flash._load(s.id, instanceOptions.url, !!(instanceOptions.stream), !!(instanceOptions.autoPlay), instanceOptions.loops||1, !!(instanceOptions.autoLoad), instanceOptions.usePolicyFile); + } + } catch(e) { + _wDS('smError', 2); + debugTS('onload', false); + catchError({type:'SMSOUND_LOAD_JS_EXCEPTION', fatal:true}); + } + + } + + // after all of this, ensure sound url is up to date. + s.url = instanceOptions.url; + + return s; + + }; + + /** + * Unloads a sound, canceling any open HTTP requests. + * + * @return {SMSound} The SMSound object + */ + + this.unload = function() { + + // Flash 8/AS2 can't "close" a stream - fake it by loading an empty URL + // Flash 9/AS3: Close stream, preventing further load + // HTML5: Most UAs will use empty URL + + if (s.readyState !== 0) { + + sm2._wD(s.id + ': unload()'); + + if (!s.isHTML5) { + + if (fV === 8) { + flash._unload(s.id, emptyURL); + } else { + flash._unload(s.id); + } + + } else { + + stop_html5_timer(); + + if (s._a) { + + s._a.pause(); + + // update empty URL, too + lastURL = html5Unload(s._a); + + } + + } + + // reset load/status flags + resetProperties(); + + } + + return s; + + }; + + /** + * Unloads and destroys a sound. + */ + + this.destruct = function(_bFromSM) { + + sm2._wD(s.id + ': Destruct'); + + if (!s.isHTML5) { + + // kill sound within Flash + // Disable the onfailure handler + s._iO.onfailure = null; + flash._destroySound(s.id); + + } else { + + stop_html5_timer(); + + if (s._a) { + s._a.pause(); + html5Unload(s._a); + if (!useGlobalHTML5Audio) { + remove_html5_events(); + } + // break obvious circular reference + s._a._s = null; + s._a = null; + } + + } + + if (!_bFromSM) { + // ensure deletion from controller + sm2.destroySound(s.id, true); + } + + }; + + /** + * Begins playing a sound. + * + * @param {object} oOptions Optional: Sound options + * @return {SMSound} The SMSound object + */ + + this.play = function(oOptions, _updatePlayState) { + + var fN, allowMulti, a, onready, + audioClone, onended, oncanplay, + startOK = true, + exit = null; + + // + fN = s.id + ': play(): '; + // + + // default to true + _updatePlayState = (_updatePlayState === _undefined ? true : _updatePlayState); + + if (!oOptions) { + oOptions = {}; + } + + // first, use local URL (if specified) + if (s.url) { + s._iO.url = s.url; + } + + // mix in any options defined at createSound() + s._iO = mixin(s._iO, s.options); + + // mix in any options specific to this method + s._iO = mixin(oOptions, s._iO); + + s._iO.url = parseURL(s._iO.url); + + s.instanceOptions = s._iO; + + // RTMP-only + if (!s.isHTML5 && s._iO.serverURL && !s.connected) { + if (!s.getAutoPlay()) { + sm2._wD(fN +' Netstream not connected yet - setting autoPlay'); + s.setAutoPlay(true); + } + // play will be called in onconnect() + return s; + } + + if (html5OK(s._iO)) { + s._setup_html5(s._iO); + start_html5_timer(); + } + + if (s.playState === 1 && !s.paused) { + allowMulti = s._iO.multiShot; + if (!allowMulti) { + sm2._wD(fN + 'Already playing (one-shot)', 1); + if (s.isHTML5) { + // go back to original position. + s.setPosition(s._iO.position); + } + exit = s; + } else { + sm2._wD(fN + 'Already playing (multi-shot)', 1); + } + } + + if (exit !== null) { + return exit; + } + + // edge case: play() with explicit URL parameter + if (oOptions.url && oOptions.url !== s.url) { + + // special case for createSound() followed by load() / play() with url; avoid double-load case. + if (!s.readyState && !s.isHTML5 && fV === 8 && urlOmitted) { + + urlOmitted = false; + + } else { + + // load using merged options + s.load(s._iO); + + } + + } + + if (!s.loaded) { + + if (s.readyState === 0) { + + sm2._wD(fN + 'Attempting to load'); + + // try to get this sound playing ASAP + if (!s.isHTML5 && !sm2.html5Only) { + + // flash: assign directly because setAutoPlay() increments the instanceCount + s._iO.autoPlay = true; + s.load(s._iO); + + } else if (s.isHTML5) { + + // iOS needs this when recycling sounds, loading a new URL on an existing object. + s.load(s._iO); + + } else { + + sm2._wD(fN + 'Unsupported type. Exiting.'); + exit = s; + + } + + // HTML5 hack - re-set instanceOptions? + s.instanceOptions = s._iO; + + } else if (s.readyState === 2) { + + sm2._wD(fN + 'Could not load - exiting', 2); + exit = s; + + } else { + + sm2._wD(fN + 'Loading - attempting to play...'); + + } + + } else { + + // "play()" + sm2._wD(fN.substr(0, fN.lastIndexOf(':'))); + + } + + if (exit !== null) { + return exit; + } + + if (!s.isHTML5 && fV === 9 && s.position > 0 && s.position === s.duration) { + // flash 9 needs a position reset if play() is called while at the end of a sound. + sm2._wD(fN + 'Sound at end, resetting to position:0'); + oOptions.position = 0; + } + + /** + * Streams will pause when their buffer is full if they are being loaded. + * In this case paused is true, but the song hasn't started playing yet. + * If we just call resume() the onplay() callback will never be called. + * So only call resume() if the position is > 0. + * Another reason is because options like volume won't have been applied yet. + * For normal sounds, just resume. + */ + + if (s.paused && s.position >= 0 && (!s._iO.serverURL || s.position > 0)) { + + // https://gist.github.com/37b17df75cc4d7a90bf6 + sm2._wD(fN + 'Resuming from paused state', 1); + s.resume(); + + } else { + + s._iO = mixin(oOptions, s._iO); + + // apply from/to parameters, if they exist (and not using RTMP) + if (s._iO.from !== null && s._iO.to !== null && s.instanceCount === 0 && s.playState === 0 && !s._iO.serverURL) { + + onready = function() { + // sound "canplay" or onload() + // re-apply from/to to instance options, and start playback + s._iO = mixin(oOptions, s._iO); + s.play(s._iO); + }; + + // HTML5 needs to at least have "canplay" fired before seeking. + if (s.isHTML5 && !s._html5_canplay) { + + // this hasn't been loaded yet. load it first, and then do this again. + sm2._wD(fN + 'Beginning load for from/to case'); + + s.load({ + // note: custom HTML5-only event added for from/to implementation. + _oncanplay: onready + }); + + exit = false; + + } else if (!s.isHTML5 && !s.loaded && (!s.readyState || s.readyState !== 2)) { + + // to be safe, preload the whole thing in Flash. + + sm2._wD(fN + 'Preloading for from/to case'); + + s.load({ + onload: onready + }); + + exit = false; + + } + + if (exit !== null) { + return exit; + } + + // otherwise, we're ready to go. re-apply local options, and continue + + s._iO = applyFromTo(); + + } + + // sm2._wD(fN + 'Starting to play'); + + // increment instance counter, where enabled + supported + if (!s.instanceCount || s._iO.multiShotEvents || (s.isHTML5 && s._iO.multiShot && !useGlobalHTML5Audio) || (!s.isHTML5 && fV > 8 && !s.getAutoPlay())) { + s.instanceCount++; + } + + // if first play and onposition parameters exist, apply them now + if (s._iO.onposition && s.playState === 0) { + attachOnPosition(s); + } + + s.playState = 1; + s.paused = false; + + s.position = (s._iO.position !== _undefined && !isNaN(s._iO.position) ? s._iO.position : 0); + + if (!s.isHTML5) { + s._iO = policyFix(loopFix(s._iO)); + } + + if (s._iO.onplay && _updatePlayState) { + s._iO.onplay.apply(s); + onplay_called = true; + } + + s.setVolume(s._iO.volume, true); + s.setPan(s._iO.pan, true); + + if (!s.isHTML5) { + + startOK = flash._start(s.id, s._iO.loops || 1, (fV === 9 ? s.position : s.position / msecScale), s._iO.multiShot || false); + + if (fV === 9 && !startOK) { + // edge case: no sound hardware, or 32-channel flash ceiling hit. + // applies only to Flash 9, non-NetStream/MovieStar sounds. + // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html#play%28%29 + sm2._wD(fN + 'No sound hardware, or 32-sound ceiling hit', 2); + if (s._iO.onplayerror) { + s._iO.onplayerror.apply(s); + } + + } + + } else { + + if (s.instanceCount < 2) { + + // HTML5 single-instance case + + start_html5_timer(); + + a = s._setup_html5(); + + s.setPosition(s._iO.position); + + a.play(); + + } else { + + // HTML5 multi-shot case + + sm2._wD(s.id + ': Cloning Audio() for instance #' + s.instanceCount + '...'); + + audioClone = new Audio(s._iO.url); + + onended = function() { + event.remove(audioClone, 'ended', onended); + s._onfinish(s); + // cleanup + html5Unload(audioClone); + audioClone = null; + }; + + oncanplay = function() { + event.remove(audioClone, 'canplay', oncanplay); + try { + audioClone.currentTime = s._iO.position/msecScale; + } catch(err) { + complain(s.id + ': multiShot play() failed to apply position of ' + (s._iO.position/msecScale)); + } + audioClone.play(); + }; + + event.add(audioClone, 'ended', onended); + + // apply volume to clones, too + if (s._iO.volume !== undefined) { + audioClone.volume = Math.max(0, Math.min(1, s._iO.volume/100)); + } + + // playing multiple muted sounds? if you do this, you're weird ;) - but let's cover it. + if (s.muted) { + audioClone.muted = true; + } + + if (s._iO.position) { + // HTML5 audio can't seek before onplay() event has fired. + // wait for canplay, then seek to position and start playback. + event.add(audioClone, 'canplay', oncanplay); + } else { + // begin playback at currentTime: 0 + audioClone.play(); + } + + } + + } + + } + + return s; + + }; + + // just for convenience + this.start = this.play; + + /** + * Stops playing a sound (and optionally, all sounds) + * + * @param {boolean} bAll Optional: Whether to stop all sounds + * @return {SMSound} The SMSound object + */ + + this.stop = function(bAll) { + + var instanceOptions = s._iO, + originalPosition; + + if (s.playState === 1) { + + sm2._wD(s.id + ': stop()'); + + s._onbufferchange(0); + s._resetOnPosition(0); + s.paused = false; + + if (!s.isHTML5) { + s.playState = 0; + } + + // remove onPosition listeners, if any + detachOnPosition(); + + // and "to" position, if set + if (instanceOptions.to) { + s.clearOnPosition(instanceOptions.to); + } + + if (!s.isHTML5) { + + flash._stop(s.id, bAll); + + // hack for netStream: just unload + if (instanceOptions.serverURL) { + s.unload(); + } + + } else { + + if (s._a) { + + originalPosition = s.position; + + // act like Flash, though + s.setPosition(0); + + // hack: reflect old position for onstop() (also like Flash) + s.position = originalPosition; + + // html5 has no stop() + // NOTE: pausing means iOS requires interaction to resume. + s._a.pause(); + + s.playState = 0; + + // and update UI + s._onTimer(); + + stop_html5_timer(); + + } + + } + + s.instanceCount = 0; + s._iO = {}; + + if (instanceOptions.onstop) { + instanceOptions.onstop.apply(s); + } + + } + + return s; + + }; + + /** + * Undocumented/internal: Sets autoPlay for RTMP. + * + * @param {boolean} autoPlay state + */ + + this.setAutoPlay = function(autoPlay) { + + sm2._wD(s.id + ': Autoplay turned ' + (autoPlay ? 'on' : 'off')); + s._iO.autoPlay = autoPlay; + + if (!s.isHTML5) { + flash._setAutoPlay(s.id, autoPlay); + if (autoPlay) { + // only increment the instanceCount if the sound isn't loaded (TODO: verify RTMP) + if (!s.instanceCount && s.readyState === 1) { + s.instanceCount++; + sm2._wD(s.id + ': Incremented instance count to '+s.instanceCount); + } + } + } + + }; + + /** + * Undocumented/internal: Returns the autoPlay boolean. + * + * @return {boolean} The current autoPlay value + */ + + this.getAutoPlay = function() { + + return s._iO.autoPlay; + + }; + + /** + * Sets the position of a sound. + * + * @param {number} nMsecOffset Position (milliseconds) + * @return {SMSound} The SMSound object + */ + + this.setPosition = function(nMsecOffset) { + + if (nMsecOffset === _undefined) { + nMsecOffset = 0; + } + + var position, position1K, + // Use the duration from the instance options, if we don't have a track duration yet. + // position >= 0 and <= current available (loaded) duration + offset = (s.isHTML5 ? Math.max(nMsecOffset, 0) : Math.min(s.duration || s._iO.duration, Math.max(nMsecOffset, 0))); + + s.position = offset; + position1K = s.position/msecScale; + s._resetOnPosition(s.position); + s._iO.position = offset; + + if (!s.isHTML5) { + + position = (fV === 9 ? s.position : position1K); + + if (s.readyState && s.readyState !== 2) { + // if paused or not playing, will not resume (by playing) + flash._setPosition(s.id, position, (s.paused || !s.playState), s._iO.multiShot); + } + + } else if (s._a) { + + // Set the position in the canplay handler if the sound is not ready yet + if (s._html5_canplay) { + + if (s._a.currentTime !== position1K) { + + /** + * DOM/JS errors/exceptions to watch out for: + * if seek is beyond (loaded?) position, "DOM exception 11" + * "INDEX_SIZE_ERR": DOM exception 1 + */ + sm2._wD(s.id + ': setPosition('+position1K+')'); + + try { + s._a.currentTime = position1K; + if (s.playState === 0 || s.paused) { + // allow seek without auto-play/resume + s._a.pause(); + } + } catch(e) { + sm2._wD(s.id + ': setPosition(' + position1K + ') failed: ' + e.message, 2); + } + + } + + } else if (position1K) { + + // warn on non-zero seek attempts + sm2._wD(s.id + ': setPosition(' + position1K + '): Cannot seek yet, sound not ready', 2); + return s; + + } + + if (s.paused) { + + // if paused, refresh UI right away + // force update + s._onTimer(true); + + } + + } + + return s; + + }; + + /** + * Pauses sound playback. + * + * @return {SMSound} The SMSound object + */ + + this.pause = function(_bCallFlash) { + + if (s.paused || (s.playState === 0 && s.readyState !== 1)) { + return s; + } + + sm2._wD(s.id + ': pause()'); + s.paused = true; + + if (!s.isHTML5) { + if (_bCallFlash || _bCallFlash === _undefined) { + flash._pause(s.id, s._iO.multiShot); + } + } else { + s._setup_html5().pause(); + stop_html5_timer(); + } + + if (s._iO.onpause) { + s._iO.onpause.apply(s); + } + + return s; + + }; + + /** + * Resumes sound playback. + * + * @return {SMSound} The SMSound object + */ + + /** + * When auto-loaded streams pause on buffer full they have a playState of 0. + * We need to make sure that the playState is set to 1 when these streams "resume". + * When a paused stream is resumed, we need to trigger the onplay() callback if it + * hasn't been called already. In this case since the sound is being played for the + * first time, I think it's more appropriate to call onplay() rather than onresume(). + */ + + this.resume = function() { + + var instanceOptions = s._iO; + + if (!s.paused) { + return s; + } + + sm2._wD(s.id + ': resume()'); + s.paused = false; + s.playState = 1; + + if (!s.isHTML5) { + if (instanceOptions.isMovieStar && !instanceOptions.serverURL) { + // Bizarre Webkit bug (Chrome reported via 8tracks.com dudes): AAC content paused for 30+ seconds(?) will not resume without a reposition. + s.setPosition(s.position); + } + // flash method is toggle-based (pause/resume) + flash._pause(s.id, instanceOptions.multiShot); + } else { + s._setup_html5().play(); + start_html5_timer(); + } + + if (!onplay_called && instanceOptions.onplay) { + instanceOptions.onplay.apply(s); + onplay_called = true; + } else if (instanceOptions.onresume) { + instanceOptions.onresume.apply(s); + } + + return s; + + }; + + /** + * Toggles sound playback. + * + * @return {SMSound} The SMSound object + */ + + this.togglePause = function() { + + sm2._wD(s.id + ': togglePause()'); + + if (s.playState === 0) { + s.play({ + position: (fV === 9 && !s.isHTML5 ? s.position : s.position / msecScale) + }); + return s; + } + + if (s.paused) { + s.resume(); + } else { + s.pause(); + } + + return s; + + }; + + /** + * Sets the panning (L-R) effect. + * + * @param {number} nPan The pan value (-100 to 100) + * @return {SMSound} The SMSound object + */ + + this.setPan = function(nPan, bInstanceOnly) { + + if (nPan === _undefined) { + nPan = 0; + } + + if (bInstanceOnly === _undefined) { + bInstanceOnly = false; + } + + if (!s.isHTML5) { + flash._setPan(s.id, nPan); + } // else { no HTML5 pan? } + + s._iO.pan = nPan; + + if (!bInstanceOnly) { + s.pan = nPan; + s.options.pan = nPan; + } + + return s; + + }; + + /** + * Sets the volume. + * + * @param {number} nVol The volume value (0 to 100) + * @return {SMSound} The SMSound object + */ + + this.setVolume = function(nVol, _bInstanceOnly) { + + /** + * Note: Setting volume has no effect on iOS "special snowflake" devices. + * Hardware volume control overrides software, and volume + * will always return 1 per Apple docs. (iOS 4 + 5.) + * http://developer.apple.com/library/safari/documentation/AudioVideo/Conceptual/HTML-canvas-guide/AddingSoundtoCanvasAnimations/AddingSoundtoCanvasAnimations.html + */ + + if (nVol === _undefined) { + nVol = 100; + } + + if (_bInstanceOnly === _undefined) { + _bInstanceOnly = false; + } + + if (!s.isHTML5) { + flash._setVolume(s.id, (sm2.muted && !s.muted) || s.muted?0:nVol); + } else if (s._a) { + if (sm2.muted && !s.muted) { + s.muted = true; + s._a.muted = true; + } + // valid range: 0-1 + s._a.volume = Math.max(0, Math.min(1, nVol/100)); + } + + s._iO.volume = nVol; + + if (!_bInstanceOnly) { + s.volume = nVol; + s.options.volume = nVol; + } + + return s; + + }; + + /** + * Mutes the sound. + * + * @return {SMSound} The SMSound object + */ + + this.mute = function() { + + s.muted = true; + + if (!s.isHTML5) { + flash._setVolume(s.id, 0); + } else if (s._a) { + s._a.muted = true; + } + + return s; + + }; + + /** + * Unmutes the sound. + * + * @return {SMSound} The SMSound object + */ + + this.unmute = function() { + + s.muted = false; + var hasIO = (s._iO.volume !== _undefined); + + if (!s.isHTML5) { + flash._setVolume(s.id, hasIO?s._iO.volume:s.options.volume); + } else if (s._a) { + s._a.muted = false; + } + + return s; + + }; + + /** + * Toggles the muted state of a sound. + * + * @return {SMSound} The SMSound object + */ + + this.toggleMute = function() { + + return (s.muted?s.unmute():s.mute()); + + }; + + /** + * Registers a callback to be fired when a sound reaches a given position during playback. + * + * @param {number} nPosition The position to watch for + * @param {function} oMethod The relevant callback to fire + * @param {object} oScope Optional: The scope to apply the callback to + * @return {SMSound} The SMSound object + */ + + this.onPosition = function(nPosition, oMethod, oScope) { + + // TODO: basic dupe checking? + + onPositionItems.push({ + position: parseInt(nPosition, 10), + method: oMethod, + scope: (oScope !== _undefined ? oScope : s), + fired: false + }); + + return s; + + }; + + // legacy/backwards-compability: lower-case method name + this.onposition = this.onPosition; + + /** + * Removes registered callback(s) from a sound, by position and/or callback. + * + * @param {number} nPosition The position to clear callback(s) for + * @param {function} oMethod Optional: Identify one callback to be removed when multiple listeners exist for one position + * @return {SMSound} The SMSound object + */ + + this.clearOnPosition = function(nPosition, oMethod) { + + var i; + + nPosition = parseInt(nPosition, 10); + + if (isNaN(nPosition)) { + // safety check + return false; + } + + for (i=0; i < onPositionItems.length; i++) { + + if (nPosition === onPositionItems[i].position) { + // remove this item if no method was specified, or, if the method matches + if (!oMethod || (oMethod === onPositionItems[i].method)) { + if (onPositionItems[i].fired) { + // decrement "fired" counter, too + onPositionFired--; + } + onPositionItems.splice(i, 1); + } + } + + } + + }; + + this._processOnPosition = function() { + + var i, item, j = onPositionItems.length; + + if (!j || !s.playState || onPositionFired >= j) { + return false; + } + + for (i=j-1; i >= 0; i--) { + item = onPositionItems[i]; + if (!item.fired && s.position >= item.position) { + item.fired = true; + onPositionFired++; + item.method.apply(item.scope, [item.position]); + j = onPositionItems.length; // reset j -- onPositionItems.length can be changed in the item callback above... occasionally breaking the loop. + } + } + + return true; + + }; + + this._resetOnPosition = function(nPosition) { + + // reset "fired" for items interested in this position + var i, item, j = onPositionItems.length; + + if (!j) { + return false; + } + + for (i=j-1; i >= 0; i--) { + item = onPositionItems[i]; + if (item.fired && nPosition <= item.position) { + item.fired = false; + onPositionFired--; + } + } + + return true; + + }; + + /** + * SMSound() private internals + * -------------------------------- + */ + + applyFromTo = function() { + + var instanceOptions = s._iO, + f = instanceOptions.from, + t = instanceOptions.to, + start, end; + + end = function() { + + // end has been reached. + sm2._wD(s.id + ': "To" time of ' + t + ' reached.'); + + // detach listener + s.clearOnPosition(t, end); + + // stop should clear this, too + s.stop(); + + }; + + start = function() { + + sm2._wD(s.id + ': Playing "from" ' + f); + + // add listener for end + if (t !== null && !isNaN(t)) { + s.onPosition(t, end); + } + + }; + + if (f !== null && !isNaN(f)) { + + // apply to instance options, guaranteeing correct start position. + instanceOptions.position = f; + + // multiShot timing can't be tracked, so prevent that. + instanceOptions.multiShot = false; + + start(); + + } + + // return updated instanceOptions including starting position + return instanceOptions; + + }; + + attachOnPosition = function() { + + var item, + op = s._iO.onposition; + + // attach onposition things, if any, now. + + if (op) { + + for (item in op) { + if (op.hasOwnProperty(item)) { + s.onPosition(parseInt(item, 10), op[item]); + } + } + + } + + }; + + detachOnPosition = function() { + + var item, + op = s._iO.onposition; + + // detach any onposition()-style listeners. + + if (op) { + + for (item in op) { + if (op.hasOwnProperty(item)) { + s.clearOnPosition(parseInt(item, 10)); + } + } + + } + + }; + + start_html5_timer = function() { + + if (s.isHTML5) { + startTimer(s); + } + + }; + + stop_html5_timer = function() { + + if (s.isHTML5) { + stopTimer(s); + } + + }; + + resetProperties = function(retainPosition) { + + if (!retainPosition) { + onPositionItems = []; + onPositionFired = 0; + } + + onplay_called = false; + + s._hasTimer = null; + s._a = null; + s._html5_canplay = false; + s.bytesLoaded = null; + s.bytesTotal = null; + s.duration = (s._iO && s._iO.duration ? s._iO.duration : null); + s.durationEstimate = null; + s.buffered = []; + + // legacy: 1D array + s.eqData = []; + + s.eqData.left = []; + s.eqData.right = []; + + s.failures = 0; + s.isBuffering = false; + s.instanceOptions = {}; + s.instanceCount = 0; + s.loaded = false; + s.metadata = {}; + + // 0 = uninitialised, 1 = loading, 2 = failed/error, 3 = loaded/success + s.readyState = 0; + + s.muted = false; + s.paused = false; + + s.peakData = { + left: 0, + right: 0 + }; + + s.waveformData = { + left: [], + right: [] + }; + + s.playState = 0; + s.position = null; + + s.id3 = {}; + + }; + + resetProperties(); + + /** + * Pseudo-private SMSound internals + * -------------------------------- + */ + + this._onTimer = function(bForce) { + + /** + * HTML5-only _whileplaying() etc. + * called from both HTML5 native events, and polling/interval-based timers + * mimics flash and fires only when time/duration change, so as to be polling-friendly + */ + + var duration, isNew = false, time, x = {}; + + if (s._hasTimer || bForce) { + + // TODO: May not need to track readyState (1 = loading) + + if (s._a && (bForce || ((s.playState > 0 || s.readyState === 1) && !s.paused))) { + + duration = s._get_html5_duration(); + + if (duration !== lastHTML5State.duration) { + + lastHTML5State.duration = duration; + s.duration = duration; + isNew = true; + + } + + // TODO: investigate why this goes wack if not set/re-set each time. + s.durationEstimate = s.duration; + + time = (s._a.currentTime * msecScale || 0); + + if (time !== lastHTML5State.time) { + + lastHTML5State.time = time; + isNew = true; + + } + + if (isNew || bForce) { + + s._whileplaying(time,x,x,x,x); + + } + + }/* else { + + // sm2._wD('_onTimer: Warn for "'+s.id+'": '+(!s._a?'Could not find element. ':'')+(s.playState === 0?'playState bad, 0?':'playState = '+s.playState+', OK')); + + return false; + + }*/ + + return isNew; + + } + + }; + + this._get_html5_duration = function() { + + var instanceOptions = s._iO, + // if audio object exists, use its duration - else, instance option duration (if provided - it's a hack, really, and should be retired) OR null + d = (s._a && s._a.duration ? s._a.duration*msecScale : (instanceOptions && instanceOptions.duration ? instanceOptions.duration : null)), + result = (d && !isNaN(d) && d !== Infinity ? d : null); + + return result; + + }; + + this._apply_loop = function(a, nLoops) { + + /** + * boolean instead of "loop", for webkit? - spec says string. http://www.w3.org/TR/html-markup/audio.html#audio.attrs.loop + * note that loop is either off or infinite under HTML5, unlike Flash which allows arbitrary loop counts to be specified. + */ + + // + if (!a.loop && nLoops > 1) { + sm2._wD('Note: Native HTML5 looping is infinite.', 1); + } + // + + a.loop = (nLoops > 1 ? 'loop' : ''); + + }; + + this._setup_html5 = function(oOptions) { + + var instanceOptions = mixin(s._iO, oOptions), + a = useGlobalHTML5Audio ? globalHTML5Audio : s._a, + dURL = decodeURI(instanceOptions.url), + sameURL; + + /** + * "First things first, I, Poppa..." (reset the previous state of the old sound, if playing) + * Fixes case with devices that can only play one sound at a time + * Otherwise, other sounds in mid-play will be terminated without warning and in a stuck state + */ + + if (useGlobalHTML5Audio) { + + if (dURL === decodeURI(lastGlobalHTML5URL)) { + // global HTML5 audio: re-use of URL + sameURL = true; + } + + } else if (dURL === decodeURI(lastURL)) { + + // options URL is the same as the "last" URL, and we used (loaded) it + sameURL = true; + + } + + if (a) { + + if (a._s) { + + if (useGlobalHTML5Audio) { + + if (a._s && a._s.playState && !sameURL) { + + // global HTML5 audio case, and loading a new URL. stop the currently-playing one. + a._s.stop(); + + } + + } else if (!useGlobalHTML5Audio && dURL === decodeURI(lastURL)) { + + // non-global HTML5 reuse case: same url, ignore request + s._apply_loop(a, instanceOptions.loops); + + return a; + + } + + } + + if (!sameURL) { + + // don't retain onPosition() stuff with new URLs. + + if (lastURL) { + resetProperties(false); + } + + // assign new HTML5 URL + + a.src = instanceOptions.url; + + s.url = instanceOptions.url; + + lastURL = instanceOptions.url; + + lastGlobalHTML5URL = instanceOptions.url; + + a._called_load = false; + + } + + } else { + + if (instanceOptions.autoLoad || instanceOptions.autoPlay) { + + s._a = new Audio(instanceOptions.url); + s._a.load(); + + } else { + + // null for stupid Opera 9.64 case + s._a = (isOpera && opera.version() < 10 ? new Audio(null) : new Audio()); + + } + + // assign local reference + a = s._a; + + a._called_load = false; + + if (useGlobalHTML5Audio) { + + globalHTML5Audio = a; + + } + + } + + s.isHTML5 = true; + + // store a ref on the track + s._a = a; + + // store a ref on the audio + a._s = s; + + add_html5_events(); + + s._apply_loop(a, instanceOptions.loops); + + if (instanceOptions.autoLoad || instanceOptions.autoPlay) { + + s.load(); + + } else { + + // early HTML5 implementation (non-standard) + a.autobuffer = false; + + // standard ('none' is also an option.) + a.preload = 'auto'; + + } + + return a; + + }; + + add_html5_events = function() { + + if (s._a._added_events) { + return false; + } + + var f; + + function add(oEvt, oFn, bCapture) { + return s._a ? s._a.addEventListener(oEvt, oFn, bCapture||false) : null; + } + + s._a._added_events = true; + + for (f in html5_events) { + if (html5_events.hasOwnProperty(f)) { + add(f, html5_events[f]); + } + } + + return true; + + }; + + remove_html5_events = function() { + + // Remove event listeners + + var f; + + function remove(oEvt, oFn, bCapture) { + return (s._a ? s._a.removeEventListener(oEvt, oFn, bCapture||false) : null); + } + + sm2._wD(s.id + ': Removing event listeners'); + s._a._added_events = false; + + for (f in html5_events) { + if (html5_events.hasOwnProperty(f)) { + remove(f, html5_events[f]); + } + } + + }; + + /** + * Pseudo-private event internals + * ------------------------------ + */ + + this._onload = function(nSuccess) { + + var fN, + // check for duration to prevent false positives from flash 8 when loading from cache. + loadOK = !!nSuccess || (!s.isHTML5 && fV === 8 && s.duration); + + // + fN = s.id + ': '; + sm2._wD(fN + (loadOK ? 'onload()' : 'Failed to load / invalid sound?' + (!s.duration ? ' Zero-length duration reported.' : ' -') + ' (' + s.url + ')'), (loadOK ? 1 : 2)); + if (!loadOK && !s.isHTML5) { + if (sm2.sandbox.noRemote === true) { + sm2._wD(fN + str('noNet'), 1); + } + if (sm2.sandbox.noLocal === true) { + sm2._wD(fN + str('noLocal'), 1); + } + } + // + + s.loaded = loadOK; + s.readyState = loadOK?3:2; + s._onbufferchange(0); + + if (s._iO.onload) { + wrapCallback(s, function() { + s._iO.onload.apply(s, [loadOK]); + }); + } + + return true; + + }; + + this._onbufferchange = function(nIsBuffering) { + + if (s.playState === 0) { + // ignore if not playing + return false; + } + + if ((nIsBuffering && s.isBuffering) || (!nIsBuffering && !s.isBuffering)) { + return false; + } + + s.isBuffering = (nIsBuffering === 1); + if (s._iO.onbufferchange) { + sm2._wD(s.id + ': Buffer state change: ' + nIsBuffering); + s._iO.onbufferchange.apply(s); + } + + return true; + + }; + + /** + * Playback may have stopped due to buffering, or related reason. + * This state can be encountered on iOS < 6 when auto-play is blocked. + */ + + this._onsuspend = function() { + + if (s._iO.onsuspend) { + sm2._wD(s.id + ': Playback suspended'); + s._iO.onsuspend.apply(s); + } + + return true; + + }; + + /** + * flash 9/movieStar + RTMP-only method, should fire only once at most + * at this point we just recreate failed sounds rather than trying to reconnect + */ + + this._onfailure = function(msg, level, code) { + + s.failures++; + sm2._wD(s.id + ': Failures = ' + s.failures); + + if (s._iO.onfailure && s.failures === 1) { + s._iO.onfailure(s, msg, level, code); + } else { + sm2._wD(s.id + ': Ignoring failure'); + } + + }; + + this._onfinish = function() { + + // store local copy before it gets trashed... + var io_onfinish = s._iO.onfinish; + + s._onbufferchange(0); + s._resetOnPosition(0); + + // reset some state items + if (s.instanceCount) { + + s.instanceCount--; + + if (!s.instanceCount) { + + // remove onPosition listeners, if any + detachOnPosition(); + + // reset instance options + s.playState = 0; + s.paused = false; + s.instanceCount = 0; + s.instanceOptions = {}; + s._iO = {}; + stop_html5_timer(); + + // reset position, too + if (s.isHTML5) { + s.position = 0; + } + + } + + if (!s.instanceCount || s._iO.multiShotEvents) { + // fire onfinish for last, or every instance + if (io_onfinish) { + sm2._wD(s.id + ': onfinish()'); + wrapCallback(s, function() { + io_onfinish.apply(s); + }); + } + } + + } + + }; + + this._whileloading = function(nBytesLoaded, nBytesTotal, nDuration, nBufferLength) { + + var instanceOptions = s._iO; + + s.bytesLoaded = nBytesLoaded; + s.bytesTotal = nBytesTotal; + s.duration = Math.floor(nDuration); + s.bufferLength = nBufferLength; + + if (!s.isHTML5 && !instanceOptions.isMovieStar) { + + if (instanceOptions.duration) { + // use duration from options, if specified and larger. nobody should be specifying duration in options, actually, and it should be retired. + s.durationEstimate = (s.duration > instanceOptions.duration) ? s.duration : instanceOptions.duration; + } else { + s.durationEstimate = parseInt((s.bytesTotal / s.bytesLoaded) * s.duration, 10); + } + + } else { + + s.durationEstimate = s.duration; + + } + + // for flash, reflect sequential-load-style buffering + if (!s.isHTML5) { + s.buffered = [{ + 'start': 0, + 'end': s.duration + }]; + } + + // allow whileloading to fire even if "load" fired under HTML5, due to HTTP range/partials + if ((s.readyState !== 3 || s.isHTML5) && instanceOptions.whileloading) { + instanceOptions.whileloading.apply(s); + } + + }; + + this._whileplaying = function(nPosition, oPeakData, oWaveformDataLeft, oWaveformDataRight, oEQData) { + + var instanceOptions = s._iO, + eqLeft; + + if (isNaN(nPosition) || nPosition === null) { + // flash safety net + return false; + } + + // Safari HTML5 play() may return small -ve values when starting from position: 0, eg. -50.120396875. Unexpected/invalid per W3, I think. Normalize to 0. + s.position = Math.max(0, nPosition); + + s._processOnPosition(); + + if (!s.isHTML5 && fV > 8) { + + if (instanceOptions.usePeakData && oPeakData !== _undefined && oPeakData) { + s.peakData = { + left: oPeakData.leftPeak, + right: oPeakData.rightPeak + }; + } + + if (instanceOptions.useWaveformData && oWaveformDataLeft !== _undefined && oWaveformDataLeft) { + s.waveformData = { + left: oWaveformDataLeft.split(','), + right: oWaveformDataRight.split(',') + }; + } + + if (instanceOptions.useEQData) { + if (oEQData !== _undefined && oEQData && oEQData.leftEQ) { + eqLeft = oEQData.leftEQ.split(','); + s.eqData = eqLeft; + s.eqData.left = eqLeft; + if (oEQData.rightEQ !== _undefined && oEQData.rightEQ) { + s.eqData.right = oEQData.rightEQ.split(','); + } + } + } + + } + + if (s.playState === 1) { + + // special case/hack: ensure buffering is false if loading from cache (and not yet started) + if (!s.isHTML5 && fV === 8 && !s.position && s.isBuffering) { + s._onbufferchange(0); + } + + if (instanceOptions.whileplaying) { + // flash may call after actual finish + instanceOptions.whileplaying.apply(s); + } + + } + + return true; + + }; + + this._oncaptiondata = function(oData) { + + /** + * internal: flash 9 + NetStream (MovieStar/RTMP-only) feature + * + * @param {object} oData + */ + + sm2._wD(s.id + ': Caption data received.'); + + s.captiondata = oData; + + if (s._iO.oncaptiondata) { + s._iO.oncaptiondata.apply(s, [oData]); + } + + }; + + this._onmetadata = function(oMDProps, oMDData) { + + /** + * internal: flash 9 + NetStream (MovieStar/RTMP-only) feature + * RTMP may include song title, MovieStar content may include encoding info + * + * @param {array} oMDProps (names) + * @param {array} oMDData (values) + */ + + sm2._wD(s.id + ': Metadata received.'); + + var oData = {}, i, j; + + for (i = 0, j = oMDProps.length; i < j; i++) { + oData[oMDProps[i]] = oMDData[i]; + } + s.metadata = oData; + + if (s._iO.onmetadata) { + s._iO.onmetadata.apply(s); + } + + }; + + this._onid3 = function(oID3Props, oID3Data) { + + /** + * internal: flash 8 + flash 9 ID3 feature + * may include artist, song title etc. + * + * @param {array} oID3Props (names) + * @param {array} oID3Data (values) + */ + + sm2._wD(s.id + ': ID3 data received.'); + + var oData = [], i, j; + + for (i = 0, j = oID3Props.length; i < j; i++) { + oData[oID3Props[i]] = oID3Data[i]; + } + s.id3 = mixin(s.id3, oData); + + if (s._iO.onid3) { + s._iO.onid3.apply(s); + } + + }; + + // flash/RTMP-only + + this._onconnect = function(bSuccess) { + + bSuccess = (bSuccess === 1); + sm2._wD(s.id + ': ' + (bSuccess ? 'Connected.' : 'Failed to connect? - ' + s.url), (bSuccess ? 1 : 2)); + s.connected = bSuccess; + + if (bSuccess) { + + s.failures = 0; + + if (idCheck(s.id)) { + if (s.getAutoPlay()) { + // only update the play state if auto playing + s.play(_undefined, s.getAutoPlay()); + } else if (s._iO.autoLoad) { + s.load(); + } + } + + if (s._iO.onconnect) { + s._iO.onconnect.apply(s, [bSuccess]); + } + + } + + }; + + this._ondataerror = function(sError) { + + // flash 9 wave/eq data handler + // hack: called at start, and end from flash at/after onfinish() + if (s.playState > 0) { + sm2._wD(s.id + ': Data error: ' + sError); + if (s._iO.ondataerror) { + s._iO.ondataerror.apply(s); + } + } + + }; + + // + this._debug(); + // + + }; // SMSound() + + /** + * Private SoundManager internals + * ------------------------------ + */ + + getDocument = function() { + + return (doc.body || doc.getElementsByTagName('div')[0]); + + }; + + id = function(sID) { + + return doc.getElementById(sID); + + }; + + mixin = function(oMain, oAdd) { + + // non-destructive merge + var o1 = (oMain || {}), o2, o; + + // if unspecified, o2 is the default options object + o2 = (oAdd === _undefined ? sm2.defaultOptions : oAdd); + + for (o in o2) { + + if (o2.hasOwnProperty(o) && o1[o] === _undefined) { + + if (typeof o2[o] !== 'object' || o2[o] === null) { + + // assign directly + o1[o] = o2[o]; + + } else { + + // recurse through o2 + o1[o] = mixin(o1[o], o2[o]); + + } + + } + + } + + return o1; + + }; + + wrapCallback = function(oSound, callback) { + + /** + * 03/03/2013: Fix for Flash Player 11.6.602.171 + Flash 8 (flashVersion = 8) SWF issue + * setTimeout() fix for certain SMSound callbacks like onload() and onfinish(), where subsequent calls like play() and load() fail when Flash Player 11.6.602.171 is installed, and using soundManager with flashVersion = 8 (which is the default). + * Not sure of exact cause. Suspect race condition and/or invalid (NaN-style) position argument trickling down to the next JS -> Flash _start() call, in the play() case. + * Fix: setTimeout() to yield, plus safer null / NaN checking on position argument provided to Flash. + * https://getsatisfaction.com/schillmania/topics/recent_chrome_update_seems_to_have_broken_my_sm2_audio_player + */ + if (!oSound.isHTML5 && fV === 8) { + window.setTimeout(callback, 0); + } else { + callback(); + } + + }; + + // additional soundManager properties that soundManager.setup() will accept + + extraOptions = { + 'onready': 1, + 'ontimeout': 1, + 'defaultOptions': 1, + 'flash9Options': 1, + 'movieStarOptions': 1 + }; + + assign = function(o, oParent) { + + /** + * recursive assignment of properties, soundManager.setup() helper + * allows property assignment based on whitelist + */ + + var i, + result = true, + hasParent = (oParent !== _undefined), + setupOptions = sm2.setupOptions, + bonusOptions = extraOptions; + + // + + // if soundManager.setup() called, show accepted parameters. + + if (o === _undefined) { + + result = []; + + for (i in setupOptions) { + + if (setupOptions.hasOwnProperty(i)) { + result.push(i); + } + + } + + for (i in bonusOptions) { + + if (bonusOptions.hasOwnProperty(i)) { + + if (typeof sm2[i] === 'object') { + + result.push(i+': {...}'); + + } else if (sm2[i] instanceof Function) { + + result.push(i+': function() {...}'); + + } else { + + result.push(i); + + } + + } + + } + + sm2._wD(str('setup', result.join(', '))); + + return false; + + } + + // + + for (i in o) { + + if (o.hasOwnProperty(i)) { + + // if not an {object} we want to recurse through... + + if (typeof o[i] !== 'object' || o[i] === null || o[i] instanceof Array || o[i] instanceof RegExp) { + + // check "allowed" options + + if (hasParent && bonusOptions[oParent] !== _undefined) { + + // valid recursive / nested object option, eg., { defaultOptions: { volume: 50 } } + sm2[oParent][i] = o[i]; + + } else if (setupOptions[i] !== _undefined) { + + // special case: assign to setupOptions object, which soundManager property references + sm2.setupOptions[i] = o[i]; + + // assign directly to soundManager, too + sm2[i] = o[i]; + + } else if (bonusOptions[i] === _undefined) { + + // invalid or disallowed parameter. complain. + complain(str((sm2[i] === _undefined ? 'setupUndef' : 'setupError'), i), 2); + + result = false; + + } else { + + /** + * valid extraOptions (bonusOptions) parameter. + * is it a method, like onready/ontimeout? call it. + * multiple parameters should be in an array, eg. soundManager.setup({onready: [myHandler, myScope]}); + */ + + if (sm2[i] instanceof Function) { + + sm2[i].apply(sm2, (o[i] instanceof Array? o[i] : [o[i]])); + + } else { + + // good old-fashioned direct assignment + sm2[i] = o[i]; + + } + + } + + } else { + + // recursion case, eg., { defaultOptions: { ... } } + + if (bonusOptions[i] === _undefined) { + + // invalid or disallowed parameter. complain. + complain(str((sm2[i] === _undefined ? 'setupUndef' : 'setupError'), i), 2); + + result = false; + + } else { + + // recurse through object + return assign(o[i], i); + + } + + } + + } + + } + + return result; + + }; + + function preferFlashCheck(kind) { + + // whether flash should play a given type + return (sm2.preferFlash && hasFlash && !sm2.ignoreFlash && (sm2.flash[kind] !== _undefined && sm2.flash[kind])); + + } + + /** + * Internal DOM2-level event helpers + * --------------------------------- + */ + + event = (function() { + + // normalize event methods + var old = (window.attachEvent), + evt = { + add: (old?'attachEvent':'addEventListener'), + remove: (old?'detachEvent':'removeEventListener') + }; + + // normalize "on" event prefix, optional capture argument + function getArgs(oArgs) { + + var args = slice.call(oArgs), + len = args.length; + + if (old) { + // prefix + args[1] = 'on' + args[1]; + if (len > 3) { + // no capture + args.pop(); + } + } else if (len === 3) { + args.push(false); + } + + return args; + + } + + function apply(args, sType) { + + // normalize and call the event method, with the proper arguments + var element = args.shift(), + method = [evt[sType]]; + + if (old) { + // old IE can't do apply(). + element[method](args[0], args[1]); + } else { + element[method].apply(element, args); + } + + } + + function add() { + + apply(getArgs(arguments), 'add'); + + } + + function remove() { + + apply(getArgs(arguments), 'remove'); + + } + + return { + 'add': add, + 'remove': remove + }; + + }()); + + /** + * Internal HTML5 event handling + * ----------------------------- + */ + + function html5_event(oFn) { + + // wrap html5 event handlers so we don't call them on destroyed and/or unloaded sounds + + return function(e) { + + var s = this._s, + result; + + if (!s || !s._a) { + // + if (s && s.id) { + sm2._wD(s.id + ': Ignoring ' + e.type); + } else { + sm2._wD(h5 + 'Ignoring ' + e.type); + } + // + result = null; + } else { + result = oFn.call(this, e); + } + + return result; + + }; + + } + + html5_events = { + + // HTML5 event-name-to-handler map + + abort: html5_event(function() { + + sm2._wD(this._s.id + ': abort'); + + }), + + // enough has loaded to play + + canplay: html5_event(function() { + + var s = this._s, + position1K; + + if (s._html5_canplay) { + // this event has already fired. ignore. + return true; + } + + s._html5_canplay = true; + sm2._wD(s.id + ': canplay'); + s._onbufferchange(0); + + // position according to instance options + position1K = (s._iO.position !== _undefined && !isNaN(s._iO.position)?s._iO.position/msecScale:null); + + // set the position if position was set before the sound loaded + if (s.position && this.currentTime !== position1K) { + sm2._wD(s.id + ': canplay: Setting position to ' + position1K); + try { + this.currentTime = position1K; + } catch(ee) { + sm2._wD(s.id + ': canplay: Setting position of ' + position1K + ' failed: ' + ee.message, 2); + } + } + + // hack for HTML5 from/to case + if (s._iO._oncanplay) { + s._iO._oncanplay(); + } + + }), + + canplaythrough: html5_event(function() { + + var s = this._s; + + if (!s.loaded) { + s._onbufferchange(0); + s._whileloading(s.bytesLoaded, s.bytesTotal, s._get_html5_duration()); + s._onload(true); + } + + }), + + // TODO: Reserved for potential use + /* + emptied: html5_event(function() { + + sm2._wD(this._s.id + ': emptied'); + + }), + */ + + ended: html5_event(function() { + + var s = this._s; + + sm2._wD(s.id + ': ended'); + + s._onfinish(); + + }), + + error: html5_event(function() { + + sm2._wD(this._s.id + ': HTML5 error, code ' + this.error.code); + /** + * HTML5 error codes, per W3C + * Error 1: Client aborted download at user's request. + * Error 2: Network error after load started. + * Error 3: Decoding issue. + * Error 4: Media (audio file) not supported. + * Reference: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#error-codes + */ + // call load with error state? + this._s._onload(false); + + }), + + loadeddata: html5_event(function() { + + var s = this._s; + + sm2._wD(s.id + ': loadeddata'); + + // safari seems to nicely report progress events, eventually totalling 100% + if (!s._loaded && !isSafari) { + s.duration = s._get_html5_duration(); + } + + }), + + loadedmetadata: html5_event(function() { + + sm2._wD(this._s.id + ': loadedmetadata'); + + }), + + loadstart: html5_event(function() { + + sm2._wD(this._s.id + ': loadstart'); + // assume buffering at first + this._s._onbufferchange(1); + + }), + + play: html5_event(function() { + + // sm2._wD(this._s.id + ': play()'); + // once play starts, no buffering + this._s._onbufferchange(0); + + }), + + playing: html5_event(function() { + + sm2._wD(this._s.id + ': playing'); + // once play starts, no buffering + this._s._onbufferchange(0); + + }), + + progress: html5_event(function(e) { + + // note: can fire repeatedly after "loaded" event, due to use of HTTP range/partials + + var s = this._s, + i, j, progStr, buffered = 0, + isProgress = (e.type === 'progress'), + ranges = e.target.buffered, + // firefox 3.6 implements e.loaded/total (bytes) + loaded = (e.loaded||0), + total = (e.total||1); + + // reset the "buffered" (loaded byte ranges) array + s.buffered = []; + + if (ranges && ranges.length) { + + // if loaded is 0, try TimeRanges implementation as % of load + // https://developer.mozilla.org/en/DOM/TimeRanges + + // re-build "buffered" array + // HTML5 returns seconds. SM2 API uses msec for setPosition() etc., whether Flash or HTML5. + for (i=0, j=ranges.length; i + if (isProgress && ranges.length > 1) { + progStr = []; + j = ranges.length; + for (i=0; i + + } + + if (!isNaN(loaded)) { + + // if progress, likely not buffering + s._onbufferchange(0); + // TODO: prevent calls with duplicate values. + s._whileloading(loaded, total, s._get_html5_duration()); + if (loaded && total && loaded === total) { + // in case "onload" doesn't fire (eg. gecko 1.9.2) + html5_events.canplaythrough.call(this, e); + } + + } + + }), + + ratechange: html5_event(function() { + + sm2._wD(this._s.id + ': ratechange'); + + }), + + suspend: html5_event(function(e) { + + // download paused/stopped, may have finished (eg. onload) + var s = this._s; + + sm2._wD(this._s.id + ': suspend'); + html5_events.progress.call(this, e); + s._onsuspend(); + + }), + + stalled: html5_event(function() { + + sm2._wD(this._s.id + ': stalled'); + + }), + + timeupdate: html5_event(function() { + + this._s._onTimer(); + + }), + + waiting: html5_event(function() { + + var s = this._s; + + // see also: seeking + sm2._wD(this._s.id + ': waiting'); + + // playback faster than download rate, etc. + s._onbufferchange(1); + + }) + + }; + + html5OK = function(iO) { + + // playability test based on URL or MIME type + + var result; + + if (!iO || (!iO.type && !iO.url && !iO.serverURL)) { + + // nothing to check + result = false; + + } else if (iO.serverURL || (iO.type && preferFlashCheck(iO.type))) { + + // RTMP, or preferring flash + result = false; + + } else { + + // Use type, if specified. Pass data: URIs to HTML5. If HTML5-only mode, no other options, so just give 'er + result = ((iO.type ? html5CanPlay({type:iO.type}) : html5CanPlay({url:iO.url}) || sm2.html5Only || iO.url.match(/data\:/i))); + + } + + return result; + + }; + + html5Unload = function(oAudio) { + + /** + * Internal method: Unload media, and cancel any current/pending network requests. + * Firefox can load an empty URL, which allegedly destroys the decoder and stops the download. + * https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox#Stopping_the_download_of_media + * However, Firefox has been seen loading a relative URL from '' and thus requesting the hosting page on unload. + * Other UA behaviour is unclear, so everyone else gets an about:blank-style URL. + */ + + var url; + + if (oAudio) { + + // Firefox and Chrome accept short WAVe data: URIs. Chome dislikes audio/wav, but accepts audio/wav for data: MIME. + // Desktop Safari complains / fails on data: URI, so it gets about:blank. + url = (isSafari ? emptyURL : (sm2.html5.canPlayType('audio/wav') ? emptyWAV : emptyURL)); + + oAudio.src = url; + + // reset some state, too + if (oAudio._called_unload !== undefined) { + oAudio._called_load = false; + } + + } + + if (useGlobalHTML5Audio) { + + // ensure URL state is trashed, also + lastGlobalHTML5URL = null; + + } + + return url; + + }; + + html5CanPlay = function(o) { + + /** + * Try to find MIME, test and return truthiness + * o = { + * url: '/path/to/an.mp3', + * type: 'audio/mp3' + * } + */ + + if (!sm2.useHTML5Audio || !sm2.hasHTML5) { + return false; + } + + var url = (o.url || null), + mime = (o.type || null), + aF = sm2.audioFormats, + result, + offset, + fileExt, + item; + + // account for known cases like audio/mp3 + + if (mime && sm2.html5[mime] !== _undefined) { + return (sm2.html5[mime] && !preferFlashCheck(mime)); + } + + if (!html5Ext) { + html5Ext = []; + for (item in aF) { + if (aF.hasOwnProperty(item)) { + html5Ext.push(item); + if (aF[item].related) { + html5Ext = html5Ext.concat(aF[item].related); + } + } + } + html5Ext = new RegExp('\\.('+html5Ext.join('|')+')(\\?.*)?$','i'); + } + + // TODO: Strip URL queries, etc. + fileExt = (url ? url.toLowerCase().match(html5Ext) : null); + + if (!fileExt || !fileExt.length) { + if (!mime) { + result = false; + } else { + // audio/mp3 -> mp3, result should be known + offset = mime.indexOf(';'); + // strip "audio/X; codecs..." + fileExt = (offset !== -1?mime.substr(0,offset):mime).substr(6); + } + } else { + // match the raw extension name - "mp3", for example + fileExt = fileExt[1]; + } + + if (fileExt && sm2.html5[fileExt] !== _undefined) { + // result known + result = (sm2.html5[fileExt] && !preferFlashCheck(fileExt)); + } else { + mime = 'audio/'+fileExt; + result = sm2.html5.canPlayType({type:mime}); + sm2.html5[fileExt] = result; + // sm2._wD('canPlayType, found result: ' + result); + result = (result && sm2.html5[mime] && !preferFlashCheck(mime)); + } + + return result; + + }; + + testHTML5 = function() { + + /** + * Internal: Iterates over audioFormats, determining support eg. audio/mp3, audio/mpeg and so on + * assigns results to html5[] and flash[]. + */ + + if (!sm2.useHTML5Audio || !sm2.hasHTML5) { + // without HTML5, we need Flash. + sm2.html5.usingFlash = true; + needsFlash = true; + return false; + } + + // double-whammy: Opera 9.64 throws WRONG_ARGUMENTS_ERR if no parameter passed to Audio(), and Webkit + iOS happily tries to load "null" as a URL. :/ + var a = (Audio !== _undefined ? (isOpera && opera.version() < 10 ? new Audio(null) : new Audio()) : null), + item, lookup, support = {}, aF, i; + + function cp(m) { + + var canPlay, j, + result = false, + isOK = false; + + if (!a || typeof a.canPlayType !== 'function') { + return result; + } + + if (m instanceof Array) { + // iterate through all mime types, return any successes + for (i=0, j=m.length; i= 0; i--) { + + // eg. audio/m4a + support['audio/'+aF[item].related[i]] = support[item]; + sm2.html5[aF[item].related[i]] = support[item]; + sm2.flash[aF[item].related[i]] = support[item]; + + } + + } + + } + + } + + support.canPlayType = (a?cp:null); + sm2.html5 = mixin(sm2.html5, support); + + sm2.html5.usingFlash = featureCheck(); + needsFlash = sm2.html5.usingFlash; + + return true; + + }; + + strings = { + + // + notReady: 'Unavailable - wait until onready() has fired.', + notOK: 'Audio support is not available.', + domError: sm + 'exception caught while appending SWF to DOM.', + spcWmode: 'Removing wmode, preventing known SWF loading issue(s)', + swf404: smc + 'Verify that %s is a valid path.', + tryDebug: 'Try ' + sm + '.debugFlash = true for more security details (output goes to SWF.)', + checkSWF: 'See SWF output for more debug info.', + localFail: smc + 'Non-HTTP page (' + doc.location.protocol + ' URL?) Review Flash player security settings for this special case:\nhttp://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html\nMay need to add/allow path, eg. c:/sm2/ or /users/me/sm2/', + waitFocus: smc + 'Special case: Waiting for SWF to load with window focus...', + waitForever: smc + 'Waiting indefinitely for Flash (will recover if unblocked)...', + waitSWF: smc + 'Waiting for 100% SWF load...', + needFunction: smc + 'Function object expected for %s', + badID: 'Sound ID "%s" should be a string, starting with a non-numeric character', + currentObj: smc + '_debug(): Current sound objects', + waitOnload: smc + 'Waiting for window.onload()', + docLoaded: smc + 'Document already loaded', + onload: smc + 'initComplete(): calling soundManager.onload()', + onloadOK: sm + '.onload() complete', + didInit: smc + 'init(): Already called?', + secNote: 'Flash security note: Network/internet URLs will not load due to security restrictions. Access can be configured via Flash Player Global Security Settings Page: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html', + badRemove: smc + 'Failed to remove Flash node.', + shutdown: sm + '.disable(): Shutting down', + queue: smc + 'Queueing %s handler', + smError: 'SMSound.load(): Exception: JS-Flash communication failed, or JS error.', + fbTimeout: 'No flash response, applying .'+swfCSS.swfTimedout+' CSS...', + fbLoaded: 'Flash loaded', + fbHandler: smc + 'flashBlockHandler()', + manURL: 'SMSound.load(): Using manually-assigned URL', + onURL: sm + '.load(): current URL already assigned.', + badFV: sm + '.flashVersion must be 8 or 9. "%s" is invalid. Reverting to %s.', + as2loop: 'Note: Setting stream:false so looping can work (flash 8 limitation)', + noNSLoop: 'Note: Looping not implemented for MovieStar formats', + needfl9: 'Note: Switching to flash 9, required for MP4 formats.', + mfTimeout: 'Setting flashLoadTimeout = 0 (infinite) for off-screen, mobile flash case', + needFlash: smc + 'Fatal error: Flash is needed to play some required formats, but is not available.', + gotFocus: smc + 'Got window focus.', + policy: 'Enabling usePolicyFile for data access', + setup: sm + '.setup(): allowed parameters: %s', + setupError: sm + '.setup(): "%s" cannot be assigned with this method.', + setupUndef: sm + '.setup(): Could not find option "%s"', + setupLate: sm + '.setup(): url, flashVersion and html5Test property changes will not take effect until reboot().', + noURL: smc + 'Flash URL required. Call soundManager.setup({url:...}) to get started.', + sm2Loaded: 'SoundManager 2: Ready.', + reset: sm + '.reset(): Removing event callbacks', + mobileUA: 'Mobile UA detected, preferring HTML5 by default.', + globalHTML5: 'Using singleton HTML5 Audio() pattern for this device.' + // + + }; + + str = function() { + + // internal string replace helper. + // arguments: o [,items to replace] + // + + var args, + i, j, o, + sstr; + + // real array, please + args = slice.call(arguments); + + // first argument + o = args.shift(); + + sstr = (strings && strings[o] ? strings[o] : ''); + + if (sstr && args && args.length) { + for (i = 0, j = args.length; i < j; i++) { + sstr = sstr.replace('%s', args[i]); + } + } + + return sstr; + // + + }; + + loopFix = function(sOpt) { + + // flash 8 requires stream = false for looping to work + if (fV === 8 && sOpt.loops > 1 && sOpt.stream) { + _wDS('as2loop'); + sOpt.stream = false; + } + + return sOpt; + + }; + + policyFix = function(sOpt, sPre) { + + if (sOpt && !sOpt.usePolicyFile && (sOpt.onid3 || sOpt.usePeakData || sOpt.useWaveformData || sOpt.useEQData)) { + sm2._wD((sPre || '') + str('policy')); + sOpt.usePolicyFile = true; + } + + return sOpt; + + }; + + complain = function(sMsg) { + + // + if (hasConsole && console.warn !== _undefined) { + console.warn(sMsg); + } else { + sm2._wD(sMsg); + } + // + + }; + + doNothing = function() { + + return false; + + }; + + disableObject = function(o) { + + var oProp; + + for (oProp in o) { + if (o.hasOwnProperty(oProp) && typeof o[oProp] === 'function') { + o[oProp] = doNothing; + } + } + + oProp = null; + + }; + + failSafely = function(bNoDisable) { + + // general failure exception handler + + if (bNoDisable === _undefined) { + bNoDisable = false; + } + + if (disabled || bNoDisable) { + sm2.disable(bNoDisable); + } + + }; + + normalizeMovieURL = function(smURL) { + + var urlParams = null, url; + + if (smURL) { + if (smURL.match(/\.swf(\?.*)?$/i)) { + urlParams = smURL.substr(smURL.toLowerCase().lastIndexOf('.swf?') + 4); + if (urlParams) { + // assume user knows what they're doing + return smURL; + } + } else if (smURL.lastIndexOf('/') !== smURL.length - 1) { + // append trailing slash, if needed + smURL += '/'; + } + } + + url = (smURL && smURL.lastIndexOf('/') !== - 1 ? smURL.substr(0, smURL.lastIndexOf('/') + 1) : './') + sm2.movieURL; + + if (sm2.noSWFCache) { + url += ('?ts=' + new Date().getTime()); + } + + return url; + + }; + + setVersionInfo = function() { + + // short-hand for internal use + + fV = parseInt(sm2.flashVersion, 10); + + if (fV !== 8 && fV !== 9) { + sm2._wD(str('badFV', fV, defaultFlashVersion)); + sm2.flashVersion = fV = defaultFlashVersion; + } + + // debug flash movie, if applicable + + var isDebug = (sm2.debugMode || sm2.debugFlash?'_debug.swf':'.swf'); + + if (sm2.useHTML5Audio && !sm2.html5Only && sm2.audioFormats.mp4.required && fV < 9) { + sm2._wD(str('needfl9')); + sm2.flashVersion = fV = 9; + } + + sm2.version = sm2.versionNumber + (sm2.html5Only?' (HTML5-only mode)':(fV === 9?' (AS3/Flash 9)':' (AS2/Flash 8)')); + + // set up default options + if (fV > 8) { + // +flash 9 base options + sm2.defaultOptions = mixin(sm2.defaultOptions, sm2.flash9Options); + sm2.features.buffering = true; + // +moviestar support + sm2.defaultOptions = mixin(sm2.defaultOptions, sm2.movieStarOptions); + sm2.filePatterns.flash9 = new RegExp('\\.(mp3|' + netStreamTypes.join('|') + ')(\\?.*)?$', 'i'); + sm2.features.movieStar = true; + } else { + sm2.features.movieStar = false; + } + + // regExp for flash canPlay(), etc. + sm2.filePattern = sm2.filePatterns[(fV !== 8?'flash9':'flash8')]; + + // if applicable, use _debug versions of SWFs + sm2.movieURL = (fV === 8?'soundmanager2.swf':'soundmanager2_flash9.swf').replace('.swf', isDebug); + + sm2.features.peakData = sm2.features.waveformData = sm2.features.eqData = (fV > 8); + + }; + + setPolling = function(bPolling, bHighPerformance) { + + if (!flash) { + return false; + } + + flash._setPolling(bPolling, bHighPerformance); + + }; + + initDebug = function() { + + // starts debug mode, creating output
    for UAs without console object + + // allow force of debug mode via URL + // + if (sm2.debugURLParam.test(wl)) { + sm2.debugMode = true; + } + + if (id(sm2.debugID)) { + return false; + } + + var oD, oDebug, oTarget, oToggle, tmp; + + if (sm2.debugMode && !id(sm2.debugID) && (!hasConsole || !sm2.useConsole || !sm2.consoleOnly)) { + + oD = doc.createElement('div'); + oD.id = sm2.debugID + '-toggle'; + + oToggle = { + 'position': 'fixed', + 'bottom': '0px', + 'right': '0px', + 'width': '1.2em', + 'height': '1.2em', + 'lineHeight': '1.2em', + 'margin': '2px', + 'textAlign': 'center', + 'border': '1px solid #999', + 'cursor': 'pointer', + 'background': '#fff', + 'color': '#333', + 'zIndex': 10001 + }; + + oD.appendChild(doc.createTextNode('-')); + oD.onclick = toggleDebug; + oD.title = 'Toggle SM2 debug console'; + + if (ua.match(/msie 6/i)) { + oD.style.position = 'absolute'; + oD.style.cursor = 'hand'; + } + + for (tmp in oToggle) { + if (oToggle.hasOwnProperty(tmp)) { + oD.style[tmp] = oToggle[tmp]; + } + } + + oDebug = doc.createElement('div'); + oDebug.id = sm2.debugID; + oDebug.style.display = (sm2.debugMode?'block':'none'); + + if (sm2.debugMode && !id(oD.id)) { + try { + oTarget = getDocument(); + oTarget.appendChild(oD); + } catch(e2) { + throw new Error(str('domError')+' \n'+e2.toString()); + } + oTarget.appendChild(oDebug); + } + + } + + oTarget = null; + // + + }; + + idCheck = this.getSoundById; + + // + _wDS = function(o, errorLevel) { + + return (!o ? '' : sm2._wD(str(o), errorLevel)); + + }; + + toggleDebug = function() { + + var o = id(sm2.debugID), + oT = id(sm2.debugID + '-toggle'); + + if (!o) { + return false; + } + + if (debugOpen) { + // minimize + oT.innerHTML = '+'; + o.style.display = 'none'; + } else { + oT.innerHTML = '-'; + o.style.display = 'block'; + } + + debugOpen = !debugOpen; + + }; + + debugTS = function(sEventType, bSuccess, sMessage) { + + // troubleshooter debug hooks + + if (window.sm2Debugger !== _undefined) { + try { + sm2Debugger.handleEvent(sEventType, bSuccess, sMessage); + } catch(e) { + // oh well + return false; + } + } + + return true; + + }; + // + + getSWFCSS = function() { + + var css = []; + + if (sm2.debugMode) { + css.push(swfCSS.sm2Debug); + } + + if (sm2.debugFlash) { + css.push(swfCSS.flashDebug); + } + + if (sm2.useHighPerformance) { + css.push(swfCSS.highPerf); + } + + return css.join(' '); + + }; + + flashBlockHandler = function() { + + // *possible* flash block situation. + + var name = str('fbHandler'), + p = sm2.getMoviePercent(), + css = swfCSS, + error = {type:'FLASHBLOCK'}; + + if (sm2.html5Only) { + // no flash, or unused + return false; + } + + if (!sm2.ok()) { + + if (needsFlash) { + // make the movie more visible, so user can fix + sm2.oMC.className = getSWFCSS() + ' ' + css.swfDefault + ' ' + (p === null?css.swfTimedout:css.swfError); + sm2._wD(name + ': ' + str('fbTimeout') + (p ? ' (' + str('fbLoaded') + ')' : '')); + } + + sm2.didFlashBlock = true; + + // fire onready(), complain lightly + processOnEvents({type:'ontimeout', ignoreInit:true, error:error}); + catchError(error); + + } else { + + // SM2 loaded OK (or recovered) + + // + if (sm2.didFlashBlock) { + sm2._wD(name + ': Unblocked'); + } + // + + if (sm2.oMC) { + sm2.oMC.className = [getSWFCSS(), css.swfDefault, css.swfLoaded + (sm2.didFlashBlock?' '+css.swfUnblocked:'')].join(' '); + } + + } + + }; + + addOnEvent = function(sType, oMethod, oScope) { + + if (on_queue[sType] === _undefined) { + on_queue[sType] = []; + } + + on_queue[sType].push({ + 'method': oMethod, + 'scope': (oScope || null), + 'fired': false + }); + + }; + + processOnEvents = function(oOptions) { + + // if unspecified, assume OK/error + + if (!oOptions) { + oOptions = { + type: (sm2.ok() ? 'onready' : 'ontimeout') + }; + } + + if (!didInit && oOptions && !oOptions.ignoreInit) { + // not ready yet. + return false; + } + + if (oOptions.type === 'ontimeout' && (sm2.ok() || (disabled && !oOptions.ignoreInit))) { + // invalid case + return false; + } + + var status = { + success: (oOptions && oOptions.ignoreInit?sm2.ok():!disabled) + }, + + // queue specified by type, or none + srcQueue = (oOptions && oOptions.type?on_queue[oOptions.type]||[]:[]), + + queue = [], i, j, + args = [status], + canRetry = (needsFlash && !sm2.ok()); + + if (oOptions.error) { + args[0].error = oOptions.error; + } + + for (i = 0, j = srcQueue.length; i < j; i++) { + if (srcQueue[i].fired !== true) { + queue.push(srcQueue[i]); + } + } + + if (queue.length) { + // sm2._wD(sm + ': Firing ' + queue.length + ' ' + oOptions.type + '() item' + (queue.length === 1 ? '' : 's')); + for (i = 0, j = queue.length; i < j; i++) { + if (queue[i].scope) { + queue[i].method.apply(queue[i].scope, args); + } else { + queue[i].method.apply(this, args); + } + if (!canRetry) { + // useFlashBlock and SWF timeout case doesn't count here. + queue[i].fired = true; + } + } + } + + return true; + + }; + + initUserOnload = function() { + + window.setTimeout(function() { + + if (sm2.useFlashBlock) { + flashBlockHandler(); + } + + processOnEvents(); + + // call user-defined "onload", scoped to window + + if (typeof sm2.onload === 'function') { + _wDS('onload', 1); + sm2.onload.apply(window); + _wDS('onloadOK', 1); + } + + if (sm2.waitForWindowLoad) { + event.add(window, 'load', initUserOnload); + } + + },1); + + }; + + detectFlash = function() { + + // hat tip: Flash Detect library (BSD, (C) 2007) by Carl "DocYes" S. Yestrau - http://featureblend.com/javascript-flash-detection-library.html / http://featureblend.com/license.txt + + if (hasFlash !== _undefined) { + // this work has already been done. + return hasFlash; + } + + var hasPlugin = false, n = navigator, nP = n.plugins, obj, type, types, AX = window.ActiveXObject; + + if (nP && nP.length) { + type = 'application/x-shockwave-flash'; + types = n.mimeTypes; + if (types && types[type] && types[type].enabledPlugin && types[type].enabledPlugin.description) { + hasPlugin = true; + } + } else if (AX !== _undefined && !ua.match(/MSAppHost/i)) { + // Windows 8 Store Apps (MSAppHost) are weird (compatibility?) and won't complain here, but will barf if Flash/ActiveX object is appended to the DOM. + try { + obj = new AX('ShockwaveFlash.ShockwaveFlash'); + } catch(e) { + // oh well + obj = null; + } + hasPlugin = (!!obj); + // cleanup, because it is ActiveX after all + obj = null; + } + + hasFlash = hasPlugin; + + return hasPlugin; + + }; + + featureCheck = function() { + + var flashNeeded, + item, + formats = sm2.audioFormats, + // iPhone <= 3.1 has broken HTML5 audio(), but firmware 3.2 (original iPad) + iOS4 works. + isSpecial = (is_iDevice && !!(ua.match(/os (1|2|3_0|3_1)/i))); + + if (isSpecial) { + + // has Audio(), but is broken; let it load links directly. + sm2.hasHTML5 = false; + + // ignore flash case, however + sm2.html5Only = true; + + // hide the SWF, if present + if (sm2.oMC) { + sm2.oMC.style.display = 'none'; + } + + } else { + + if (sm2.useHTML5Audio) { + + if (!sm2.html5 || !sm2.html5.canPlayType) { + sm2._wD('SoundManager: No HTML5 Audio() support detected.'); + sm2.hasHTML5 = false; + } + + // + if (isBadSafari) { + sm2._wD(smc + 'Note: Buggy HTML5 Audio in Safari on this OS X release, see https://bugs.webkit.org/show_bug.cgi?id=32159 - ' + (!hasFlash ?' would use flash fallback for MP3/MP4, but none detected.' : 'will use flash fallback for MP3/MP4, if available'), 1); + } + // + + } + + } + + if (sm2.useHTML5Audio && sm2.hasHTML5) { + + // sort out whether flash is optional, required or can be ignored. + + // innocent until proven guilty. + canIgnoreFlash = true; + + for (item in formats) { + if (formats.hasOwnProperty(item)) { + if (formats[item].required) { + if (!sm2.html5.canPlayType(formats[item].type)) { + // 100% HTML5 mode is not possible. + canIgnoreFlash = false; + flashNeeded = true; + } else if (sm2.preferFlash && (sm2.flash[item] || sm2.flash[formats[item].type])) { + // flash may be required, or preferred for this format. + flashNeeded = true; + } + } + } + } + + } + + // sanity check... + if (sm2.ignoreFlash) { + flashNeeded = false; + canIgnoreFlash = true; + } + + sm2.html5Only = (sm2.hasHTML5 && sm2.useHTML5Audio && !flashNeeded); + + return (!sm2.html5Only); + + }; + + parseURL = function(url) { + + /** + * Internal: Finds and returns the first playable URL (or failing that, the first URL.) + * @param {string or array} url A single URL string, OR, an array of URL strings or {url:'/path/to/resource', type:'audio/mp3'} objects. + */ + + var i, j, urlResult = 0, result; + + if (url instanceof Array) { + + // find the first good one + for (i=0, j=url.length; i= 0; i--) { + + if (sm2.sounds[sm2.soundIDs[i]].isHTML5 && sm2.sounds[sm2.soundIDs[i]]._hasTimer) { + + sm2.sounds[sm2.soundIDs[i]]._onTimer(); + + } + + } + + }; + + catchError = function(options) { + + options = (options !== _undefined ? options : {}); + + if (typeof sm2.onerror === 'function') { + sm2.onerror.apply(window, [{type:(options.type !== _undefined ? options.type : null)}]); + } + + if (options.fatal !== _undefined && options.fatal) { + sm2.disable(); + } + + }; + + badSafariFix = function() { + + // special case: "bad" Safari (OS X 10.3 - 10.7) must fall back to flash for MP3/MP4 + if (!isBadSafari || !detectFlash()) { + // doesn't apply + return false; + } + + var aF = sm2.audioFormats, i, item; + + for (item in aF) { + if (aF.hasOwnProperty(item)) { + if (item === 'mp3' || item === 'mp4') { + sm2._wD(sm + ': Using flash fallback for ' + item + ' format'); + sm2.html5[item] = false; + // assign result to related formats, too + if (aF[item] && aF[item].related) { + for (i = aF[item].related.length-1; i >= 0; i--) { + sm2.html5[aF[item].related[i]] = false; + } + } + } + } + } + + }; + + /** + * Pseudo-private flash/ExternalInterface methods + * ---------------------------------------------- + */ + + this._setSandboxType = function(sandboxType) { + + // + var sb = sm2.sandbox; + + sb.type = sandboxType; + sb.description = sb.types[(sb.types[sandboxType] !== _undefined?sandboxType:'unknown')]; + + if (sb.type === 'localWithFile') { + + sb.noRemote = true; + sb.noLocal = false; + _wDS('secNote', 2); + + } else if (sb.type === 'localWithNetwork') { + + sb.noRemote = false; + sb.noLocal = true; + + } else if (sb.type === 'localTrusted') { + + sb.noRemote = false; + sb.noLocal = false; + + } + // + + }; + + this._externalInterfaceOK = function(swfVersion) { + + // flash callback confirming flash loaded, EI working etc. + // swfVersion: SWF build string + + if (sm2.swfLoaded) { + return false; + } + + var e; + + debugTS('swf', true); + debugTS('flashtojs', true); + sm2.swfLoaded = true; + tryInitOnFocus = false; + + if (isBadSafari) { + badSafariFix(); + } + + // complain if JS + SWF build/version strings don't match, excluding +DEV builds + // + if (!swfVersion || swfVersion.replace(/\+dev/i,'') !== sm2.versionNumber.replace(/\+dev/i, '')) { + + e = sm + ': Fatal: JavaScript file build "' + sm2.versionNumber + '" does not match Flash SWF build "' + swfVersion + '" at ' + sm2.url + '. Ensure both are up-to-date.'; + + // escape flash -> JS stack so this error fires in window. + setTimeout(function versionMismatch() { + throw new Error(e); + }, 0); + + // exit, init will fail with timeout + return false; + + } + // + + // IE needs a larger timeout + setTimeout(init, isIE ? 100 : 1); + + }; + + /** + * Private initialization helpers + * ------------------------------ + */ + + createMovie = function(smID, smURL) { + + if (didAppend && appendSuccess) { + // ignore if already succeeded + return false; + } + + function initMsg() { + + // + + var options = [], + title, + msg = [], + delimiter = ' + '; + + title = 'SoundManager ' + sm2.version + (!sm2.html5Only && sm2.useHTML5Audio ? (sm2.hasHTML5 ? ' + HTML5 audio' : ', no HTML5 audio support') : ''); + + if (!sm2.html5Only) { + + if (sm2.preferFlash) { + options.push('preferFlash'); + } + + if (sm2.useHighPerformance) { + options.push('useHighPerformance'); + } + + if (sm2.flashPollingInterval) { + options.push('flashPollingInterval (' + sm2.flashPollingInterval + 'ms)'); + } + + if (sm2.html5PollingInterval) { + options.push('html5PollingInterval (' + sm2.html5PollingInterval + 'ms)'); + } + + if (sm2.wmode) { + options.push('wmode (' + sm2.wmode + ')'); + } + + if (sm2.debugFlash) { + options.push('debugFlash'); + } + + if (sm2.useFlashBlock) { + options.push('flashBlock'); + } + + } else { + + if (sm2.html5PollingInterval) { + options.push('html5PollingInterval (' + sm2.html5PollingInterval + 'ms)'); + } + + } + + if (options.length) { + msg = msg.concat([options.join(delimiter)]); + } + + sm2._wD(title + (msg.length ? delimiter + msg.join(', ') : ''), 1); + + showSupport(); + + // + + } + + if (sm2.html5Only) { + + // 100% HTML5 mode + setVersionInfo(); + + initMsg(); + sm2.oMC = id(sm2.movieID); + init(); + + // prevent multiple init attempts + didAppend = true; + + appendSuccess = true; + + return false; + + } + + // flash path + var remoteURL = (smURL || sm2.url), + localURL = (sm2.altURL || remoteURL), + swfTitle = 'JS/Flash audio component (SoundManager 2)', + oTarget = getDocument(), + extraClass = getSWFCSS(), + isRTL = null, + html = doc.getElementsByTagName('html')[0], + oEmbed, oMovie, tmp, movieHTML, oEl, s, x, sClass; + + isRTL = (html && html.dir && html.dir.match(/rtl/i)); + smID = (smID === _undefined?sm2.id:smID); + + function param(name, value) { + return ''; + } + + // safety check for legacy (change to Flash 9 URL) + setVersionInfo(); + sm2.url = normalizeMovieURL(overHTTP?remoteURL:localURL); + smURL = sm2.url; + + sm2.wmode = (!sm2.wmode && sm2.useHighPerformance ? 'transparent' : sm2.wmode); + + if (sm2.wmode !== null && (ua.match(/msie 8/i) || (!isIE && !sm2.useHighPerformance)) && navigator.platform.match(/win32|win64/i)) { + /** + * extra-special case: movie doesn't load until scrolled into view when using wmode = anything but 'window' here + * does not apply when using high performance (position:fixed means on-screen), OR infinite flash load timeout + * wmode breaks IE 8 on Vista + Win7 too in some cases, as of January 2011 (?) + */ + messages.push(strings.spcWmode); + sm2.wmode = null; + } + + oEmbed = { + 'name': smID, + 'id': smID, + 'src': smURL, + 'quality': 'high', + 'allowScriptAccess': sm2.allowScriptAccess, + 'bgcolor': sm2.bgColor, + 'pluginspage': http+'www.macromedia.com/go/getflashplayer', + 'title': swfTitle, + 'type': 'application/x-shockwave-flash', + 'wmode': sm2.wmode, + // http://help.adobe.com/en_US/as3/mobile/WS4bebcd66a74275c36cfb8137124318eebc6-7ffd.html + 'hasPriority': 'true' + }; + + if (sm2.debugFlash) { + oEmbed.FlashVars = 'debug=1'; + } + + if (!sm2.wmode) { + // don't write empty attribute + delete oEmbed.wmode; + } + + if (isIE) { + + // IE is "special". + oMovie = doc.createElement('div'); + movieHTML = [ + '', + param('movie', smURL), + param('AllowScriptAccess', sm2.allowScriptAccess), + param('quality', oEmbed.quality), + (sm2.wmode? param('wmode', sm2.wmode): ''), + param('bgcolor', sm2.bgColor), + param('hasPriority', 'true'), + (sm2.debugFlash ? param('FlashVars', oEmbed.FlashVars) : ''), + '' + ].join(''); + + } else { + + oMovie = doc.createElement('embed'); + for (tmp in oEmbed) { + if (oEmbed.hasOwnProperty(tmp)) { + oMovie.setAttribute(tmp, oEmbed[tmp]); + } + } + + } + + initDebug(); + extraClass = getSWFCSS(); + oTarget = getDocument(); + + if (oTarget) { + + sm2.oMC = (id(sm2.movieID) || doc.createElement('div')); + + if (!sm2.oMC.id) { + + sm2.oMC.id = sm2.movieID; + sm2.oMC.className = swfCSS.swfDefault + ' ' + extraClass; + s = null; + oEl = null; + + if (!sm2.useFlashBlock) { + if (sm2.useHighPerformance) { + // on-screen at all times + s = { + 'position': 'fixed', + 'width': '8px', + 'height': '8px', + // >= 6px for flash to run fast, >= 8px to start up under Firefox/win32 in some cases. odd? yes. + 'bottom': '0px', + 'left': '0px', + 'overflow': 'hidden' + }; + } else { + // hide off-screen, lower priority + s = { + 'position': 'absolute', + 'width': '6px', + 'height': '6px', + 'top': '-9999px', + 'left': '-9999px' + }; + if (isRTL) { + s.left = Math.abs(parseInt(s.left,10))+'px'; + } + } + } + + if (isWebkit) { + // soundcloud-reported render/crash fix, safari 5 + sm2.oMC.style.zIndex = 10000; + } + + if (!sm2.debugFlash) { + for (x in s) { + if (s.hasOwnProperty(x)) { + sm2.oMC.style[x] = s[x]; + } + } + } + + try { + if (!isIE) { + sm2.oMC.appendChild(oMovie); + } + oTarget.appendChild(sm2.oMC); + if (isIE) { + oEl = sm2.oMC.appendChild(doc.createElement('div')); + oEl.className = swfCSS.swfBox; + oEl.innerHTML = movieHTML; + } + appendSuccess = true; + } catch(e) { + throw new Error(str('domError')+' \n'+e.toString()); + } + + } else { + + // SM2 container is already in the document (eg. flashblock use case) + sClass = sm2.oMC.className; + sm2.oMC.className = (sClass?sClass+' ':swfCSS.swfDefault) + (extraClass?' '+extraClass:''); + sm2.oMC.appendChild(oMovie); + if (isIE) { + oEl = sm2.oMC.appendChild(doc.createElement('div')); + oEl.className = swfCSS.swfBox; + oEl.innerHTML = movieHTML; + } + appendSuccess = true; + + } + + } + + didAppend = true; + initMsg(); + // sm2._wD(sm + ': Trying to load ' + smURL + (!overHTTP && sm2.altURL ? ' (alternate URL)' : ''), 1); + + return true; + + }; + + initMovie = function() { + + if (sm2.html5Only) { + createMovie(); + return false; + } + + // attempt to get, or create, movie (may already exist) + if (flash) { + return false; + } + + if (!sm2.url) { + + /** + * Something isn't right - we've reached init, but the soundManager url property has not been set. + * User has not called setup({url: ...}), or has not set soundManager.url (legacy use case) directly before init time. + * Notify and exit. If user calls setup() with a url: property, init will be restarted as in the deferred loading case. + */ + + _wDS('noURL'); + return false; + + } + + // inline markup case + flash = sm2.getMovie(sm2.id); + + if (!flash) { + if (!oRemoved) { + // try to create + createMovie(sm2.id, sm2.url); + } else { + // try to re-append removed movie after reboot() + if (!isIE) { + sm2.oMC.appendChild(oRemoved); + } else { + sm2.oMC.innerHTML = oRemovedHTML; + } + oRemoved = null; + didAppend = true; + } + flash = sm2.getMovie(sm2.id); + } + + if (typeof sm2.oninitmovie === 'function') { + setTimeout(sm2.oninitmovie, 1); + } + + // + flushMessages(); + // + + return true; + + }; + + delayWaitForEI = function() { + + setTimeout(waitForEI, 1000); + + }; + + rebootIntoHTML5 = function() { + + // special case: try for a reboot with preferFlash: false, if 100% HTML5 mode is possible and useFlashBlock is not enabled. + + window.setTimeout(function() { + + complain(smc + 'useFlashBlock is false, 100% HTML5 mode is possible. Rebooting with preferFlash: false...'); + + sm2.setup({ + preferFlash: false + }).reboot(); + + // if for some reason you want to detect this case, use an ontimeout() callback and look for html5Only and didFlashBlock == true. + sm2.didFlashBlock = true; + + sm2.beginDelayedInit(); + + }, 1); + + }; + + waitForEI = function() { + + var p, + loadIncomplete = false; + + if (!sm2.url) { + // No SWF url to load (noURL case) - exit for now. Will be retried when url is set. + return false; + } + + if (waitingForEI) { + return false; + } + + waitingForEI = true; + event.remove(window, 'load', delayWaitForEI); + + if (hasFlash && tryInitOnFocus && !isFocused) { + // Safari won't load flash in background tabs, only when focused. + _wDS('waitFocus'); + return false; + } + + if (!didInit) { + p = sm2.getMoviePercent(); + if (p > 0 && p < 100) { + loadIncomplete = true; + } + } + + setTimeout(function() { + + p = sm2.getMoviePercent(); + + if (loadIncomplete) { + // special case: if movie *partially* loaded, retry until it's 100% before assuming failure. + waitingForEI = false; + sm2._wD(str('waitSWF')); + window.setTimeout(delayWaitForEI, 1); + return false; + } + + // + if (!didInit) { + + sm2._wD(sm + ': No Flash response within expected time. Likely causes: ' + (p === 0 ? 'SWF load failed, ':'') + 'Flash blocked or JS-Flash security error.' + (sm2.debugFlash?' ' + str('checkSWF'):''), 2); + + if (!overHTTP && p) { + + _wDS('localFail', 2); + + if (!sm2.debugFlash) { + _wDS('tryDebug', 2); + } + + } + + if (p === 0) { + + // if 0 (not null), probably a 404. + sm2._wD(str('swf404', sm2.url), 1); + + } + + debugTS('flashtojs', false, ': Timed out' + overHTTP?' (Check flash security or flash blockers)':' (No plugin/missing SWF?)'); + + } + // + + // give up / time-out, depending + + if (!didInit && okToDisable) { + + if (p === null) { + + // SWF failed to report load progress. Possibly blocked. + + if (sm2.useFlashBlock || sm2.flashLoadTimeout === 0) { + + if (sm2.useFlashBlock) { + + flashBlockHandler(); + + } + + _wDS('waitForever'); + + } else { + + // no custom flash block handling, but SWF has timed out. Will recover if user unblocks / allows SWF load. + + if (!sm2.useFlashBlock && canIgnoreFlash) { + + rebootIntoHTML5(); + + } else { + + _wDS('waitForever'); + + // fire any regular registered ontimeout() listeners. + processOnEvents({type:'ontimeout', ignoreInit: true, error: {type: 'INIT_FLASHBLOCK'}}); + + } + + } + + } else { + + // SWF loaded? Shouldn't be a blocking issue, then. + + if (sm2.flashLoadTimeout === 0) { + + _wDS('waitForever'); + + } else { + + if (!sm2.useFlashBlock && canIgnoreFlash) { + + rebootIntoHTML5(); + + } else { + + failSafely(true); + + } + + } + + } + + } + + }, sm2.flashLoadTimeout); + + }; + + handleFocus = function() { + + function cleanup() { + event.remove(window, 'focus', handleFocus); + } + + if (isFocused || !tryInitOnFocus) { + // already focused, or not special Safari background tab case + cleanup(); + return true; + } + + okToDisable = true; + isFocused = true; + _wDS('gotFocus'); + + // allow init to restart + waitingForEI = false; + + // kick off ExternalInterface timeout, now that the SWF has started + delayWaitForEI(); + + cleanup(); + return true; + + }; + + flushMessages = function() { + + // + + // SM2 pre-init debug messages + if (messages.length) { + sm2._wD('SoundManager 2: ' + messages.join(' '), 1); + messages = []; + } + + // + + }; + + showSupport = function() { + + // + + flushMessages(); + + var item, tests = []; + + if (sm2.useHTML5Audio && sm2.hasHTML5) { + for (item in sm2.audioFormats) { + if (sm2.audioFormats.hasOwnProperty(item)) { + tests.push(item + ' = ' + sm2.html5[item] + (!sm2.html5[item] && needsFlash && sm2.flash[item] ? ' (using flash)' : (sm2.preferFlash && sm2.flash[item] && needsFlash ? ' (preferring flash)': (!sm2.html5[item] ? ' (' + (sm2.audioFormats[item].required ? 'required, ':'') + 'and no flash support)' : '')))); + } + } + sm2._wD('SoundManager 2 HTML5 support: ' + tests.join(', '), 1); + } + + // + + }; + + initComplete = function(bNoDisable) { + + if (didInit) { + return false; + } + + if (sm2.html5Only) { + // all good. + _wDS('sm2Loaded'); + didInit = true; + initUserOnload(); + debugTS('onload', true); + return true; + } + + var wasTimeout = (sm2.useFlashBlock && sm2.flashLoadTimeout && !sm2.getMoviePercent()), + result = true, + error; + + if (!wasTimeout) { + didInit = true; + } + + error = {type: (!hasFlash && needsFlash ? 'NO_FLASH' : 'INIT_TIMEOUT')}; + + sm2._wD('SoundManager 2 ' + (disabled ? 'failed to load' : 'loaded') + ' (' + (disabled ? 'Flash security/load error' : 'OK') + ')', disabled ? 2: 1); + + if (disabled || bNoDisable) { + if (sm2.useFlashBlock && sm2.oMC) { + sm2.oMC.className = getSWFCSS() + ' ' + (sm2.getMoviePercent() === null?swfCSS.swfTimedout:swfCSS.swfError); + } + processOnEvents({type:'ontimeout', error:error, ignoreInit: true}); + debugTS('onload', false); + catchError(error); + result = false; + } else { + debugTS('onload', true); + } + + if (!disabled) { + if (sm2.waitForWindowLoad && !windowLoaded) { + _wDS('waitOnload'); + event.add(window, 'load', initUserOnload); + } else { + // + if (sm2.waitForWindowLoad && windowLoaded) { + _wDS('docLoaded'); + } + // + initUserOnload(); + } + } + + return result; + + }; + + /** + * apply top-level setupOptions object as local properties, eg., this.setupOptions.flashVersion -> this.flashVersion (soundManager.flashVersion) + * this maintains backward compatibility, and allows properties to be defined separately for use by soundManager.setup(). + */ + + setProperties = function() { + + var i, + o = sm2.setupOptions; + + for (i in o) { + + if (o.hasOwnProperty(i)) { + + // assign local property if not already defined + + if (sm2[i] === _undefined) { + + sm2[i] = o[i]; + + } else if (sm2[i] !== o[i]) { + + // legacy support: write manually-assigned property (eg., soundManager.url) back to setupOptions to keep things in sync + sm2.setupOptions[i] = sm2[i]; + + } + + } + + } + + }; + + + init = function() { + + // called after onload() + + if (didInit) { + _wDS('didInit'); + return false; + } + + function cleanup() { + event.remove(window, 'load', sm2.beginDelayedInit); + } + + if (sm2.html5Only) { + if (!didInit) { + // we don't need no steenking flash! + cleanup(); + sm2.enabled = true; + initComplete(); + } + return true; + } + + // flash path + initMovie(); + + try { + + // attempt to talk to Flash + flash._externalInterfaceTest(false); + + // apply user-specified polling interval, OR, if "high performance" set, faster vs. default polling + // (determines frequency of whileloading/whileplaying callbacks, effectively driving UI framerates) + setPolling(true, (sm2.flashPollingInterval || (sm2.useHighPerformance ? 10 : 50))); + + if (!sm2.debugMode) { + // stop the SWF from making debug output calls to JS + flash._disableDebug(); + } + + sm2.enabled = true; + debugTS('jstoflash', true); + + if (!sm2.html5Only) { + // prevent browser from showing cached page state (or rather, restoring "suspended" page state) via back button, because flash may be dead + // http://www.webkit.org/blog/516/webkit-page-cache-ii-the-unload-event/ + event.add(window, 'unload', doNothing); + } + + } catch(e) { + + sm2._wD('js/flash exception: ' + e.toString()); + debugTS('jstoflash', false); + catchError({type:'JS_TO_FLASH_EXCEPTION', fatal:true}); + // don't disable, for reboot() + failSafely(true); + initComplete(); + + return false; + + } + + initComplete(); + + // disconnect events + cleanup(); + + return true; + + }; + + domContentLoaded = function() { + + if (didDCLoaded) { + return false; + } + + didDCLoaded = true; + + // assign top-level soundManager properties eg. soundManager.url + setProperties(); + + initDebug(); + + /** + * Temporary feature: allow force of HTML5 via URL params: sm2-usehtml5audio=0 or 1 + * Ditto for sm2-preferFlash, too. + */ + // + (function(){ + + var a = 'sm2-usehtml5audio=', + a2 = 'sm2-preferflash=', + b = null, + b2 = null, + l = wl.toLowerCase(); + + if (l.indexOf(a) !== -1) { + b = (l.charAt(l.indexOf(a)+a.length) === '1'); + if (hasConsole) { + console.log((b?'Enabling ':'Disabling ')+'useHTML5Audio via URL parameter'); + } + sm2.setup({ + 'useHTML5Audio': b + }); + } + + if (l.indexOf(a2) !== -1) { + b2 = (l.charAt(l.indexOf(a2)+a2.length) === '1'); + if (hasConsole) { + console.log((b2?'Enabling ':'Disabling ')+'preferFlash via URL parameter'); + } + sm2.setup({ + 'preferFlash': b2 + }); + } + + }()); + // + + if (!hasFlash && sm2.hasHTML5) { + sm2._wD('SoundManager 2: No Flash detected' + (!sm2.useHTML5Audio ? ', enabling HTML5.' : '. Trying HTML5-only mode.'), 1); + sm2.setup({ + 'useHTML5Audio': true, + // make sure we aren't preferring flash, either + // TODO: preferFlash should not matter if flash is not installed. Currently, stuff breaks without the below tweak. + 'preferFlash': false + }); + } + + testHTML5(); + + if (!hasFlash && needsFlash) { + messages.push(strings.needFlash); + // TODO: Fatal here vs. timeout approach, etc. + // hack: fail sooner. + sm2.setup({ + 'flashLoadTimeout': 1 + }); + } + + if (doc.removeEventListener) { + doc.removeEventListener('DOMContentLoaded', domContentLoaded, false); + } + + initMovie(); + + return true; + + }; + + domContentLoadedIE = function() { + + if (doc.readyState === 'complete') { + domContentLoaded(); + doc.detachEvent('onreadystatechange', domContentLoadedIE); + } + + return true; + + }; + + winOnLoad = function() { + + // catch edge case of initComplete() firing after window.load() + windowLoaded = true; + event.remove(window, 'load', winOnLoad); + + }; + + /** + * miscellaneous run-time, pre-init stuff + */ + + preInit = function() { + + if (mobileHTML5) { + + // prefer HTML5 for mobile + tablet-like devices, probably more reliable vs. flash at this point. + + // + if (!sm2.setupOptions.useHTML5Audio || sm2.setupOptions.preferFlash) { + // notify that defaults are being changed. + messages.push(strings.mobileUA); + } + // + + sm2.setupOptions.useHTML5Audio = true; + sm2.setupOptions.preferFlash = false; + + if (is_iDevice || (isAndroid && !ua.match(/android\s2\.3/i))) { + // iOS and Android devices tend to work better with a single audio instance, specifically for chained playback of sounds in sequence. + // common use case: exiting sound onfinish() -> createSound() -> play() + // + messages.push(strings.globalHTML5); + // + if (is_iDevice) { + sm2.ignoreFlash = true; + } + useGlobalHTML5Audio = true; + } + + } + + }; + + preInit(); + + // sniff up-front + detectFlash(); + + // focus and window load, init (primarily flash-driven) + event.add(window, 'focus', handleFocus); + event.add(window, 'load', delayWaitForEI); + event.add(window, 'load', winOnLoad); + + if (doc.addEventListener) { + + doc.addEventListener('DOMContentLoaded', domContentLoaded, false); + + } else if (doc.attachEvent) { + + doc.attachEvent('onreadystatechange', domContentLoadedIE); + + } else { + + // no add/attachevent support - safe to assume no JS -> Flash either + debugTS('onload', false); + catchError({type:'NO_DOM2_EVENTS', fatal:true}); + + } + +} // SoundManager() + +// SM2_DEFER details: http://www.schillmania.com/projects/soundmanager2/doc/getstarted/#lazy-loading + +if (window.SM2_DEFER === undefined || !SM2_DEFER) { + soundManager = new SoundManager(); +} + +/** + * SoundManager public interfaces + * ------------------------------ + */ + +window.SoundManager = SoundManager; // constructor +window.soundManager = soundManager; // public API, flash callbacks etc. + +}(window)); diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/SoundManager2.as b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/SoundManager2.as new file mode 100755 index 00000000..6527594e --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/SoundManager2.as @@ -0,0 +1,421 @@ +/** + * SoundManager 2: Javascript Sound for the Web + * ---------------------------------------------- + * http://schillmania.com/projects/soundmanager2/ + * + * Copyright (c) 2007, Scott Schiller. All rights reserved. + * Code licensed under the BSD License: + * http://www.schillmania.com/projects/soundmanager2/license.txt + * + * Flash 8 / ActionScript 2 version + * + * Compiling AS to Flash 8 SWF using MTASC (free compiler - http://www.mtasc.org/): + * mtasc -swf soundmanager2.swf -main -header 16:16:30 SoundManager2.as -version 8 + * + * ActionScript Sound class reference (Macromedia), documentation download: + * http://livedocs.macromedia.com/flash/8/ + * Previously-live URL: + * http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002668.html + * + * *** NOTE ON LOCAL FILE SYSTEM ACCESS *** + * + * Flash security allows local OR network access, but not both + * unless explicitly whitelisted/allowed by the flash player's + * security settings. + * + * To enable in-flash messaging for troubleshooting, pass debug=1 in FlashVars (within object/embed code) + * SM2 will do this by default when soundManager.debugFlash = true. + * + */ + +import flash.external.ExternalInterface; // woo + +class SoundManager2 { + + static var app: SoundManager2; + + function SoundManager2() { + + var version = "V2.97a.20131201"; + var version_as = "(AS2/Flash 8)"; + + /** + * Cross-domain security options + * HTML on foo.com loading .swf hosted on bar.com? Define your "HTML domain" here to allow JS+Flash communication to work. + * // allow_xdomain_scripting = true; + * // xdomain = "foo.com"; + * For all domains (possible security risk?), use xdomain = "*"; which ends up as System.security.allowDomain("*"); + * When loading from HTTPS, use System.security.allowInsecureDomain(); + * See "allowDomain (security.allowDomain method)" in Flash 8/AS2 liveDocs documentation (AS2 reference -> classes -> security) + * download from http://livedocs.macromedia.com/flash/8/ + * Related AS3 documentation: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/system/Security.html#allowDomain%28%29 + */ + + var allow_xdomain_scripting = false; + var xdomain = "*"; + + if (allow_xdomain_scripting && xdomain) { + System.security.allowDomain(xdomain); + version_as += ' - cross-domain enabled'; + } + + // externalInterface references (for Javascript callbacks) + var baseJSController = "soundManager"; + var baseJSObject = baseJSController + ".sounds"; + + // internal objects + var sounds = []; // indexed string array + var soundObjects = []; // associative Sound() object array + var timer = null; + var pollingEnabled = false; // polling (timer) flag - disabled by default, enabled by JS->Flash call + var debugEnabled = true; // Flash debug output enabled by default, disabled by JS call + var flashDebugEnabled = false; // debug output to flash movie, off by default + var didSandboxMessage = false; + var caughtFatal = false; + + // for flash text output, debugging etc. + var _messages = []; + var _messageObj = null; + flashDebugEnabled = (_root.debug == 1); + + // display stuffs + Stage.scaleMode = 'noScale'; + Stage.align = 'TL'; + + // context menu item with version info + + var doNothing = function() {} + + var sm2Menu:ContextMenu = new ContextMenu(); + var sm2MenuItem:ContextMenuItem = new ContextMenuItem('SoundManager ' + version + ' ' + version_as, doNothing); + sm2MenuItem.enabled = false; + sm2Menu.customItems.push(sm2MenuItem); + _root.menu = sm2Menu; + + var writeDebug = function(s, logLevel) { + // + if (!debugEnabled) return false; + ExternalInterface.call(baseJSController + "['_writeDebug']", "(Flash): " + s, (logLevel || 0)); + // + } + + var flashDebug = function(messageText) { + // + _messages.push(messageText); + if (!flashDebugEnabled) { + return false; + } + var sans = new TextFormat(); + sans.size = 12; + sans.font = "Arial"; + + // 320x240 if no stage dimensions (happens in IE, apparently 0 before stage resize event fires.) + var w = Stage.width?Stage.width:320; + var h = Stage.height?Stage.height:240; + if (!_messageObj) { + _messageObj = _root.createTextField("_messageObj", 0, 0, 0, w, h); + _messageObj.x = 0; + _messageObj.y = 0; + _messageObj.multiline = true; + _messageObj.html = true; + _messageObj.wordWrap = true; + _messageObj.align = 'left'; + _messageObj.autoSize = false; + } + _messageObj.htmlText = _messages.join('\n'); + _messageObj.setTextFormat(sans); + _messageObj.width = w; + _messageObj.height = h; + // + } + + var _externalInterfaceTest = function(isFirstCall) { + var sandboxType = System.security['sandboxType']; + try { + if (isFirstCall) { + flashDebug('Testing Flash -> JS...') + if (!didSandboxMessage && sandboxType != 'remote' && sandboxType != 'localTrusted') { + didSandboxMessage = true; + flashDebug('
    Fatal: Security sandbox error: Got "' + sandboxType + '", expected "remote" or "localTrusted".
    Additional security permissions need to be granted.
    See flash security settings panel for non-HTTP, eg. file:// use.

    http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html

    You may also be able to right-click this movie and choose from the menu:
    "Global Settings" -> "Advanced" tab -> "Trusted Location Settings"
    '); + } + ExternalInterface.call(baseJSController + "._externalInterfaceOK", version); + if (!didSandboxMessage) { + flashDebug('Flash -> JS OK'); + flashDebug('Waiting for JS -> Flash...'); + } + } else { + // writeDebug('SM2 SWF ' + version + ' ' + version_as, 1); + ExternalInterface.call(baseJSController + "._setSandboxType", sandboxType); + flashDebug('JS -> Flash OK'); + } + } catch(e) { + flashDebug(e.toString()); + if (!caughtFatal) { + caughtFatal = true; + } + return false; + } + return true; // to verify that a call from JS to here, works. (eg. JS receives "true", thus OK.) + } + + var _disableDebug = function() { + // prevent future debug calls from Flash going to client (maybe improve performance) + writeDebug('_disableDebug()'); + debugEnabled = false; + } + + var checkProgress = function() { + var bL = 0; + var bT = 0; + var nD = 0; + var nP = 0; + var oSound = null; + for (var i = 0, j = sounds.length; i < j; i++) { + oSound = soundObjects[sounds[i]]; + bL = oSound.getBytesLoaded(); + bT = oSound.getBytesTotal(); + nD = oSound.duration || 0; // can sometimes be null with short MP3s? Wack. + nP = oSound.position; + if (bL && bT && bL != oSound.lastValues.bytes) { + oSound.lastValues.bytes = bL; + ExternalInterface.call(baseJSObject + "['" + oSound.sID + "']._whileloading", bL, bT, nD); + } + if (typeof nP != 'undefined' && nP != oSound.lastValues.position) { + oSound.lastValues.position = nP; + ExternalInterface.call(baseJSObject + "['" + oSound.sID + "']._whileplaying", nP); + // if position changed, check for near-end + } + } + } + + var onLoad = function(bSuccess) { + checkProgress(); // ensure progress stats are up-to-date + // force duration update (doesn't seem to be always accurate) + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._whileloading", this.getBytesLoaded(), this.getBytesTotal(), this.duration); + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onload", this.duration > 0 ? 1 : 0); // bSuccess doesn't always seem to work, so check MP3 duration instead. + } + + var onID3 = function() { + // --- NOTE: BUGGY? --- + // -------------------- + // TODO: Investigate holes in ID3 parsing - for some reason, Album will be populated with Date if empty and date is provided. (?) + // ID3V1 seem to parse OK, but "holes" / blanks in ID3V2 data seem to get messed up (eg. missing album gets filled with date.) + // iTunes issues: onID3 was not called with a test MP3 encoded with iTunes 7.01, and what appeared to be valid ID3V2 data. + // May be related to thumbnails for album art included in MP3 file by iTunes. See http://mabblog.com/blog/?p=33 + var id3Data = []; + var id3Props = []; + for (var prop in this.id3) { + id3Props.push(prop); + id3Data.push(this.id3[prop]); + // writeDebug('id3['+prop+']: '+this.id3[prop]); + } + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onid3", id3Props, id3Data); + // unhook own event handler, prevent second call (can fire twice as data is received - ID3V2 at beginning, ID3V1 at end.) + // Therefore if ID3V2 data is received, ID3V1 is ignored. + soundObjects[this.sID].onID3 = null; + } + + var registerOnComplete = function(sID) { + soundObjects[sID].onSoundComplete = function() { + checkProgress(); + ExternalInterface.call(baseJSObject + "['" + sID + "']._onfinish"); + } + } + + var _setPosition = function(sID, nSecOffset, isPaused, _allowMultiShot) { + // note: multiShot is Flash 9-only; retained so JS/Flash function signatures are identical. + var s = soundObjects[sID]; + // writeDebug('_setPosition()'); + s.lastValues.position = s.position; + if (s.lastValues.loops > 1 && nSecOffset != 0) { + writeDebug('Warning: Looping functionality being disabled due to Flash limitation.', 240); + s.lastValues.loops = 1; + } + s.start(nSecOffset, s.lastValues.nLoops || 1); // start playing at new position + if (isPaused) { + s.stop(); + } + } + + var _load = function(sID, sURL, bStream, bAutoPlay, bCheckPolicyFile) { + // writeDebug('_load(): '+sID+', '+sURL+', '+bStream+', '+bAutoPlay+', '+bCheckPolicyFile); + if (typeof bAutoPlay == 'undefined') { + bAutoPlay = false; + } + if (typeof bStream == 'undefined') { + bStream = true; + } + if (typeof bCheckPolicyFile == 'undefined') { + bCheckPolicyFile = false; + } + // writeDebug('bStream: '+bStream); + // writeDebug('bAutoPlay: '+bAutoPlay); + // checkProgress(); + var s = soundObjects[sID]; + s.onID3 = onID3; + s.onLoad = onLoad; + s.loaded = true; + s.checkPolicyFile = bCheckPolicyFile; + s.loadSound(sURL, bStream); + if (bAutoPlay != true) { + s.stop(); // prevent default auto-play behaviour + } else { + writeDebug('auto-play allowed'); + } + registerOnComplete(sID); + } + + var _unload = function(sID, sURL) { + // effectively "stop" loading by loading a tiny MP3 + var s = soundObjects[sID]; + s.onID3 = null; + s.onLoad = null; + s.loaded = false; + // ensure position is reset, if unload fails + s.start(0,1); + s.stop(); + s.loadSound(sURL, true); + s.stop(); // prevent auto-play + } + + var _createSound = function(sID, loops, checkPolicyFile) { + var s = new Sound(); + if (!soundObjects[sID]) { + sounds.push(sID); + } + soundObjects[sID] = s; + s.setVolume(100); + s.sID = sID; + s.paused = false; + s.loaded = false; + s.checkPolicyFile = checkPolicyFile; + s.lastValues = { + bytes: 0, + position: 0, + nLoops: loops||1 + }; + } + + var _destroySound = function(sID) { + // for the power of garbage collection! .. er, Greyskull! + var s = (soundObjects[sID] || null); + if (!s) { + return false; + } + for (var i = 0; i < sounds.length; i++) { + if (sounds[i] == sID) { + sounds.splice(i, 1); + break; + } + } + s = null; + delete soundObjects[sID]; + } + + var _stop = function(sID, bStopAll) { + // stop this particular instance (or "all", based on parameter) + if (bStopAll) { + _root.stop(); + } else { + soundObjects[sID].stop(); + soundObjects[sID].paused = false; + } + } + + var _start = function(sID, nLoops, nMsecOffset, _allowMultiShot) { + // note: multiShot is Flash 9-only; retained so JS/Flash function signatures are identical. + // writeDebug('_start: ' + sID + ', loops: ' + nLoops + ', nMsecOffset: ' + nMsecOffset); + registerOnComplete(); + var s = soundObjects[sID]; + s.lastValues.paused = false; // reset pause if applicable + s.lastValues.nLoops = (nLoops || 1); + s.start(nMsecOffset, nLoops); + return true; + } + + var _pause = function(sID, _allowMultiShot) { + // note: multiShot is Flash 9-only; retained so JS/Flash function signatures are identical. + // writeDebug('_pause()'); + var s = soundObjects[sID]; + if (!s.paused) { + // reference current position, stop sound + s.paused = true; + s.lastValues.position = s.position; + // writeDebug('_pause(): position: '+s.lastValues.position); + s.stop(); + } else { + // resume playing from last position + // writeDebug('resuming - playing at '+s.lastValues.position+', '+s.lastValues.nLoops+' times'); + s.paused = false; + s.start(s.lastValues.position / 1000, s.lastValues.nLoops); + } + } + + var _setPan = function(sID, nPan) { + soundObjects[sID].setPan(nPan); + } + + var _setVolume = function(sID, nVol) { + soundObjects[sID].setVolume(nVol); + } + + var _setPolling = function(bPolling, timerInterval) { + if (typeof timerInterval === 'undefined') { + timerInterval = 50; + } + pollingEnabled = bPolling; + if (timer == null && pollingEnabled) { + flashDebug('Enabling polling, ' + timerInterval + ' ms interval'); + timer = setInterval(checkProgress, timerInterval); + } else if (timer && !pollingEnabled) { + flashDebug('Disabling polling'); + clearInterval(timer); + timer = null; + } + } + + var _init = function() { + + // OK now stuff should be available + try { + flashDebug('Adding ExternalInterface callbacks...'); + ExternalInterface.addCallback('_load', this, _load); + ExternalInterface.addCallback('_unload', this, _unload); + ExternalInterface.addCallback('_stop', this, _stop); + ExternalInterface.addCallback('_start', this, _start); + ExternalInterface.addCallback('_pause', this, _pause); + ExternalInterface.addCallback('_setPosition', this, _setPosition); + ExternalInterface.addCallback('_setPan', this, _setPan); + ExternalInterface.addCallback('_setVolume', this, _setVolume); + ExternalInterface.addCallback('_setPolling', this, _setPolling); + ExternalInterface.addCallback('_externalInterfaceTest', this, _externalInterfaceTest); + ExternalInterface.addCallback('_disableDebug', this, _disableDebug); + ExternalInterface.addCallback('_createSound', this, _createSound); + ExternalInterface.addCallback('_destroySound', this, _destroySound); + } catch(e) { + flashDebug('Fatal: ExternalInterface error: ' + e.toString()); + } + // try to talk to JS, do init etc. + _externalInterfaceTest(true); + // flashDebug('Init OK'); + } + + flashDebug('SM2 SWF ' + version + ' ' + version_as); + + if (ExternalInterface.available) { + flashDebug('ExternalInterface available'); + _init(); + } else { + // d'oh! - may be from a corrupt install, ancient (pre-Netscape 6?) browser etc. + flashDebug('Fatal: ExternalInterface (Flash <-> JS) not available'); + } + + + } // SoundManager2() + + // entry point + static function main(mc) { + app = new SoundManager2(); + } + +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/SoundManager2_AS3.as b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/SoundManager2_AS3.as new file mode 100755 index 00000000..6568129e --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/SoundManager2_AS3.as @@ -0,0 +1,925 @@ +/** + * SoundManager 2: Javascript Sound for the Web + * ---------------------------------------------- + * http://schillmania.com/projects/soundmanager2/ + * + * Copyright (c) 2007, Scott Schiller. All rights reserved. + * Code licensed under the BSD License: + * http://www.schillmania.com/projects/soundmanager2/license.txt + * + * Flash 9 / ActionScript 3 version + */ + +package { + + import flash.display.Sprite; + import flash.events.Event; + import flash.events.IOErrorEvent; + import flash.events.MouseEvent; + import flash.events.SecurityErrorEvent; + import flash.events.AsyncErrorEvent; + import flash.events.NetStatusEvent; + import flash.events.TimerEvent; + import flash.external.ExternalInterface; // woo + import flash.media.Sound; + import flash.media.SoundChannel; + import flash.media.SoundMixer; + import flash.net.URLLoader; + import flash.net.URLRequest; + import flash.system.Security; + import flash.system.System; + import flash.text.TextField; + import flash.text.TextFormat; + import flash.text.TextFieldAutoSize; + import flash.ui.ContextMenu; + import flash.ui.ContextMenuItem; + import flash.utils.setInterval; + import flash.utils.clearInterval; + import flash.utils.Dictionary; + import flash.utils.Timer; + + public class SoundManager2_AS3 extends Sprite { + + public var version:String = "V2.97a.20131201"; + public var version_as:String = "(AS3/Flash 9)"; + + /** + * Cross-domain security options + * HTML on foo.com loading .swf hosted on bar.com? Define your "HTML domain" here to allow JS+Flash communication to work. + * // allow_xdomain_scripting = true; + * // xdomain = "foo.com"; + * For all domains (possible security risk?), use xdomain = "*"; which ends up as System.security.allowDomain("*"); + * When loading from HTTPS, use System.security.allowInsecureDomain(); + * See http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/system/Security.html#allowDomain() + */ + public var allow_xdomain_scripting:Boolean = false; + public var xdomain:String = "*"; + + // externalInterface references (for Javascript callbacks) + public var baseJSController:String = "soundManager"; + public var baseJSObject:String = baseJSController + ".sounds"; + + // internal objects + public var sounds:Array = []; // indexed string array + public var soundObjects: Dictionary = new Dictionary(); // associative Sound() object Dictionary type + public var timer: Timer = null; + public var pollingEnabled: Boolean = false; // polling (timer) flag - disabled by default, enabled by JS->Flash call + public var debugEnabled: Boolean = true; // Flash debug output enabled by default, disabled by JS call + public var flashDebugEnabled: Boolean = false; // Flash internal debug output (write to visible SWF in browser) + public var loaded: Boolean = false; + public var currentObject: SoundManager2_SMSound_AS3 = null; + public var paramList:Object = null; + public var messages:Array = []; + public var textField: TextField = null; + public var textStyle: TextFormat = new TextFormat(); + public var didSandboxMessage: Boolean = false; + public var caughtFatal: Boolean = false; + + public function SoundManager2_AS3() { + + if (allow_xdomain_scripting && xdomain) { + Security.allowDomain(xdomain); + version_as += ' - cross-domain enabled'; + } + + this.paramList = this.root.loaderInfo.parameters; + + // + if (this.paramList['debug'] == 1) { + this.flashDebugEnabled = true; + } + + if (this.flashDebugEnabled) { + var canvas: Sprite = new Sprite(); + canvas.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); + addChild(canvas); + } + // + + flashDebug('SM2 SWF ' + version + ' ' + version_as); + + // context menu item with version info + + var sm2Menu:ContextMenu = new ContextMenu(); + var sm2MenuItem:ContextMenuItem = new ContextMenuItem('SoundManager ' + version + ' ' + version_as); + sm2MenuItem.enabled = false; + sm2Menu.customItems.push(sm2MenuItem); + contextMenu = sm2Menu; + + if (ExternalInterface.available) { + flashDebug('ExternalInterface available'); + try { + flashDebug('Adding ExternalInterface callbacks...'); + ExternalInterface.addCallback('_load', _load); + ExternalInterface.addCallback('_unload', _unload); + ExternalInterface.addCallback('_stop', _stop); + ExternalInterface.addCallback('_start', _start); + ExternalInterface.addCallback('_pause', _pause); + ExternalInterface.addCallback('_setPosition', _setPosition); + ExternalInterface.addCallback('_setPan', _setPan); + ExternalInterface.addCallback('_setVolume', _setVolume); + ExternalInterface.addCallback('_setPolling', _setPolling); + ExternalInterface.addCallback('_externalInterfaceTest', _externalInterfaceTest); + ExternalInterface.addCallback('_disableDebug', _disableDebug); + ExternalInterface.addCallback('_getMemoryUse', _getMemoryUse); + ExternalInterface.addCallback('_createSound', _createSound); + ExternalInterface.addCallback('_destroySound', _destroySound); + ExternalInterface.addCallback('_setAutoPlay', _setAutoPlay); + } catch(e: Error) { + flashDebug('Fatal: ExternalInterface error: ' + e.toString()); + } + } else { + flashDebug('Fatal: ExternalInterface (Flash <-> JS) not available'); + }; + + // call after delay, to be safe (ensure callbacks are registered by the time JS is called below) + var timer: Timer = new Timer(20, 0); + timer.addEventListener(TimerEvent.TIMER, function() : void { + timer.reset(); + _externalInterfaceTest(true); + // timer.reset(); + // flashDebug('Init OK'); + }); + timer.start(); + // delayed, see above + // _externalInterfaceTest(true); + } // SoundManager2() + + public function flashDebug (txt:String) : void { + // + messages.push(txt); + if (this.flashDebugEnabled) { + var didCreate: Boolean = false; + textStyle.font = 'Arial'; + textStyle.size = 12; + // 320x240 if no stage dimensions (happens in IE, apparently 0 before stage resize event fires.) + var w:Number = this.stage.width?this.stage.width:320; + var h:Number = this.stage.height?this.stage.height:240; + if (textField == null) { + didCreate = true; + textField = new TextField(); + textField.autoSize = TextFieldAutoSize.LEFT; + textField.x = 0; + textField.y = 0; + textField.multiline = true; + textField.textColor = 0; + textField.wordWrap = true; + } + textField.htmlText = messages.join('\n'); + textField.setTextFormat(textStyle); + textField.width = w; + textField.height = h; + if (didCreate) { + this.addChild(textField); + } + } + // + } + + public function _setAutoPlay(sID:String, autoPlay:Boolean) : void { + var s: SoundManager2_SMSound_AS3 = soundObjects[sID]; + if (s) { + s.setAutoPlay(autoPlay); + } + } + + // methods + // ----------------------------------- + + public function writeDebug (s:String, logLevel:Number = 0) : Boolean { + if (!debugEnabled) { + return false; + } + // + ExternalInterface.call(baseJSController + "['_writeDebug']", "(Flash): " + s, null, logLevel); + // + return true; + } + + public function _externalInterfaceTest(isFirstCall: Boolean) : Boolean { + var sandboxType:String = flash.system.Security['sandboxType']; + if (!didSandboxMessage && sandboxType != 'localTrusted' && sandboxType != 'remote') { + didSandboxMessage = true; + flashDebug('
    Fatal: Security sandbox error: Got "' + sandboxType + '", expected "remote" or "localTrusted".
    Additional security permissions need to be granted.
    See flash security settings panel for non-HTTP, eg., file:// use.

    http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html

    You may also be able to right-click this movie and choose from the menu:
    "Global Settings" -> "Advanced" tab -> "Trusted Location Settings"
    '); + } + try { + if (isFirstCall == true) { + flashDebug('Testing Flash -> JS...'); + ExternalInterface.call(baseJSController + "._externalInterfaceOK", version); + flashDebug('Flash -> JS OK'); + flashDebug('Waiting for JS -> Flash...'); + } else { + // writeDebug('SM2 SWF ' + version + ' ' + version_as, 1); + ExternalInterface.call(baseJSController + "._setSandboxType", sandboxType); + flashDebug('JS -> Flash OK'); + } + } catch(e: Error) { + flashDebug('Fatal: Flash <-> JS error: ' + e.toString()); + writeDebug('_externalInterfaceTest: Error: ' + e.toString(), 2); + if (!caughtFatal) { + caughtFatal = true; + } + return false; + } + return true; // to verify that a call from JS to here, works. (eg. JS receives "true", thus OK.) + } + + public function _disableDebug() : void { + // prevent future debug calls from Flash going to client (maybe improve performance) + writeDebug('_disableDebug()'); + debugEnabled = false; + } + + public function checkLoadProgress(e: Event) : void { + try { + var oSound:Object = e.target; + var bL: int = oSound.bytesLoaded; + var bT: int = oSound.bytesTotal; + var nD: int = oSound.length || oSound.duration || 0; + var sMethod:String = baseJSObject + "['" + oSound.sID + "']._whileloading"; + ExternalInterface.call(sMethod, bL, bT, nD); + if (bL && bT && bL != oSound.lastValues.bytes) { + oSound.lastValues.bytes = bL; + ExternalInterface.call(sMethod, bL, bT, nD); + } + } catch(e: Error) { + writeDebug('checkLoadProgress(): ' + e.toString()); + } + } + + public function checkSoundProgress(oSound:SoundManager2_SMSound_AS3, forceCheck:Boolean = false, forceEndCheck:Boolean = false) : void { + var bL: int = 0; + var bT: int = 0; + var nD: int = 0; + var nP: int = 0; + var bufferLength: int = 0; + var lP:Number = 0; + var rP:Number = 0; + var isBuffering:Object = null; + var oSoundChannel: flash.media.SoundChannel = null; + var sMethod:String = null; + var newPeakData: Boolean = false; + var newWaveformData: Boolean = false; + var newEQData: Boolean = false; + var areSoundsInaccessible: Boolean = SoundMixer.areSoundsInaccessible(); + var isPlaying: Boolean = true; // special case for NetStream when ending + var hasNew:Boolean = false; + var hasNewLoaded:Boolean = false; + + if (!oSound || !oSound.useEvents || oSound.failed || !oSound.connected) { + // edge cases for ignoring: if sounds are destructed within event handlers while checkProgress() is running, may be null + return; + } + + sMethod = baseJSObject + "['" + oSound.sID + "']._whileloading"; + + if (oSound.useNetstream) { + + // Don't do anything if there is no NetStream object yet + if (!oSound.ns) { + return; + } + + // stream + bufferLength = oSound.ns.bufferLength; + bL = oSound.ns.bytesLoaded; + bT = oSound.ns.bytesTotal; + nD = int(oSound.duration || 0); // can sometimes be null with short MP3s? Wack. + nP = oSound.ns.time * 1000; + + if (oSound.paused) { + // special case: paused netStreams don't update if setPosition() is called while they are paused. + // instead, return lastValues.position which should reflect setPosition() call. + // writeDebug('paused case, setting nP of '+nP+' to -1'); + // writeDebug('lastValues: '+oSound.lastValues.position); + nP = oSound.lastValues.position; + } + + if (nP >= 0 && nP != oSound.lastValues.position) { + oSound.lastValues.position = nP; + hasNew = true; + } + if (nD > oSound.lastValues.duration) { + oSound.lastValues.duration = nD; + hasNew = true; + } + if (bL > oSound.lastValues.bytesLoaded) { + oSound.lastValues.bytesLoaded = bL; + hasNew = true; + } + if (bT > oSound.lastValues.bytes) { + oSound.lastValues.bytes = bT; + hasNew = true; + } + if (bufferLength != oSound.lastValues.bufferLength) { + oSound.lastValues.bufferLength = bufferLength; + hasNew = true; + } + + // Don't set loaded for streams because bytesLoaded and bytesTotal are always 0 + // writeDebug('ns: time/duration, bytesloaded/total: '+nP+'/'+nD+', '+bL+'/'+bT); + if (oSound.loaded != true && nD > 0 && bL == bT && bL != 0 && bT != 0) { + // non-MP3 has loaded + oSound.loaded = true; + try { + ExternalInterface.call(sMethod, bL, bT, nD, bufferLength); + ExternalInterface.call(baseJSObject + "['" + oSound.sID + "']._onload", oSound.duration > 0 ? 1 : 0); + } catch(e: Error) { + writeDebug('_whileLoading/_onload error: ' + e.toString(), 2); + } + } else if (oSound.loaded != true && hasNew) { + ExternalInterface.call(sMethod, bL, bT, nD, bufferLength); + } + + } else { + + // MP3 sound + oSoundChannel = oSound.soundChannel; + bL = oSound.bytesLoaded; + bT = oSound.bytesTotal; + nD = int(oSound.length || 0); // can sometimes be null with short MP3s? Wack. + isBuffering = oSound.isBuffering; + + if (oSoundChannel) { + nP = (oSoundChannel.position || 0); + if (oSound.lastValues.loops > 1 && nP > oSound.length) { + // round down to nearest loop + var playedLoops:Number = Math.floor(nP/oSound.length); + nP = nP - (oSound.length*playedLoops); + } + if (oSound.usePeakData) { + lP = int((oSoundChannel.leftPeak) * 1000) / 1000; + rP = int((oSoundChannel.rightPeak) * 1000) / 1000; + } else { + lP = 0; + rP = 0; + } + } else { + // stopped, not loaded or feature not used + nP = 0; + } + + if (forceEndCheck) { + // sound finish case: Ensure position is at end (sound duration), as flash 9 does not always correctly match the two. + if (nP < nD) { + writeDebug('correcting sound ' + oSound.sID + ' end position ('+nP+') to length: '+ nD, 2); + nP = nD; + } + } + + if (nP != oSound.lastValues.position && nP !== 0 && !oSound.didFinish) { // once "completed", sound is locked via didFinish so no more position-type events fire. + oSound.lastValues.position = nP; + hasNew = true; + } + + if (nD > oSound.lastValues.duration) { // original sound duration * number of sound loops + oSound.lastValues.duration = nD; + hasNew = true; + } + + if (bL > oSound.lastValues.bytesLoaded) { + oSound.lastValues.bytesLoaded = bL; + hasNew = true; + } + + if (bT > oSound.lastValues.bytes) { + oSound.lastValues.bytes = bT; + hasNew = true; + hasNewLoaded = true; + } + + // loading progress + if (hasNewLoaded) { + oSound.lastValues.bytes = bL; + ExternalInterface.call(sMethod, bL, bT, nD); + } + + } + + // peak data + if (oSoundChannel && oSound.usePeakData) { + if (lP != oSound.lastValues.leftPeak) { + oSound.lastValues.leftPeak = lP; + newPeakData = true; + } + if (rP != oSound.lastValues.rightPeak) { + oSound.lastValues.rightPeak = rP; + newPeakData = true; + } + } + + var newDataError:Boolean = false; + var dataError:String; + + // special case: Netstream may try to fire whileplaying() after finishing. check that stop hasn't fired. + isPlaying = (oSound.didLoad && !oSound.paused && (!oSound.useNetstream || (oSound.useNetstream && oSound.lastNetStatus != "NetStream.Play.Stop"))); // don't update if stream has ended + + // raw waveform + EQ spectrum data + if (isPlaying && (oSoundChannel || oSound.useNetstream)) { + + if (oSound.useWaveformData) { + if (!areSoundsInaccessible && !oSound.handledDataError && !oSound.ignoreDataError) { + try { + oSound.getWaveformData(); + } catch(e: Error) { + if (!oSound.handledDataError) { + writeDebug('getWaveformData() (waveform data) '+e.toString()); + } + // oSound.useWaveformData = false; + newDataError = true; + dataError = e.toString(); + } + } + } + + if (oSound.useEQData) { + if (!areSoundsInaccessible && !oSound.handledDataError && !oSound.ignoreDataError) { + try { + oSound.getEQData(); + } catch(e: Error) { + if (!oSound.handledDataError) { + writeDebug('computeSpectrum() (EQ data) '+e.toString()); + } + // oSound.useEQData = false; + newDataError = true; + dataError = e.toString(); + } + } + } + + if (oSound.waveformDataArray != oSound.lastValues.waveformDataArray) { + oSound.lastValues.waveformDataArray = oSound.waveformDataArray; + newWaveformData = true; + } + + if (oSound.eqDataArray != oSound.lastValues.eqDataArray) { + oSound.lastValues.eqDataArray = oSound.eqDataArray; + newEQData = true; + } + + if (newDataError && !oSound.handledDataError) { + sMethod = baseJSObject + "['" + oSound.sID + "']._ondataerror"; + ExternalInterface.call(sMethod, 'data unavailable: ' + dataError); + oSound.handledDataError = true; + } + + } + + if (typeof nP != 'undefined' && (hasNew && (oSound.soundChannel || oSound.useNetstream || forceCheck || forceEndCheck))) { // && isPlaying - removed to allow updates while paused, eg. from setPosition() calls. Also be more liberal if we're using netStream. + + // oSound.lastValues.position = nP; + sMethod = baseJSObject + "['" + oSound.sID + "']._whileplaying"; + var waveDataLeft:String = (newWaveformData ? oSound.waveformDataArray.slice(0, 256).join(',') : null); + var waveDataRight:String = (newWaveformData ? oSound.waveformDataArray.slice(256).join(',') : null); + var eqDataLeft:String = (newEQData ? oSound.eqDataArray.slice(0, 256).join(',') : null); + var eqDataRight:String = (newEQData ? oSound.eqDataArray.slice(256).join(',') : null); + ExternalInterface.call(sMethod, nP, (newPeakData ? { + leftPeak: lP, + rightPeak: rP + } : null), waveDataLeft, waveDataRight, (newEQData ? { + leftEQ: eqDataLeft, + rightEQ: eqDataRight + } : null)); + } + + // check isBuffering + if (!oSound.useNetstream && oSound.isBuffering != oSound.lastValues.isBuffering) { + // property has changed + oSound.lastValues.isBuffering = oSound.isBuffering; + sMethod = baseJSObject + "['" + oSound.sID + "']._onbufferchange"; + ExternalInterface.call(sMethod, oSound.isBuffering ? 1 : 0); + } + + } + + public function checkProgress() : void { + for (var i: int = 0, j: int = sounds.length; i < j; i++) { + checkSoundProgress(soundObjects[sounds[i]]); + } + } + + public function onLoadError(oSound:Object) : void { + // something went wrong. 404, bad format etc. + ExternalInterface.call(baseJSObject + "['" + oSound.sID + "']._onload", 0); + } + + public function onLoad(e: Event) : void { + var oSound:Object = e.target; + checkSoundProgress(soundObjects[oSound.sID]); // ensure progress stats are up-to-date + if (!oSound.useNetstream) { // FLV must also have metadata + oSound.loaded = true; + // force duration update (doesn't seem to be always accurate) + ExternalInterface.call(baseJSObject + "['" + oSound.sID + "']._whileloading", oSound.bytesLoaded, oSound.bytesTotal, oSound.length || oSound.duration); + // duration > 0 means a valid sound was loaded. + ExternalInterface.call(baseJSObject + "['" + oSound.sID + "']._onload", (oSound.length || oSound.duration ? 1 : 0)); + } + } + + public function onID3(e: Event) : void { + + // --- NOTE: BUGGY (Flash 8 only? Haven't really checked 9 + 10.) --- + // TODO: Investigate holes in ID3 parsing - for some reason, Album will be populated with Date if empty and date is provided. (?) + // ID3V1 seem to parse OK, but "holes" / blanks in ID3V2 data seem to get messed up (eg. missing album gets filled with date.) + // iTunes issues: onID3 was not called with a test MP3 encoded with iTunes 7.01, and what appeared to be valid ID3V2 data. + // May be related to thumbnails for album art included in MP3 file by iTunes. See http://mabblog.com/blog/?p=33 + try { + var oSound:Object = e.target; + + var id3Data:Array = []; + var id3Props:Array = []; + for (var prop:String in oSound.id3) { + id3Props.push(prop); + id3Data.push(oSound.id3[prop]); + // writeDebug('id3['+prop+']: '+oSound.id3[prop]); + } + ExternalInterface.call(baseJSObject + "['" + oSound.sID + "']._onid3", id3Props, id3Data); + // unhook own event handler, prevent second call (can fire twice as data is received - ID3V2 at beginning, ID3V1 at end.) + // Therefore if ID3V2 data is received, ID3V1 is ignored. + // soundObjects[oSound.sID].onID3 = null; + } catch(e: Error) { + writeDebug('onID3(): Unable to get ID3 info for ' + oSound.sID + '.'); + } + oSound.removeEventListener(Event.ID3, onID3); + } + + public function registerOnComplete(sID:String) : void { + var oSound: SoundManager2_SMSound_AS3 = soundObjects[sID]; + if (oSound && oSound.soundChannel) { + oSound.didFinish = false; // reset this flag + oSound.soundChannel.addEventListener(Event.SOUND_COMPLETE, function() : void { + if (oSound) { + // force progress check, catching special end-of-sound case where position may not match duration. + checkSoundProgress(oSound, true, true); + try { + oSound.ignoreDataError = true; // workaround: avoid data error handling for this manual step.. + // oSound.soundChannel.stop(); + oSound.didFinish = true; // "lock" sound, prevent extra whileplaying() position-type updates + // call onfinish first (with end position)... + ExternalInterface.call(baseJSObject + "['" + sID + "']._onfinish"); + // then reset sound so it can be played again. + // oSound.start(0, 1); // go back to 0 + } catch(e: Error) { + writeDebug('Could not set position on ' + sID + ': ' + e.toString()); + } + oSound.ignoreDataError = false; // ..and reset + oSound.handledDataError = false; // reset this flag + } else { + // safety net + ExternalInterface.call(baseJSObject + "['" + sID + "']._onfinish"); + } + }); + } + } + + public function doSecurityError(oSound: SoundManager2_SMSound_AS3, e: SecurityErrorEvent) : void { + writeDebug('securityError: ' + e.text); + // when this happens, you don't have security rights on the server containing the FLV file + // a crossdomain.xml file would fix the problem easily + } + + public function _setPosition(sID:String, nSecOffset:Number, isPaused: Boolean, allowMultiShot: Boolean) : void { + var s: SoundManager2_SMSound_AS3 = soundObjects[sID]; + if (!s) return void; + // writeDebug('_setPosition()'); + + // stop current channel, start new one. + if (s.lastValues) { + s.lastValues.position = nSecOffset; // s.soundChannel.position; + } + if (s.useNetstream) { + // Minimize the buffer so playback starts ASAP + s.ns.bufferTime = s.bufferTime; + writeDebug('setPosition ('+ sID + '): setting buffer to '+s.ns.bufferTime+' secs'); + + nSecOffset = nSecOffset > 0 ? nSecOffset / 1000 : 0; + s.ns.seek(nSecOffset); + checkSoundProgress(s); // force UI update + } else { + if (s.soundChannel) { + s.soundChannel.stop(); + } + writeDebug('setPosition ('+ sID + '): ' + nSecOffset); // +', '+(s.lastValues.loops?s.lastValues.loops:1)); + if (s.lastValues.loops > 1 && nSecOffset != 0) { + writeDebug('Warning: Looping functionality being disabled due to Flash limitation.'); + s.lastValues.loops = 1; + } + try { + s.start(nSecOffset, s.lastValues.loops || 1, allowMultiShot); // start playing at new position + } catch(e: Error) { + writeDebug('Warning: Could not set position on ' + sID + ': ' + e.toString()); + } + checkSoundProgress(s); // force UI update + try { + registerOnComplete(sID); + } catch(e: Error) { + writeDebug('_setPosition(): Could not register onComplete'); + } + if (isPaused && s.soundChannel) { + // writeDebug('_setPosition: stopping (paused) sound'); + // writeDebug('last position: '+s.lastValues.position+' vs '+s.soundChannel.position); + s.soundChannel.stop(); + } + } + } + + public function _load(sID:String, sURL:String, bStream: Boolean, bAutoPlay: Boolean, nLoops: Number, bAutoLoad: Boolean, bCheckPolicyFile: Boolean) : void { + // writeDebug('_load()'); + if (typeof bAutoPlay == 'undefined') bAutoPlay = false; + var s: SoundManager2_SMSound_AS3 = soundObjects[sID]; + if (!s) return void; + var didRecreate: Boolean = false; + if (s.didLoad == true) { + // need to recreate sound + didRecreate = true; + writeDebug('recreating sound ' + sID + ' in order to load ' + sURL); + var ns:Object = new Object(); + ns.sID = s.sID; + ns.loops = nLoops||1; + ns.usePeakData = s.usePeakData; + ns.useWaveformData = s.useWaveformData; + ns.useEQData = s.useEQData; + ns.useNetstream = s.useNetstream; + ns.bufferTime = s.bufferTime; + ns.serverUrl = s.serverUrl; + ns.duration = s.duration; + ns.checkPolicyFile = s.checkPolicyFile; + ns.useEvents = true; + _destroySound(s.sID); + _createSound(ns.sID, sURL, ns.usePeakData, ns.useWaveformData, ns.useEQData, ns.useNetstream, ns.bufferTime, ns.loops, ns.serverUrl, ns.duration, bAutoPlay, ns.useEvents, bAutoLoad, ns.checkPolicyFile); + s = soundObjects[sID]; + // writeDebug('Sound object replaced'); + } + checkSoundProgress(s); + + if (!s.didLoad) { + try { + s.addEventListener(Event.ID3, onID3); + s.addEventListener(Event.COMPLETE, onLoad); + } catch(e: Error) { + writeDebug('_load(): could not assign ID3/complete event handlers'); + } + } + + // don't try to load if same request already made + s.sURL = sURL; + + try { + if (!s.useNetstream) { + s.addEventListener(IOErrorEvent.IO_ERROR, function(e: IOErrorEvent) : void { + s.doIOError(e); + }); + } + s.loadSound(sURL); + } catch(e: Error) { + // oh well + writeDebug('_load: Error loading ' + sURL + '. Flash error detail: ' + e.toString()); + } + + } + + public function _unload(sID:String) : void { + var s: SoundManager2_SMSound_AS3 = (soundObjects[sID] || null); + if (!s) return void; + var sURL:String = s.sURL; // save existing sound URL for object recreation + try { + removeEventListener(Event.ID3, onID3); + removeEventListener(Event.COMPLETE, onLoad); + } catch(e: Error) { + writeDebug('_unload() warn: Could not remove ID3/complete events'); + } + s.paused = false; + if (s.soundChannel) { + s.soundChannel.stop(); + } + try { + if (s.didLoad && !s.loaded && !s.useNetstream) { + s.close(); // close stream only if still loading? + } + } catch(e: Error) { + // stream may already have closed if sound loaded, etc. + writeDebug(sID + '._unload(): Note: Unable to close stream: ' + e.toString()); + // oh well + } + // destroy and recreate Flash sound object, try to reclaim memory + // writeDebug('sound._unload(): recreating sound '+sID+' to free memory'); + if (s.useNetstream) { + // writeDebug('_unload(): closing netStream stuff'); + try { + s.removeNetstreamEvents(); + s.ns.close(); + s.nc.close(); + // s.nc = null; + // s.ns = null; + } catch(e: Error) { + // oh well + writeDebug('_unload(): caught exception during netConnection/netStream close'); + } + } + var ns:Object = new Object(); + ns.sID = s.sID; + ns.loops = s.loops; + ns.usePeakData = s.usePeakData; + ns.useWaveformData = s.useWaveformData; + ns.useEQData = s.useEQData; + ns.useNetstream = s.useNetstream; + ns.bufferTime = s.bufferTime; + ns.serverUrl = s.serverUrl; + ns.duration = s.duration; + ns.autoPlay = s.autoPlay; + ns.autoLoad = s.autoLoad; + ns.checkPolicyFile = s.checkPolicyFile; + _destroySound(s.sID); + _createSound(ns.sID, sURL, ns.usePeakData, ns.useWaveformData, ns.useEQData, ns.useNetstream, ns.bufferTime, ns.loops, ns.serverUrl, ns.duration, ns.autoPlay, false, ns.autoLoad, ns.checkPolicyFile); // false: don't allow events just yet + soundObjects[sID].connected = true; // fake it? + writeDebug(s.sID + '.unload(): ok'); + } + + public function _createSound(sID:String, sURL:String, usePeakData: Boolean, useWaveformData: Boolean, useEQData: Boolean, useNetstream: Boolean, bufferTime:Number, loops:Number, serverUrl:String, duration:Number, autoPlay:Boolean, useEvents:Boolean, autoLoad:Boolean, checkPolicyFile:Boolean) : void { + var s: SoundManager2_SMSound_AS3 = new SoundManager2_SMSound_AS3(this, sID, sURL, usePeakData, useWaveformData, useEQData, useNetstream, bufferTime, serverUrl, duration, autoPlay, useEvents, autoLoad, checkPolicyFile); + if (!soundObjects[sID]) { + sounds.push(sID); + } + soundObjects[sID] = s; + this.currentObject = s; + s.sID = sID; + s.sURL = sURL; + s.paused = false; + s.loaded = false; + s.checkPolicyFile = checkPolicyFile; + s.lastValues = { + bytes: 0, + duration: 0, + position: 0, + loops: loops||1, + leftPeak: 0, + rightPeak: 0, + bufferLength: 0 + }; + } + + public function _destroySound(sID:String) : void { + // for the power of garbage collection! .. er, Greyskull! + var s: SoundManager2_SMSound_AS3 = (soundObjects[sID] || null); + if (!s) return void; + // try to unload the sound + for (var i: int = 0, j: int = sounds.length; i < j; i++) { + if (sounds[i] == sID) { + sounds.splice(i, 1); + break; + } + } + if (s.soundChannel) { + s.soundChannel.stop(); + } + // if is a movie, remove that as well. + if (s.useNetstream) { + // s.nc.client = null; + try { + s.removeNetstreamEvents(); + // s.nc.removeEventListener(NetStatusEvent.NET_STATUS, s.doNetStatus); + } catch(e: Error) { + writeDebug('_destroySound(): Events already removed from netStream/netConnection?'); + } + if (s.didLoad) { + // TODO: figure out if stream is still open first, can't close an already-closed stream. + try { + s.ns.close(); + s.nc.close(); + } catch(e: Error) { + // oh well + writeDebug('_destroySound(): caught exception: '+e.toString()); + } + } + } else if (s.didLoad) { + // non-netstream case + try { + s.close(); // close stream only if still loading? + } catch(e: Error) { + // oh well + } + } + s = null; + soundObjects[sID] = null; + delete soundObjects[sID]; + } + + public function _stop(sID:String, bStopAll: Boolean) : void { + // stop this particular instance (or "all", based on parameter) + if (bStopAll) { + SoundMixer.stopAll(); + } else { + var s: SoundManager2_SMSound_AS3 = soundObjects[sID]; + if (!s) return void; + if (s.useNetstream && s.ns) { + s.ns.pause(); + } else if (s.soundChannel) { + s.soundChannel.stop(); + } + s.paused = false; + } + } + + public function _start(sID:String, nLoops: int, nMsecOffset: int, allowMultiShot: Boolean) : Boolean { + var s: SoundManager2_SMSound_AS3 = soundObjects[sID]; + var result: Boolean; + if (!s) return true; + writeDebug('start (' + sID + '): ' + nMsecOffset + (nLoops > 1 ? ', loops: ' + nLoops : '')); + s.lastValues.paused = false; // reset pause if applicable + s.lastValues.loops = (nLoops || 1); + if (!s.useNetstream) { + s.lastValues.position = nMsecOffset; + } + s.handledDataError = false; // reset this flag + try { + result = s.start(nMsecOffset, nLoops, allowMultiShot); + } catch(e: Error) { + writeDebug('Could not start ' + sID + ': ' + e.toString()); + } + try { + registerOnComplete(sID); + } catch(e: Error) { + writeDebug('_start(): registerOnComplete failed'); + } + return result; + } + + public function _pause(sID:String, allowMultiShot: Boolean) : void { + // writeDebug('_pause(): ' + sID); + var s: SoundManager2_SMSound_AS3 = soundObjects[sID]; + if (!s) return void; + // writeDebug('s.paused: '+s.paused); + if (!s.paused) { + // reference current position, stop sound + s.paused = true; + // writeDebug('_pause(): position: '+s.lastValues.position); + if (s.useNetstream) { + if (s.ns) { + s.lastValues.position = s.ns.time*1000; + s.ns.pause(); + } else if (s.autoPlay) { + s.setAutoPlay(false); + } + } else { + if (s.soundChannel) { + s.lastValues.position = s.soundChannel.position; + s.soundChannel.stop(); + } + } + } else { + // resume playing from last position + // writeDebug('resuming - playing at '+s.lastValues.position+', '+s.lastValues.loops+' times'); + s.paused = false; + if (s.useNetstream) { + s.ns.resume(); + } else { + s.start(s.lastValues.position, s.lastValues.loops, allowMultiShot); + } + try { + registerOnComplete(sID); + } catch(e: Error) { + writeDebug('_pause(): registerOnComplete() failed'); + } + } + } + + public function _setPan(sID:String, nPan:Number) : void { + if (soundObjects[sID]) { + soundObjects[sID].setPan(nPan); + } + } + + public function _setVolume(sID:String, nVol:Number) : void { + // writeDebug('_setVolume: '+nVol); + if (soundObjects[sID]) { + soundObjects[sID].setVolume(nVol); + } + } + + public function _setPolling(bPolling: Boolean = false, nTimerInterval: uint = 50) : void { + pollingEnabled = bPolling; + if (timer == null && pollingEnabled) { + flashDebug('Enabling polling, ' + nTimerInterval + ' ms interval'); + timer = new Timer(nTimerInterval, 0); + timer.addEventListener(TimerEvent.TIMER, function() : void { + checkProgress(); + }); // direct reference eg. checkProgress doesn't work? .. odd. + timer.start(); + } else if (timer && !pollingEnabled) { + flashDebug('Disabling polling'); + // flash.utils.clearInterval(timer); + timer.reset(); + } + } + + public function _getMemoryUse() : String { + return System.totalMemory.toString(); + } + + // ----------------------------------- + // end methods + + } + + // package + +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/SoundManager2_SMSound_AS3.as b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/SoundManager2_SMSound_AS3.as new file mode 100755 index 00000000..d240bc5b --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/SoundManager2_SMSound_AS3.as @@ -0,0 +1,585 @@ +/** + * SoundManager 2: Javascript Sound for the Web + * ---------------------------------------------- + * http://schillmania.com/projects/soundmanager2/ + * + * Copyright (c) 2007, Scott Schiller. All rights reserved. + * Code licensed under the BSD License: + * http://www.schillmania.com/projects/soundmanager2/license.txt + * + * Flash 9 / ActionScript 3 version + */ + +package { + + import flash.external.*; + import flash.events.*; + import flash.media.Sound; + import flash.media.SoundChannel; + import flash.media.SoundLoaderContext; + import flash.media.SoundTransform; + import flash.media.SoundMixer; + import flash.net.URLRequest; + import flash.utils.ByteArray; + import flash.utils.getTimer; + import flash.net.NetConnection; + import flash.net.NetStream; + import flash.net.Responder; + + public class SoundManager2_SMSound_AS3 extends Sound { + + public var sm: SoundManager2_AS3 = null; + // externalInterface references (for Javascript callbacks) + public var baseJSController: String = "soundManager"; + public var baseJSObject: String = baseJSController + ".sounds"; + public var soundChannel: SoundChannel = new SoundChannel(); + public var urlRequest: URLRequest; + public var soundLoaderContext: SoundLoaderContext; + public var waveformData: ByteArray = new ByteArray(); + public var waveformDataArray: Array = []; + public var eqData: ByteArray = new ByteArray(); + public var eqDataArray: Array = []; + public var usePeakData: Boolean = false; + public var useWaveformData: Boolean = false; + public var useEQData: Boolean = false; + public var sID: String; + public var sURL: String; + public var didFinish: Boolean; + public var loaded: Boolean; + public var connected: Boolean; + public var failed: Boolean; + public var paused: Boolean; + public var finished: Boolean; + public var duration: Number; + public var handledDataError: Boolean = false; + public var ignoreDataError: Boolean = false; + public var autoPlay: Boolean = false; + public var autoLoad: Boolean = false; + public var pauseOnBufferFull: Boolean = false; // only applies to RTMP + public var loops: Number = 1; + public var lastValues: Object = { + bytes: 0, + position: 0, + duration: 0, + volume: 100, + pan: 0, + loops: 1, + leftPeak: 0, + rightPeak: 0, + waveformDataArray: null, + eqDataArray: null, + isBuffering: null, + bufferLength: 0 + }; + public var didLoad: Boolean = false; + public var useEvents: Boolean = false; + public var sound: Sound = new Sound(); + + public var cc: Object; + public var nc: NetConnection; + public var ns: NetStream = null; + public var st: SoundTransform; + public var useNetstream: Boolean; + public var bufferTime: Number = 3; // previously 0.1 + public var lastNetStatus: String = null; + public var serverUrl: String = null; + + public var checkPolicyFile:Boolean = false; + + public function SoundManager2_SMSound_AS3(oSoundManager: SoundManager2_AS3, sIDArg: String = null, sURLArg: String = null, usePeakData: Boolean = false, useWaveformData: Boolean = false, useEQData: Boolean = false, useNetstreamArg: Boolean = false, netStreamBufferTime: Number = 1, serverUrl: String = null, duration: Number = 0, autoPlay: Boolean = false, useEvents: Boolean = false, autoLoad: Boolean = false, checkPolicyFile: Boolean = false) { + this.sm = oSoundManager; + this.sID = sIDArg; + this.sURL = sURLArg; + this.usePeakData = usePeakData; + this.useWaveformData = useWaveformData; + this.useEQData = useEQData; + this.urlRequest = new URLRequest(sURLArg); + this.didFinish = false; + this.loaded = false; + this.connected = false; + this.failed = false; + this.finished = false; + this.soundChannel = null; + this.lastNetStatus = null; + this.useNetstream = useNetstreamArg; + this.serverUrl = serverUrl; + this.duration = duration; + this.useEvents = useEvents; + this.autoLoad = autoLoad; + if (netStreamBufferTime) { + this.bufferTime = netStreamBufferTime; + } + this.checkPolicyFile = checkPolicyFile; + + writeDebug('SoundManager2_SMSound_AS3: Got duration: '+duration+', autoPlay: '+autoPlay); + + if (this.useNetstream) { + // Pause on buffer full if auto-loading an RTMP stream + if (this.serverUrl && this.autoLoad) { + this.pauseOnBufferFull = true; + } + + this.cc = new Object(); + this.nc = new NetConnection(); + + // Handle FMS bandwidth check callback. + // @see onBWDone + // @see http://www.adobe.com/devnet/flashmediaserver/articles/dynamic_stream_switching_04.html + // @see http://www.johncblandii.com/index.php/2007/12/fms-a-quick-fix-for-missing-onbwdone-onfcsubscribe-etc.html + this.nc.client = this; + + // TODO: security/IO error handling + // this.nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, doSecurityError); + nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); + + if (this.serverUrl != null) { + writeDebug('SoundManager2_SMSound_AS3: NetConnection: connecting to server ' + this.serverUrl + '...'); + } + this.nc.connect(serverUrl); + } else { + this.connected = true; + } + + } + + public function rtmpResponder(result:Object):void { + // callback from Flash Media Server (RTMP) for 'getStreamLength' server-side method - result should be a floating-point. + // http://help.adobe.com/en_US/FlashMediaServer/3.5_Deving/WS5b3ccc516d4fbf351e63e3d11a0773d117-7ffe.html + writeDebug('RTMP server getStreamLength() response: ' + result); + // we now know the duration. type cast to floating-point - this will update JS-land during whileloading() / whileplaying(). + this.duration = Number(result) * 1000; + } + + public function netStatusHandler(event:NetStatusEvent):void { + + if (this.useEvents) { + writeDebug('netStatusHandler: '+event.info.code); + } + + switch (event.info.code) { + + case "NetConnection.Connect.Success": + try { + this.ns = new NetStream(this.nc); + this.ns.checkPolicyFile = this.checkPolicyFile; + // bufferTime reference: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/NetStream.html#bufferTime + this.ns.bufferTime = this.bufferTime; // set to 0.1 or higher. 0 is reported to cause playback issues with static files. + this.st = new SoundTransform(); + this.cc.onMetaData = this.onMetaData; + this.cc.setCaption = this.captionHandler; + this.ns.client = this.cc; + this.ns.receiveAudio(true); + this.addNetstreamEvents(); + this.connected = true; + // RTMP-only + if (this.serverUrl && this.useEvents) { + var responder:Responder = new Responder(rtmpResponder); + // call a method on server to get the length of the stream (like onMetaData, but Flash Media Server-specific) + // Red5 and other RTMP servers appear to provide duration via onMetaData event(s) in the stream. + // http://help.adobe.com/en_US/FlashMediaServer/3.5_Deving/WS5b3ccc516d4fbf351e63e3d11a0773d117-7ffe.html + nc.call('getStreamLength', responder, this.sURL); + writeDebug('NetConnection: connected'); + writeDebug('firing _onconnect for '+this.sID); + ExternalInterface.call(this.sm.baseJSObject + "['" + this.sID + "']._onconnect", 1); + } + } catch(e: Error) { + this.failed = true; + writeDebug('netStream error: ' + e.toString()); + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfailure", 'Connection failed!', event.info.level, event.info.code); + } + break; + + case "NetStream.Play.StreamNotFound": + this.failed = true; + writeDebug("NetConnection: Stream not found!"); + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfailure", 'Stream not found!', event.info.level, event.info.code); + break; + + // This is triggered when the sound loses the connection with the server. + // In some cases one could just try to reconnect to the server and resume playback. + // However for streams protected by expiring tokens, I don't think that will work. + // + // Flash says that this is not an error code, but a status code... + // should this call the onFailure handler? + case "NetConnection.Connect.Closed": + this.failed = true; + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfailure", 'Connection closed!', event.info.level, event.info.code); + writeDebug("NetConnection: Connection closed!"); + break; + + // Couldn't establish a connection with the server. Attempts to connect to the server + // can also fail if the permissible number of socket connections on either the client + // or the server computer is at its limit. This also happens when the internet + // connection is lost. + case "NetConnection.Connect.Failed": + this.failed = true; + writeDebug("NetConnection: Connection failed! Lost internet connection? Try again... Description: " + event.info.description); + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfailure", 'Connection failed!', event.info.level, event.info.code); + break; + + // A change has occurred to the network status. This could mean that the network + // connection is back, or it could mean that it has been lost...just try to resume + // playback. + + // KJV: Can't use this yet because by the time you get your connection back the + // song has reached it's maximum retries, so it doesn't retry again. We need + // a new _ondisconnect handler. + //case "NetConnection.Connect.NetworkChange": + // this.failed = true; + // writeDebug("NetConnection: Network connection status changed"); + // ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfailure", 'Reconnecting...'); + // break; + + // Consider everything else a failure... + default: + this.failed = true; + writeDebug("NetConnection: got unhandled code '" + event.info.code + "'! Description: " + event.info.description); + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfailure", '', event.info.level, event.info.code); + break; + } + + } + + public function writeDebug (s: String, logLevel: Number = 0) : Boolean { + return this.sm.writeDebug (s,logLevel); // defined in main SM object + } + + public function onMetaData(infoObject: Object) : void { + var prop:String; + if (sm.debugEnabled) { + var data:String = new String(); + for (prop in infoObject) { + data += prop+': '+infoObject[prop]+' \n'; + } + writeDebug('Metadata: '+data); + } + this.duration = infoObject.duration * 1000; + if (!this.loaded) { + // writeDebug('not loaded yet: '+this.ns.bytesLoaded+', '+this.ns.bytesTotal+', '+infoObject.duration*1000); + // TODO: investigate loaded/total values + // ExternalInterface.call(baseJSObject + "['" + this.sID + "']._whileloading", this.ns.bytesLoaded, this.ns.bytesTotal, infoObject.duration*1000); + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._whileloading", this.bytesLoaded, this.bytesTotal, (this.duration || infoObject.duration)) + } + var metaData:Array = []; + var metaDataProps:Array = []; + for (prop in infoObject) { + metaData.push(prop); + metaDataProps.push(infoObject[prop]); + } + // pass infoObject to _onmetadata, too + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onmetadata", metaData, metaDataProps); + // this handler may fire multiple times, eg., when a song changes while playing an RTMP stream. + if (!this.serverUrl) { + // disconnect for non-RTMP cases, since multiple firings may mess up duration. + this.cc.onMetaData = function(infoObject: Object) : void {} + } + } + + public function captionHandler(infoObject: Object) : void { + + if (sm.debugEnabled) { + var data:String = new String(); + for (var prop:* in infoObject) { + data += prop+': '+infoObject[prop]+' \n'; + } + writeDebug('Caption: '+data); + } + + // null this out for the duration of this object's existence. + // it may be called multiple times. + // this.cc.setCaption = function(infoObject: Object) : void {} + + // writeDebug('Caption\n'+infoObject['dynamicMetadata']); + // writeDebug('firing _oncaptiondata for '+this.sID); + + ExternalInterface.call(this.sm.baseJSObject + "['" + this.sID + "']._oncaptiondata", infoObject['dynamicMetadata']); + + } + + public function getWaveformData() : void { + // http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/SoundMixer.html#computeSpectrum() + SoundMixer.computeSpectrum(this.waveformData, false, 0); // sample wave data at 44.1 KHz + this.waveformDataArray = []; + for (var i: int = 0, j: int = this.waveformData.length / 4; i < j; i++) { // get all 512 values (256 per channel) + this.waveformDataArray.push(int(this.waveformData.readFloat() * 1000) / 1000); + } + } + + public function getEQData() : void { + // http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/SoundMixer.html#computeSpectrum() + SoundMixer.computeSpectrum(this.eqData, true, 0); // sample EQ data at 44.1 KHz + this.eqDataArray = []; + for (var i: int = 0, j: int = this.eqData.length / 4; i < j; i++) { // get all 512 values (256 per channel) + this.eqDataArray.push(int(this.eqData.readFloat() * 1000) / 1000); + } + } + + public function start(nMsecOffset: int, nLoops: int, allowMultiShot:Boolean) : Boolean { + + this.useEvents = true; + + if (this.useNetstream) { + + writeDebug("SMSound::start nMsecOffset "+ nMsecOffset+ ' nLoops '+nLoops + ' current bufferTime '+this.ns.bufferTime+' current bufferLength '+this.ns.bufferLength+ ' this.lastValues.position '+this.lastValues.position); + + // mark for later Netstream.Play.Stop / sound completion + this.finished = false; + + this.cc.onMetaData = this.onMetaData; + + // Don't seek if we don't have to because it destroys the buffer + var set_position:Boolean = this.lastValues.position != null && this.lastValues.position != nMsecOffset; + + if (set_position) { + // Minimize the buffer so playback starts ASAP + this.ns.bufferTime = this.bufferTime; + } + + if (this.paused) { + writeDebug('start: resuming from paused state'); + this.ns.resume(); // get the sound going again + if (!this.didLoad) { + this.didLoad = true; + } + this.paused = false; + } else if (!this.didLoad) { + writeDebug('start: !didLoad - playing '+this.sURL); + this.ns.play(this.sURL); + this.pauseOnBufferFull = false; // SAS: playing behaviour overrides buffering behaviour + this.didLoad = true; + this.paused = false; + } else { + // previously loaded, perhaps stopped/finished. play again? + writeDebug('playing again (not paused, didLoad = true)'); + this.pauseOnBufferFull = false; + this.ns.play(this.sURL); + } + + // KJV seek after calling play otherwise some streams get a NetStream.Seek.Failed + // Should only apply to the !didLoad case, but do it for all for simplicity. + // nMsecOffset is in milliseconds for streams but in seconds for progressive + // download. + if (set_position) { + this.ns.seek(this.serverUrl ? nMsecOffset / 1000 : nMsecOffset); + this.lastValues.position = nMsecOffset; // https://gist.github.com/1de8a3113cf33d0cff67 + } + + // this.ns.addEventListener(Event.SOUND_COMPLETE, _onfinish); + this.applyTransform(); + + } else { + // writeDebug('start: seeking to '+nMsecOffset+', '+nLoops+(nLoops==1?' loop':' loops')); + if (!this.soundChannel || allowMultiShot) { + this.soundChannel = this.play(nMsecOffset, nLoops); + this.addEventListener(Event.SOUND_COMPLETE, _onfinish); + this.applyTransform(); + } else { + // writeDebug('start: was already playing, no-multishot case. Seeking to '+nMsecOffset+', '+nLoops+(nLoops==1?' loop':' loops')); + // already playing and no multi-shot allowed, so re-start and set position + if (this.soundChannel) { + this.soundChannel.stop(); + } + this.soundChannel = this.play(nMsecOffset, nLoops); // start playing at new position + this.addEventListener(Event.SOUND_COMPLETE, _onfinish); + this.applyTransform(); + } + } + + // if soundChannel is null (and not a netStream), there is no sound card (or 32-channel ceiling has been hit.) + // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html#play%28%29 + return (!this.useNetstream && this.soundChannel === null ? false : true); + + } + + private function _onfinish() : void { + this.removeEventListener(Event.SOUND_COMPLETE, _onfinish); + } + + public function loadSound(sURL: String) : void { + if (this.useNetstream) { + this.useEvents = true; + if (this.didLoad != true) { + this.ns.play(this.sURL); // load streams by playing them + if (!this.autoPlay) { + this.pauseOnBufferFull = true; + } + this.paused = false; + } + // this.addEventListener(Event.SOUND_COMPLETE, _onfinish); + this.applyTransform(); + } else { + try { + this.didLoad = true; + this.urlRequest = new URLRequest(sURL); + this.soundLoaderContext = new SoundLoaderContext(1000, this.checkPolicyFile); // check for policy (crossdomain.xml) file on remote domains - http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/media/SoundLoaderContext.html + this.load(this.urlRequest, this.soundLoaderContext); + } catch(e: Error) { + writeDebug('error during loadSound(): ' + e.toString()); + } + } + } + + // Set the value of autoPlay + public function setAutoPlay(autoPlay: Boolean) : void { + if (!this.serverUrl) { + this.autoPlay = autoPlay; + } else { + this.autoPlay = autoPlay; + if (this.autoPlay) { + this.pauseOnBufferFull = false; + } else if (!this.autoPlay) { + this.pauseOnBufferFull = true; + } + } + } + + public function setVolume(nVolume: Number) : void { + this.lastValues.volume = nVolume / 100; + this.applyTransform(); + } + + public function setPan(nPan: Number) : void { + this.lastValues.pan = nPan / 100; + this.applyTransform(); + } + + public function applyTransform() : void { + var st: SoundTransform = new SoundTransform(this.lastValues.volume, this.lastValues.pan); + if (this.useNetstream) { + if (this.ns) { + this.ns.soundTransform = st; + } else { + // writeDebug('applyTransform(): Note: No active netStream'); + } + } else if (this.soundChannel) { + this.soundChannel.soundTransform = st; // new SoundTransform(this.lastValues.volume, this.lastValues.pan); + } + } + + // Handle FMS bandwidth check callback. + // @see http://www.adobe.com/devnet/flashmediaserver/articles/dynamic_stream_switching_04.html + // @see http://www.johncblandii.com/index.php/2007/12/fms-a-quick-fix-for-missing-onbwdone-onfcsubscribe-etc.html + public function onBWDone() : void { + // writeDebug('onBWDone: called and ignored'); + } + + // NetStream client callback. Invoked when the song is complete. + public function onPlayStatus(info:Object):void { + writeDebug('onPlayStatus called with '+info); + switch(info.code) { + case "NetStream.Play.Complete": + writeDebug('Song has finished!'); + break; + } + } + + public function doIOError(e: IOErrorEvent) : void { + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onload", 0); // call onload, assume it failed. + // there was a connection drop, a loss of internet connection, or something else wrong. 404 error too. + } + + public function doAsyncError(e: AsyncErrorEvent) : void { + writeDebug('asyncError: ' + e.text); + } + + public function doNetStatus(e: NetStatusEvent) : void { + + // Handle failures + if (e.info.code == "NetStream.Failed" + || e.info.code == "NetStream.Play.FileStructureInvalid" + || e.info.code == "NetStream.Play.StreamNotFound") { + + this.lastNetStatus = e.info.code; + writeDebug('netStatusEvent: ' + e.info.code); + this.failed = true; + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfailure", '', e.info.level, e.info.code); + return; + } + + writeDebug('netStatusEvent: ' + e.info.code); // KJV we like to see all events + + // When streaming, Stop is called when buffering stops, not when the stream is actually finished. + // @see http://www.actionscript.org/forums/archive/index.php3/t-159194.html + if (e.info.code == "NetStream.Play.Stop") { + + if (!this.finished && (!this.useNetstream || !this.serverUrl)) { + + // finished playing, and not RTMP + writeDebug('calling onfinish for a sound'); + // reset the sound? Move back to position 0? + this.sm.checkProgress(); + this.finished = true; // will be reset via JS callback + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfinish"); + + } + + } else if (e.info.code == "NetStream.Play.Start" || e.info.code == "NetStream.Buffer.Empty" || e.info.code == "NetStream.Buffer.Full") { + + // RTMP case.. + // We wait for the buffer to fill up before pausing the just-loaded song because only if the + // buffer is full will the song continue to buffer until the user hits play. + if (this.serverUrl && e.info.code == "NetStream.Buffer.Full" && this.pauseOnBufferFull) { + this.ns.pause(); + this.paused = true; + this.pauseOnBufferFull = false; + // Call pause in JS. This will call back to us to pause again, but + // that should be harmless. + writeDebug('Pausing on buffer full'); + ExternalInterface.call(baseJSObject + "['" + this.sID + "'].pause", false); + } + + var isNetstreamBuffering: Boolean = (e.info.code == "NetStream.Buffer.Empty" || e.info.code == "NetStream.Play.Start"); + // assume buffering when we start playing, eg. initial load. + if (isNetstreamBuffering != this.lastValues.isBuffering) { + this.lastValues.isBuffering = isNetstreamBuffering; + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onbufferchange", this.lastValues.isBuffering ? 1 : 0); + } + + // We can detect the end of the stream when Play.Stop is called followed by Buffer.Empty. + // However, if you pause and let the whole song buffer, Buffer.Flush is called followed by + // Buffer.Empty, so handle that case too. + // + // Ignore this event if we are more than 3 seconds from the end of the song. + if (e.info.code == "NetStream.Buffer.Empty" && (this.lastNetStatus == 'NetStream.Play.Stop' || this.lastNetStatus == 'NetStream.Buffer.Flush')) { + if (this.duration && (this.ns.time * 1000) < (this.duration - 3000)) { + writeDebug('Ignoring Buffer.Empty because this is too early to be the end of the stream! (sID: '+this.sID+', time: '+(this.ns.time*1000)+', duration: '+this.duration+')'); + } else if (!this.finished) { + this.finished = true; + writeDebug('calling onfinish for sound '+this.sID); + this.sm.checkProgress(); + ExternalInterface.call(baseJSObject + "['" + this.sID + "']._onfinish"); + } + + } else if (e.info.code == "NetStream.Buffer.Empty") { + // The buffer is empty. Start from the smallest buffer again. + this.ns.bufferTime = this.bufferTime; + } + } + + // Remember the last NetStatus event + this.lastNetStatus = e.info.code; + } + + // KJV The sound adds some of its own netstatus handlers so we don't need to do it here. + public function addNetstreamEvents() : void { + ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, doAsyncError); + ns.addEventListener(NetStatusEvent.NET_STATUS, doNetStatus); + ns.addEventListener(IOErrorEvent.IO_ERROR, doIOError); + } + + public function removeNetstreamEvents() : void { + ns.removeEventListener(AsyncErrorEvent.ASYNC_ERROR, doAsyncError); + ns.removeEventListener(NetStatusEvent.NET_STATUS, doNetStatus); + ns.addEventListener(NetStatusEvent.NET_STATUS, dummyNetStatusHandler); + ns.removeEventListener(IOErrorEvent.IO_ERROR, doIOError); + // KJV Stop listening for NetConnection events on the sound + nc.removeEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); + } + + // Prevents possible 'Unhandled NetStatusEvent' condition if a sound is being + // destroyed and interacted with at the same time. + public function dummyNetStatusHandler(e: NetStatusEvent) : void { + // Don't do anything + } + } +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/make-flash8.bat b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/make-flash8.bat new file mode 100755 index 00000000..fcab4234 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/make-flash8.bat @@ -0,0 +1,5 @@ +@REM this builds the soundmanager 2 SWF from source + +mtasc -swf ../swf/soundmanager2_debug.swf -main -header 16:16:30 SoundManager2.as -version 8 +@pause + diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/make-flash8.sh b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/make-flash8.sh new file mode 100755 index 00000000..8857d152 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/make-flash8.sh @@ -0,0 +1,2 @@ +#!/bin/bash +/Applications/mtasc/mtasc -swf ../swf/soundmanager2_debug.swf -main -header 16:16:30 SoundManager2.as -version 8 diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/make-flash9.bat b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/make-flash9.bat new file mode 100755 index 00000000..ed63934a --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/make-flash9.bat @@ -0,0 +1,4 @@ +@REM this builds the soundmanager 2 SWF from source +@REM using mxmlc from the Adobe open-source Flex SDK + +c:\progra~1\flexsdk\bin\mxmlc -debug=true -use-network=false -static-link-runtime-shared-libraries=true -optimize=true -o ../swf/soundmanager2_flash9_debug.swf -file-specs SoundManager2_AS3.as diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/make-flash9.sh b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/make-flash9.sh new file mode 100755 index 00000000..ec6041c1 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/src/make-flash9.sh @@ -0,0 +1,2 @@ +#!/bin/bash +/Applications/flexsdk/bin/mxmlc -debug=true -static-link-runtime-shared-libraries=true -optimize=true -o ../swf/soundmanager2_flash9_debug.swf -file-specs SoundManager2_AS3.as diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2.swf b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2.swf new file mode 100755 index 00000000..e900766a Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2.swf differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2_debug.swf b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2_debug.swf new file mode 100755 index 00000000..a6809121 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2_debug.swf differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2_flash9.swf b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2_flash9.swf new file mode 100755 index 00000000..3d4222a3 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2_flash9.swf differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2_flash9_debug.swf b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2_flash9_debug.swf new file mode 100755 index 00000000..c1a129d8 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2_flash9_debug.swf differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2_flash_xdomain.zip b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2_flash_xdomain.zip new file mode 100755 index 00000000..5661d213 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/swf/soundmanager2_flash_xdomain.zip differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/debug.css b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/debug.css new file mode 100755 index 00000000..5bccf9a9 --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/debug.css @@ -0,0 +1,119 @@ +/* SM2 troubleshooting CSS */ + +#sm2-test { + position:relative; + background:#f6f6f6; + border:1px solid #eee; + padding:3px; +} + +#sm2-test, +#sm2-test ul.items { + border-radius:3px; +} + +#sm2-test ul.items { + position:relative; + background:#fff; + list-style-type:none; + margin:0px; + padding:0px; + border:1px solid #ccc; +} + +#sm2-test ul.items li { + position:relative; + margin-left:0.5em; + padding-left:0.5em; + margin-right:0.5em; + padding-right:0.5em; +} + +#sm2-test ul.items li h3 { + padding-top:0.3em; + margin-top:0px; + border-bottom:1px solid #ccc; + border-top: none; +} + +#sm2-test ul.items li:last-child h3 { + border-bottom:none; +} + +#sm2-test ul.items li div.details { + border-bottom:1px solid #ccc; +} + +#sm2-test ul.items li:hover div.details { + border-bottom:1px solid #ccc; +} + +#sm2-test ul.items li.open:last-child h3, +#sm2-test ul.items li.fail:last-child h3, +#sm2-test ul.items li:last-child div.details:last-child { + border-bottom:1px solid #fff; +} + +#sm2-test ul.items li div.details { + display:none; +} + +#sm2-test ul.items li.open div.details, +#sm2-test ul.items li.unknown div.details, +#sm2-test ul.items li.fail div.details { + display:block; +} + +#sm2-test ul.items li span.yay, +#sm2-test ul.items li span.boo, +#sm2-test ul.items li span.default, +#sm2-test ul.items li span.unknown { + display:none; +} + +#sm2-test ul.items li span.yay, +#sm2-test ul.items li.pass span.msg { + color:green; +} + +#sm2-test ul.items li span.boo, +#sm2-test ul.items li.fail span.msg { + color:red; +} + +#sm2-test ul.items li span.default, +#sm2-test ul.items li.default span.msg { + color:#ccc; +} + +#sm2-test ul.items li span.unknown, +#sm2-test ul.items li.unknown span.msg { + color:#666; +} + +#sm2-test ul.items li.default span.msg { + display:none; /* hide messages in the event a reset occurs */ +} + +#sm2-test ul.items li.pass span.yay, +#sm2-test ul.items li.fail span.boo, +#sm2-test ul.items li.default span.default, +#sm2-test ul.items li.unknown span.unknown { + float:right; + display:inline; +} + +#sm2-container.flash_debug { + /* flash movie, when soundManager.debugFlash = true */ + position:relative; + width:auto; + height:300px; + width:100%; + background:#f6f6f6; + border:1px solid #ccc; +} + +#sm2-container.flash_debug object, +#sm2-container.flash_debug embed { + border:1px solid #fff; +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/debug.js b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/debug.js new file mode 100755 index 00000000..8b0f851a --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/debug.js @@ -0,0 +1,187 @@ +// SoundManager 2 start-up troubleshooting tool + +// FlashDetect, by Carl Yestrau +// http://www.featureblend.com/license.txt +var FlashDetect=new function(){var self=this;self.installed=false;self.raw="";self.major=-1;self.minor=-1;self.revision=-1;self.revisionStr="";var activeXDetectRules=[{"name":"ShockwaveFlash.ShockwaveFlash.7","version":function(obj){return getActiveXVersion(obj);}},{"name":"ShockwaveFlash.ShockwaveFlash.6","version":function(obj){var version="6,0,21";try{obj.AllowScriptAccess="always";version=getActiveXVersion(obj);}catch(err){} +return version;}},{"name":"ShockwaveFlash.ShockwaveFlash","version":function(obj){return getActiveXVersion(obj);}}];var getActiveXVersion=function(activeXObj){var version=-1;try{version=activeXObj.GetVariable("$version");}catch(err){} +return version;};var getActiveXObject=function(name){var obj=-1;try{obj=new ActiveXObject(name);}catch(err){} +return obj;};var parseActiveXVersion=function(str){var versionArray=str.split(",");return{"raw":str,"major":parseInt(versionArray[0].split(" ")[1],10),"minor":parseInt(versionArray[1],10),"revision":parseInt(versionArray[2],10),"revisionStr":versionArray[2]};};var parseStandardVersion=function(str){var descParts=str.split(/ +/);var majorMinor=descParts[2].split(/\./);var revisionStr=descParts[3];return{"raw":str,"major":parseInt(majorMinor[0],10),"minor":parseInt(majorMinor[1],10),"revisionStr":revisionStr,"revision":parseRevisionStrToInt(revisionStr)};};var parseRevisionStrToInt=function(str){return parseInt(str.replace(/[a-zA-Z]/g,""),10)||self.revision;};self.majorAtLeast=function(version){return self.major>=version;};self.FlashDetect=function(){if(navigator.plugins&&navigator.plugins.length>0){var type='application/x-shockwave-flash';var mimeTypes=navigator.mimeTypes;if(mimeTypes&&mimeTypes[type]&&mimeTypes[type].enabledPlugin&&mimeTypes[type].enabledPlugin.description){var version=mimeTypes[type].enabledPlugin.description;var versionObj=parseStandardVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revisionStr=versionObj.revisionStr;self.revision=versionObj.revision;self.installed=true;}}else if(navigator.appVersion.indexOf("Mac")==-1&&window.execScript){var version=-1;for(var i=0;i'+soundManager.url+''; + if (soundManager.getMoviePercent() == 100) { + // SWF may have already loaded + fOnComplete(true,msg); + } else { + try { + xhr.open("HEAD",sURL,true); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4) { + if (xhr.status == '200') { + fOnComplete(true,msg); + } else if (xhr.status == '404') { + fOnComplete(false,msg); + } else { + // some other response + fOnComplete('unknown',(xhr.status != '0'?'HTTP response: '+xhr.status+', ':'')+msg); // safari returns 0 when offline + } + } + } + xhr.send(null); + + } catch(e) { + // fail (cross-domain, or no XHR) unless offline + fOnComplete('unknown',msg); + return false; + } + } + } + + this.handleEvent = function(sEventType,bSuccess,sMessage) { + var o = elements[sEventType]; + if (o) { + o.className = (bSuccess == true?'pass':(bSuccess != false?bSuccess:'fail')); // true = pass, className as argument, or false == fail + if (sMessage) { + var oSpan = o.getElementsByTagName('span')[4]; + if (oSpan) { + oSpan.innerHTML = (oSpan.innerHTML +' '+sMessage+''); + } else { + o.title = sMessage; + } + } + // associated events + if (sEventType == 'onload') { + if (bSuccess) { + self.doSoundTest(); + } else { + self.testURL(soundManager.url,function(bSuccess,sMessage) { + if (typeof sMessage == 'undefined') { + sMessage = null; + } + self.handleEvent('swf',bSuccess,sMessage); + }); + } + } else if (sEventType == 'swf') { + if (bSuccess == false) { + // don't show flashtojs at all if SWF failed to load + self.handleEvent('flashtojs','default'); // reset to N/A status + } + } else if (sEventType == 'flashtojs') { + if (bSuccess != true) { + // online or offline help messages + if (soundManager._overHTTP) { + document.getElementById('d-flashtojs-offline').style.display = 'none'; + } else { + document.getElementById('d-flashtojs-online').style.display = 'none'; + } + } + } + } else { + soundManager._writeDebug('SM2 debugger warning: Undefined event type "'+sEventType+'"',1); + } + } + + this.doSoundTest = function() { + var foo = soundManager.createSound({ + id: 'sm2TestSound', + url: ('http://www.schillmania.com/projects/soundmanager2/demo/_mp3/mouseover.mp3') + }); + if (!soundManager._disabled) { + foo.play(); + // looks to be OK.. + if (!soundManager._disabled) { + // still OK.. + self.handleEvent('soundtest',true); + } else { + self.handleEvent('soundtest',false,': Failed after play()'); + } + } else { + self.handleEvent('soundtest',false,': Failed after createSound()'); + } + } + + this.init = function() { + // map event elements to DOM nodes - eg. elements.flashtojs = document.getElementById('d-flashtojs'); + for (var i=elementIDs.length; i--;) { + elements[elementIDs[i]] = document.getElementById('d-'+elementIDs[i]); + } + self.doFlashTest(); + } + + this.doFlashTest = function() { + var fd = FlashDetect; + var hasFlash = fd.installed; + var fv = soundManager.setupOptions.flashVersion; + var isSupported = (hasFlash && fd.major >= fv); + var flashVersion = fd.major+'.'+fd.minor+'.'+fd.revisionStr; + var flashInfo = ' version '+(!isSupported?'unsupported ('+flashVersion+', SWF version '+fv+')':flashVersion); + document.getElementById('d-flashversion').innerHTML = 'soundManager.flashVersion = '+fv+';'; + if (hasFlash) { + self.handleEvent('hasflash',isSupported,hasFlash?flashInfo:null); + } else { + self.handleEvent('hasflash','default',hasFlash?flashInfo:null); + } + } + + soundManager.setup({ + debugFlash: true // try to get flash debug output, as well + }); + + this.init(); + +} + +function sm2DebugInit() { + sm2Debugger = new SM2Debugger(); +} \ No newline at end of file diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/fpgss-add-location.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/fpgss-add-location.png new file mode 100755 index 00000000..78e82710 Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/fpgss-add-location.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/fpgss-added-location.png b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/fpgss-added-location.png new file mode 100755 index 00000000..df005d4c Binary files /dev/null and b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/fpgss-added-location.png differ diff --git a/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/index.html b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/index.html new file mode 100755 index 00000000..62a1713b --- /dev/null +++ b/app/assets/javascripts/librariesForAllPages/soundmanagerv297a-20131201/troubleshoot/index.html @@ -0,0 +1,154 @@ + + + +SoundManager 2 Start-up Test / Troubleshooting Tool + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    Flash options: Flash 8 (default), Flash 9 (normal) or Flash 9 + highPerformance + fastPolling modes.

    + +
    +
      + +
    • +

      OKFAILN/AUnknownSoundManager 2 start-up

      +
      +

      soundManager onready() or ontimeout() events are ultimately called when start-up completes.

      +

      If you're seeing a failure, refer to the below for troubleshooting details for common causes.

      +
      +
    • + +
    • +

      OKErrorN/AUnknownFlash

      +
      +

      Flash 8 or 9 may be required for SoundManager 2 to start, depending on HTML5 support. You are currently using [unknown].

      +
      +
    • + +
    • +

      OKErrorN/AUnknownFlash SWF

      +
      +

      SoundManager 2 must load a flash movie before initialisation can proceed. If you have errors here, check that soundManager.url is correctly defined and that the URL being loaded is correct.

      +

      If the Flash movie URL is OK, Flash security or flash blockers are the likely cause. Check the section below.

      +
      +
    • + +
    • +

      OKErrorN/AUnknownFlash -> JS

      +
      +

      Once the flash component of SM2 has loaded, it tries to make a call to Javascript-land. This is a common point of failure, for security reasons:

      +
        +
      • +

        Have a flash blocker? Check that the SM2 flash movie (below) is loading and is not being blocked.

        +
      • +
      • + Is your browser URL at file:// or c:/path/ or otherwise not using HTTP? Flash security "whitelisting" is required to allow Flash + JS to work when offline, placing it in the "LocalTrusted" Flash security sandbox rather than "localWithFile". + +
        +

        Offline viewing: Adding a "trusted location" to the Flash Security Settings Panel

        +

        The Flash Player Global Security Settings Panel is a web-based control panel which allows you to configure Flash security. You will need to add the path of the SoundManager 2 project in order for it to work "offline" (ie., when viewing via file:// or c:/)

        +

        Show me how: Adding a "trusted location"

        + +

        Launch the Flash Security Settings Panel

        +
        + +
      • +
      • Flash blockers (FlashBlock, "click to flash" etc.) preventing flash load and start-up - need whitelisting/"allow this domain" to work smoothly. If you suspect blocking is the issue, try the SoundManager 2 Flashblock demo.
      • +
      • Online viewing (HTTP/S): Same-domain security rules apply to HTML + Flash content by default (crossdomain.xml/allowDomain() in .AS source required to override.)
      • +
      +

      See Flash debug output for more security error details.

      + +
      +

      Online viewing: Cross-domain security restrictions

      +

      HTML page on domain A loading .SWF from domain B: Flash security prevents JS + Flash when a cross-domain XML permission file is not available on domain B, and/or flash movie was not compiled with allowDomain('domainA') or allowDomain('*') - note that the SWF distributed with SM2 does not use this by default; try using the cross-domain version of the SWF, or compile your own which whitelists your own domain(s).

      + +

      Flash Blockers

      +

      Browser extensions/add-ons like "FlashBlock" and "click to flash" can prevent the .SWF from loading, and this will mean SM2 will time-out and fail waiting for a response from Flash. For development, it's best to whitelist the domain(s) or the .SWF for SM2 to allow it to work.

      +

      Have a flash blocker installed? Want to test it? Try the SoundManager 2 Flashblock demo.

      + +
      + +
      +
    • + +
    • +

      OKErrorN/AUnknownJS -> Flash

      +
      +

      At this point, Javascript attempts to respond to Flash's initial outgoing Flash -> JS call, completing the test for JS/flash communication. If SM2 does not receive a response from flash, it will eventually fail.

      +

      Offline viewing conditions and cross-domain security rules will prevent Flash <-> JS communication. See the details of Flash -> JS for information.

      +

      Special Firefox Note: Some versions of Firefox (9.0 and newer?) may break JS/Flash in the file:// or offline case even when the path has been whitelisted in the Flash player security settings panel. IE, Chrome, Safari and Opera do not have this issue.

      +
      +
    • + +
    • +

      OKErrorN/AUnknownSound test

      +
      +

      Here, a simple createSound() call is made to test SM2's actual operation. A sound should load and play provided SM2 was able to start successfully.

      +
      +
    • + +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    +
    + + + +
    + + diff --git a/app/assets/javascripts/metamaps/Metamaps.Backbone.js b/app/assets/javascripts/metamaps/Metamaps.Backbone.js index d75814c6..5c326970 100644 --- a/app/assets/javascripts/metamaps/Metamaps.Backbone.js +++ b/app/assets/javascripts/metamaps/Metamaps.Backbone.js @@ -21,6 +21,14 @@ Metamaps.Backbone.Mapper = Backbone.Model.extend({ toJSON: function (options) { return _.omit(this.attributes, this.blacklist); }, + prepareLiForFilter: function () { + var li = ''; + li += '
  • ';       + li += '';       + li += '

    ' + this.get('name') + '

  • '; + return li; + } }); Metamaps.Backbone.MapperCollection = Backbone.Collection.extend({ model: Metamaps.Backbone.Mapper, diff --git a/app/assets/javascripts/metamaps/Metamaps.JIT.js b/app/assets/javascripts/metamaps/Metamaps.JIT.js index c05677b6..41ff23ba 100644 --- a/app/assets/javascripts/metamaps/Metamaps.JIT.js +++ b/app/assets/javascripts/metamaps/Metamaps.JIT.js @@ -8,6 +8,10 @@ Metamaps.JIT = { var self = Metamaps.JIT; self.prepareVizData(); + $(".zoomIn").click(self.zoomIn); + $(".zoomOut").click(self.zoomOut); + $(".centerMap").click(self.centerMap); + $(".zoomExtents").click(self.zoomExtents); }, /** * convert our topic JSON into something JIT can use @@ -307,7 +311,7 @@ Metamaps.JIT = { if (Metamaps.Mouse.boxStartCoordinates) { Metamaps.Visualize.mGraph.busy = false; Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos(); - Metamaps.JIT.selectNodesWithBox(); + Metamaps.JIT.selectWithBox(e); return; } @@ -331,7 +335,7 @@ Metamaps.JIT = { if (Metamaps.Mouse.boxStartCoordinates) { Metamaps.Visualize.mGraph.busy = false; Metamaps.Mouse.boxEndCoordinates = eventInfo.getPos(); - Metamaps.JIT.selectNodesWithBox(); + Metamaps.JIT.selectWithBox(e); return; } @@ -885,12 +889,11 @@ Metamaps.JIT = { // 4 this node and others were selected, so drag them (just return false) //return value: deselect node again after? if (Metamaps.Selected.Nodes.length == 0) { - Metamaps.Control.selectNode(node); - return 'deselect'; + return 'only-drag-this-one'; } if (Metamaps.Selected.Nodes.indexOf(node) == -1) { if (e.shiftKey) { - Metamaps.Control.selectNode(node); + Metamaps.Control.selectNode(node,e); return 'nothing'; } else { return 'only-drag-this-one'; @@ -898,30 +901,135 @@ Metamaps.JIT = { } return 'nothing'; //case 4? }, // handleSelectionBeforeDragging - selectNodesWithBox: function () { + selectWithBox: function (e) { var sX = Metamaps.Mouse.boxStartCoordinates.x, sY = Metamaps.Mouse.boxStartCoordinates.y, eX = Metamaps.Mouse.boxEndCoordinates.x, eY = Metamaps.Mouse.boxEndCoordinates.y; + + if(!(e.shiftKey) && !(e.ctrlKey)){ + Metamaps.Control.deselectAllNodes(); + Metamaps.Control.deselectAllEdges(); + } - + //select all nodes, and their edges, that are within the box Metamaps.Visualize.mGraph.graph.eachNode(function (n) { var x = n.pos.x, y = n.pos.y; if ((sX < x && x < eX && sY < y && y < eY) || (sX > x && x > eX && sY > y && y > eY) || (sX > x && x > eX && sY < y && y < eY) || (sX < x && x < eX && sY > y && y > eY)) { - var nodeIsSelected = Metamaps.Selected.Nodes.indexOf(n); - if (nodeIsSelected == -1) Metamaps.Control.selectNode(n); // the node is not selected, so select it - else if (nodeIsSelected != -1) Metamaps.Control.deselectNode(n); // the node is selected, so deselect it - + if(e.ctrlKey){ + if(n.selected){ + Metamaps.Control.deselectNode(n); + } + else{ + Metamaps.Control.selectNode(n,e); + } + } + else{ + Metamaps.Control.selectNode(n,e); + } } }); + //Convert selection box coordinates to traditional coordinates (+,+) in upper right + sY = -1 * sY; + eY = -1 * eY + + Metamaps.Synapses.each(function(synapse) { + var fromNodeX = synapse.get('edge').nodeFrom.pos.x; + var fromNodeY = -1 * synapse.get('edge').nodeFrom.pos.y; + var toNodeX = synapse.get('edge').nodeTo.pos.x; + var toNodeY = -1 * synapse.get('edge').nodeTo.pos.y; + + var maxX = fromNodeX; + var maxY = fromNodeY; + var minX = fromNodeX; + var minY = fromNodeY; + + //Correct maxX, MaxY values + (toNodeX > maxX) ? (maxX = toNodeX):(minX = toNodeX); + (toNodeY > maxY) ? (maxY = toNodeY):(minY = toNodeY); + + var maxBoxX = sX; + var maxBoxY = sY; + var minBoxX = sX; + var minBoxY = sY; + + //Correct maxBoxX, maxBoxY values + (eX > maxBoxX) ? (maxBoxX = eX):(minBoxX = eX); + (eY > maxBoxY) ? (maxBoxY = eY):(minBoxY = eY); + + //Fins the slopes from the synapse fromNode to the 4 corners of the selection box + var slopes = []; + slopes.push( (sY - fromNodeY) / (sX - fromNodeX) ); + slopes.push( (sY - fromNodeY) / (eX - fromNodeX) ); + slopes.push( (eY - fromNodeY) / (eX - fromNodeX) ); + slopes.push( (eY - fromNodeY) / (sX - fromNodeX) ); + + var minSlope = slopes[0]; + var maxSlope = slopes[0]; + slopes.forEach(function(entry){ + if(entry > maxSlope) maxSlope = entry; + if(entry < minSlope) minSlope = entry; + }); + + //Find synapse-in-question's slope + var synSlope = (toNodeY - fromNodeY) / (toNodeX - fromNodeX); + var b = fromNodeY - synSlope * fromNodeX; + + var selectTest = false; + + //if the synapse slope is within a range that would intersect with the selection box + if (synSlope <= maxSlope && synSlope >= minSlope){ + var testX = sX; + var testY = synSlope * testX + b; + + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testY >= minBoxY && testY <= maxBoxY){ + selectTest = true; + } + + testX = eX; + testY = synSlope * testX + b; + + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testY >= minBoxY && testY <= maxBoxY){ + selectTest = true; + } + + testY = sY; + testX = (testY - b)/synSlope; + + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testY <= maxBoxX){ + selectTest = true; + } + + testY = eY; + testX = (testY - b)/synSlope; + + if(testX >= minX && testX <= maxX && testY >= minY && testY <= maxY && testX >= minBoxX && testY <= maxBoxX){ + selectTest = true; + } + } + //The test synapse was selected! + if(selectTest){ + if(e.ctrlKey){ + if(Metamaps.Selected.Edges.indexOf(synapse.get('edge')) != -1 ){ + Metamaps.Control.deselectEdge(synapse.get('edge')); + } + else{ + Metamaps.Control.selectEdge(synapse.get('edge')); + } + } + else{ + Metamaps.Control.selectEdge(synapse.get('edge')); + } + } + }); Metamaps.Mouse.boxStartCoordinates = false; Metamaps.Mouse.boxEndCoordinates = false; Metamaps.Visualize.mGraph.plot(); - }, // selectNodesWithBox + }, // selectWithBox drawSelectBox: function (eventInfo, e) { var ctx = Metamaps.Visualize.mGraph.canvas.getCtx(); @@ -974,7 +1082,7 @@ Metamaps.JIT = { if (node.selected) { Metamaps.Control.deselectNode(node); } else { - Metamaps.Control.selectNode(node); + Metamaps.Control.selectNode(node,e); } //trigger animation to final styles Metamaps.Visualize.mGraph.fx.animate({ @@ -1321,5 +1429,91 @@ Metamaps.JIT = { y: posChild.y }, 13, inv, canvas, 0.3); } - } //renderEdgeArrows + }, //renderEdgeArrows + zoomIn: function () { + Metamaps.Visualize.mGraph.canvas.scale(1.25,1.25); + }, + zoomOut: function () { + Metamaps.Visualize.mGraph.canvas.scale(0.8,0.8); + }, + centerMap: function () { + var canvas = Metamaps.Visualize.mGraph.canvas; + var offsetScale = canvas.scaleOffsetX; + + canvas.scale(1/offsetScale,1/offsetScale); + + var offsetX = canvas.translateOffsetX; + var offsetY = canvas.translateOffsetY; + + canvas.translate(-1*offsetX,-1*offsetY); + }, + zoomExtents: function () { + Metamaps.JIT.centerMap(); + var height = $(document).height(), + width = $(document).width(), + maxX, minX, maxY, minY, counter = 0; + + var nodes = Metamaps.Visualize.mGraph.graph; + + + if(Object.keys(nodes).length >1){ + + + nodes.eachNode(function (n) { + var x = n.pos.x, + y = n.pos.y; + + if (counter == 0){ + maxX = x; + minX = x; + maxY = y; + minY = y; + } + + maxX = Math.max(x,maxX); + maxY = Math.max(y,maxY); + minX = Math.min(x,minX); + minY = Math.min(y,minY); + + counter++; + }); + + var spanX = maxX - minX; + var spanY = maxY - minY; + var ratioX = spanX / width; + var ratioY = spanY / height; + + var newRatio = Math.max(ratioX,ratioY); + + var canvas = Metamaps.Visualize.mGraph.canvas; + + canvas.scale(1/newRatio*0.9,1/newRatio*0.9); + + counter = 0; + + nodes.eachNode(function (n) { + var x = n.pos.x, + y = n.pos.y; + + if (counter == 0){ + maxX = x; + minX = x; + maxY = y; + minY = y; + } + + maxX = Math.max(x,maxX); + maxY = Math.max(y,maxY); + minX = Math.min(x,minX); + minY = Math.min(y,minY); + + counter++; + }); + + var cogX = (maxX + minX)/2; + var cogY = (maxY + minY)/2; + + canvas.translate(-1* cogX, -1* cogY); + } + } }; \ No newline at end of file diff --git a/app/assets/javascripts/metamaps/Metamaps.Router.js b/app/assets/javascripts/metamaps/Metamaps.Router.js index f1dfe1ec..6e989d3b 100644 --- a/app/assets/javascripts/metamaps/Metamaps.Router.js +++ b/app/assets/javascripts/metamaps/Metamaps.Router.js @@ -45,4 +45,4 @@ } }); } -})(); \ No newline at end of file +})(); diff --git a/app/assets/javascripts/metamaps/metamaps.js b/app/assets/javascripts/metamaps/Metamaps.js similarity index 86% rename from app/assets/javascripts/metamaps/metamaps.js rename to app/assets/javascripts/metamaps/Metamaps.js index 08b594d5..4a185186 100644 --- a/app/assets/javascripts/metamaps/metamaps.js +++ b/app/assets/javascripts/metamaps/Metamaps.js @@ -83,11 +83,25 @@ Metamaps.Backbone.init = function () { var image = new Image(); image.src = this.get('icon'); this.set('image',image); + }, + prepareLiForFilter: function () { + var li = ''; + li += '
  • ';       + li += '';       + li += '

    ' + this.get('name').toLowerCase() + '

  • '; + return li; } + }); self.MetacodeCollection = Backbone.Collection.extend({ model: this.Metacode, url: '/metacodes', + comparator: function (a, b) { + a = a.get('name').toLowerCase(); + b = b.get('name').toLowerCase(); + return a > b ? 1 : a < b ? -1 : 0; + } }); self.Topic = Backbone.Model.extend({ @@ -105,6 +119,8 @@ Metamaps.Backbone.init = function () { "permission": Metamaps.Active.Map ? Metamaps.Active.Map.get('permission') : 'commons' }); } + + this.on('change:metacode_id', Metamaps.Filter.checkMetacodes, this); }, authorizeToEdit: function (mapper) { if (mapper && (this.get('permission') === "commons" || this.get('user_id') === mapper.get('id'))) return true; @@ -189,6 +205,15 @@ Metamaps.Backbone.init = function () { "category": "from-to" }); } + this.on('change:desc', Metamaps.Filter.checkSynapses, this); + }, + prepareLiForFilter: function () { + var li = ''; + li += '
  • ';       + li += '
  • '; + return li; }, authorizeToEdit: function (mapper) { if (mapper && (this.get('permission') === "commons" || this.get('user_id') === mapper.get('id'))) return true; @@ -302,11 +327,28 @@ Metamaps.Backbone.init = function () { Metamaps.Topics = new self.TopicCollection(Metamaps.Topics); + Metamaps.Topics.on("add remove", function(topic){ + Metamaps.Filter.checkMetacodes(); + Metamaps.Filter.checkMappers(); + }); + Metamaps.Synapses = new self.SynapseCollection(Metamaps.Synapses); - Metamaps.Mappings = new self.MappingCollection(Metamaps.Mappings); + Metamaps.Synapses.on("add remove", function(synapse){ + Metamaps.Filter.checkSynapses(); + Metamaps.Filter.checkMappers(); + }); + + Metamaps.Mappers = new self.MapperCollection(Metamaps.Mappers) if (Metamaps.Active.Map) { + Metamaps.Mappings = new self.MappingCollection(Metamaps.Mappings); + + Metamaps.Mappings.on("add remove", function(synapse){ + Metamaps.Filter.checkMetacodes(); + Metamaps.Filter.checkMappers(); + }); + Metamaps.Active.Map = new self.Map(Metamaps.Active.Map); Metamaps.Maps.add(Metamaps.Active.Map); } @@ -1595,13 +1637,16 @@ Metamaps.Control = { init: function () { }, - selectNode: function (node) { + selectNode: function (node,e) { if (Metamaps.Selected.Nodes.indexOf(node) != -1) return; node.selected = true; node.setData('dim', 30, 'current'); - node.eachAdjacency(function (adj) { - Metamaps.Control.selectEdge(adj); - }); + if(!(e.ctrlKey) && !(e.altKey)){ + node.eachAdjacency(function (adj) { + Metamaps.Control.selectEdge(adj); + }); + } + Metamaps.Selected.Nodes.push(node); }, deselectAllNodes: function () { @@ -1614,9 +1659,11 @@ Metamaps.Control = { }, deselectNode: function (node) { delete node.selected; + /* node.eachAdjacency(function (adj) { Metamaps.Control.deselectEdge(adj); }); + */ node.setData('dim', 25, 'current'); //remove the node @@ -1691,6 +1738,8 @@ Metamaps.Control = { setTimeout(function () { Metamaps.Visualize.mGraph.graph.removeNode(nodeid); }, 500); + Metamaps.Filter.checkMetacodes(); + Metamaps.Filter.checkMappers(); }, selectEdge: function (edge) { if (Metamaps.Selected.Edges.indexOf(edge) != -1) return; @@ -1806,6 +1855,8 @@ Metamaps.Control = { setTimeout(function () { Metamaps.Visualize.mGraph.graph.removeAdjacence(from, to); }, 500); + Metamaps.Filter.checkSynapses(); + Metamaps.Filter.checkMappers(); }, updateSelectedPermissions: function (permission) { @@ -1862,9 +1913,14 @@ Metamaps.Control = { Metamaps.Filter = { filters: { name: "", - metacode: [], + metacodes: [], mappers: [], - synapseTypes: [] + synapses: [] + }, + visible: { + metacodes: [], + mappers: [], + synapses: [] }, isOpen: false, timeOut: null, @@ -1874,24 +1930,19 @@ Metamaps.Filter = { $(".sidebarFilter").hover(self.open, self.close); - // initialize scroll bar for filter by metacode, then hide it and position it correctly again - $("#filter_by_metacode").mCustomScrollbar({ - mouseWheelPixels: 200, - advanced: { - updateOnContentResize: true - } - }); - $('.sidebarFilterBox').hide().css({ - position: 'absolute', - top: '45px', - right: '-36px' - }); - - $('.sidebarFilterBox .showAll').click(self.filterNoMetacodes); - $('.sidebarFilterBox .hideAll').click(self.filterAllMetacodes); + $('.sidebarFilterBox .showAllMetacodes').click(self.filterNoMetacodes); + $('.sidebarFilterBox .showAllSynapses').click(self.filterNoSynapses); + $('.sidebarFilterBox .showAllMappers').click(self.filterNoMappers); + $('.sidebarFilterBox .hideAllMetacodes').click(self.filterAllMetacodes); + $('.sidebarFilterBox .hideAllSynapses').click(self.filterAllSynapses); + $('.sidebarFilterBox .hideAllMappers').click(self.filterAllMappers); // toggle visibility of topics with metacodes based on status in the filters list $('#filter_by_metacode ul li').click(self.toggleMetacode); + $('#filter_by_mapper ul li').click(self.toggleMapper); + $('#filter_by_synapse ul li').click(self.toggleSynapse); + + self.getFilterData(); }, open: function () { var self = Metamaps.Filter; @@ -1920,70 +1971,280 @@ Metamaps.Filter = { } }, 500); }, - filterNoMetacodes: function (e) { - - $('#filter_by_metacode ul li').removeClass('toggledOff'); - - // TODO - /* - showAll(); - - for (var catVis in categoryVisible) { - categoryVisible[catVis] = true; + checkMetacodes: function () { + var self = Metamaps.Filter; + + var newMetacodeList = []; + var removedMetacodes = []; + var addedMetacodes = []; + + Metamaps.Topics.each(function(topic) { + if (newMetacodeList.indexOf(topic.get('metacode_id')) === -1) { + newMetacodeList.push(topic.get('metacode_id').toString()); + } + }); + + removedMetacodes = _.difference(self.filters.metacodes, newMetacodeList); + addedMetacodes = _.difference(newMetacodeList, self.filters.metacodes); + + _.each(removedMetacodes, function(metacode_id) { + $('#filter_by_metacode li[data-id="' + metacode_id + '"]').fadeOut('fast',function(){ + $(this).remove(); + }); + }); + + var synapse, li, jQueryLi; + function sortAlpha(a,b){ + console.log(a.childNodes); + return a.childNodes[1].innerText.toLowerCase() > b.childNodes[1].innerText.toLowerCase() ? 1 : -1; } - */ + _.each(addedMetacodes, function(metacode_id) { + metacode = Metamaps.Metacodes.get(metacode_id); + li = metacode.prepareLiForFilter(); + jQueryLi = $(li).hide(); + $('li', '#filter_by_metacode ul').add(jQueryLi.fadeIn("fast")) + .sort(sortAlpha).appendTo('#filter_by_metacode ul'); + }); + self.filters.metacodes = newMetacodeList; + }, + checkMappers: function () { + var self = Metamaps.Filter; + + var newMappersList = []; + var removedMappersList = []; + var addedMappers = []; + + Metamaps.Topics.each(function(topic) { + if (newMappersList.indexOf(topic.get('user_id')) === -1) { + newMappersList.push(topic.get('user_id').toString()); + } + }); + Metamaps.Synapses.each(function(synapse) { + if (newMappersList.indexOf(synapse.get('user_id')) === -1) { + newMappersList.push(synapse.get('user_id').toString()); + } + }); + + + removedMappersList = _.difference(self.filters.mappers, newMappersList); + addedMappers = _.difference(newMappersList, self.filters.mappers); + + _.each(removedMappersList, function(user_id) { + $('#filter_by_mapper li[data-id="' + user_id + '"]').fadeOut('fast',function(){ + $(this).remove(); + }); + }); + + var mapper, li, jQueryLi; + function sortAlpha(a,b){ + return a.childNodes[1].innerText.toLowerCase() > b.childNodes[1].innerText.toLowerCase() ? 1 : -1; + } + _.each(addedMappers, function(user_id) { + mapper = Metamaps.Mapper.get(user_id); + li = mapper.prepareLiForFilter(); + jQueryLi = $(li).hide(); + $('li', '#filter_by_mapper ul').add(jQueryLi.fadeIn("fast")) + .sort(sortAlpha).appendTo('#filter_by_mapper ul'); + }); + + self.filters.mappers = newMappersList; + + }, + checkSynapses: function () { + var self = Metamaps.Filter; + + var newSynapsesList = []; + var removedSynapses = []; + var addedSynapses = []; + + Metamaps.Synapses.each(function(synapse) { + if (synapse.get('desc') && newSynapsesList.indexOf(synapse.get('desc')) === -1) { + newSynapsesList.push(synapse.get('desc').toString()); + } + }); + + removedSynapses = _.difference(self.filters.synapses, newSynapsesList); + addedSynapses = _.difference(newSynapsesList, self.filters.synapses); + + _.each(removedSynapses, function(synapse_desc) { + $('#filter_by_synapse li[data-id="' + synapse_desc + '"]').fadeOut('fast',function(){ + $(this).remove(); + }); + }); + + var synapse, li, jQueryLi; + function sortAlpha(a,b){ + return a.innerHTML.toLowerCase() > b.innerHTML.toLowerCase() ? 1 : -1; + } + _.each(addedSynapses, function(synapse_desc) { + synapse = Metamaps.Synapses.findWhere({desc:synapse_desc}); + li = synapse.prepareLiForFilter(); + jQueryLi = $(li).hide(); + $('li', '#filter_by_synapse ul').add(jQueryLi.fadeIn("fast")) + .sort(sortAlpha).appendTo('#filter_by_synapse ul'); + }); + + self.filters.synapses = newSynapsesList; }, filterAllMetacodes: function (e) { - + var self = Metamaps.Filter; $('#filter_by_metacode ul li').addClass('toggledOff'); + self.visible.metacodes = []; + self.passFilters(); + }, + filterNoMetacodes: function (e) { + var self = Metamaps.Filter; + $('#filter_by_metacode ul li').removeClass('toggledOff'); + self.visible.metacodes = self.filters.metacodes.slice(); + self.passFilters(); + }, + filterAllMappers: function (e) { + var self = Metamaps.Filter; + $('#filter_by_mapper ul li').addClass('toggledOff'); + self.visible.mappers = []; + self.passFilters(); + }, + filterNoMappers: function (e) { + var self = Metamaps.Filter; + $('#filter_by_mapper ul li').removeClass('toggledOff'); + self.visible.mappers = self.filters.mappers.slice(); + self.passFilters(); + }, + filterAllSynapses: function (e) { + var self = Metamaps.Filter; + $('#filter_by_synapse ul li').addClass('toggledOff'); + self.visible.synapses = []; + self.passFilters(); + }, + filterNoSynapses: function (e) { + var self = Metamaps.Filter; + $('#filter_by_synapse ul li').removeClass('toggledOff'); + self.visible.synapses = self.filters.synapses.slice(); + self.passFilters(); - // TODO - /* - hideAll(); - for (var catVis in categoryVisible) { - categoryVisible[catVis] = false; - } - */ + + }, + /* + Most of this data essentially depends on the ruby function which are happening for filter inside view filterBox + But what these function do is load this data into three accessible array within java : metacodes, mappers and synapses + */ + getFilterData: function () { + var self = Metamaps.Filter; + + var metacode, mapper, synapse; + + $('#filter_by_metacode li').each(function() { + metacode = $( this ).find('img').attr('data-id'); + self.filters.metacodes.push(metacode); + self.visible.metacodes.push(metacode); + }); + + $('#filter_by_mapper li').each(function() { + mapper = ($( this ).find('img').attr('data-id')); + self.filters.mappers.push(mapper); + self.visible.mappers.push(mapper); + }); + + $('#filter_by_synapse li').each(function() { + synapse = ($( this ).find('p').text()); + self.filters.synapses.push(synapse); + self.visible.synapses.push(synapse); + }); }, toggleMetacode: function () { + var self = Metamaps.Filter, index; - var category = $(this).children('img').attr('alt'); - - // TODO - /*switchVisible(category); - - // toggle the image and the boolean array value - if (categoryVisible[category] == true) { - $(this).addClass('toggledOff'); - categoryVisible[category] = false; - } else if (categoryVisible[category] == false) { + var metacode_id = $(this).attr("data-id"); + if (self.visible.metacodes.indexOf(metacode_id) == -1) { + self.visible.metacodes.push(metacode_id); $(this).removeClass('toggledOff'); - categoryVisible[category] = true; - }*/ + } + else { + index = self.visible.metacodes.indexOf(metacode_id); + self.visible.metacodes.splice(index, 1); + $(this).addClass('toggledOff'); + } + self.passFilters(); }, - passFilters: function (topic) { - var self = Metamaps.Find; - var filters = self.filters; + toggleMapper: function () { + var self = Metamaps.Filter, index; - var passesName = filters.name == "" ? true : false, - passesType = filters.type == [] ? true : false; + var user_id = $(this).attr("data-id"); + if (self.visible.mappers.indexOf(user_id) == -1) { + self.visible.mappers.push(user_id); + $(this).removeClass('toggledOff'); + } + else { + index = self.visible.mappers.indexOf(user_id); + self.visible.mappers.splice(index, 1); + $(this).addClass('toggledOff'); + } + self.passFilters(); + }, + toggleSynapse: function () { + var self = Metamaps.Filter, index; - //filter by name - if (topic.get('1')[1][0].toLowerCase().indexOf(filters.name) !== -1) { - passesName = true; + var synapse_desc = $(this).attr("data-id"); + if (self.visible.synapses.indexOf(synapse_desc) == -1) { + self.visible.synapses.push(synapse_desc); + $(this).removeClass('toggledOff'); } - // filter by type - if (!filters.type == []) { - // get the array of types that your topic 'is' - var metacodes = topic.get('2') ? topic.get('2')[1] : []; - if (_.intersection(filters.type, metacodes).length == 0) passesType = true; + else { + index = self.visible.synapses.indexOf(synapse_desc); + self.visible.synapses.splice(index, 1); + $(this).addClass('toggledOff'); } + self.passFilters(); + }, + passFilters: function () { + var self = Metamaps.Filter; + var visible = self.visible; - if (passesName && passesType) { - return true; - } else { - return false; - } + var passesMetacode, passesMapper, passesSynapse; + + Metamaps.Topics.each(function(topic) { + var n = topic.get('node'); + var metacode_id = topic.get("metacode_id").toString(); + var user_id = topic.get("user_id").toString(); + + if (visible.metacodes.indexOf(metacode_id) == -1) passesMetacode = false; + else passesMetacode = true; + + if (visible.mappers.indexOf(user_id) == -1) passesMapper = false; + else passesMapper = true; + + if (passesMetacode && passesMapper) { + n.setData('alpha', 1, 'end'); + } + else { + n.setData('alpha', 0.0, 'end'); + } + }); + Metamaps.Synapses.each(function(synapse) { + var e = synapse.get('edge'); + var desc = synapse.get("desc"); + var user_id = synapse.get("user_id").toString(); + + if (visible.synapses.indexOf(desc) == -1) passesSynapse = false; + else passesSynapse = true; + + if (visible.mappers.indexOf(user_id) == -1) passesMapper = false; + else passesMapper = true; + + if (passesSynapse && passesMapper) { + e.setData('alpha', 1, 'end'); + } + else { + e.setData('alpha', 0.0, 'end'); + } + }); + + // run the animation + Metamaps.Visualize.mGraph.fx.animate({ + modes: ['node-property:alpha', + 'edge-property:alpha'], + duration: 500 + }); } }; // end Metamaps.Filter @@ -2690,4 +2951,4 @@ Metamaps.Mapper = { } } }, -}; // end Metamaps.Mapper \ No newline at end of file +}; // end Metamaps.Mapper diff --git a/app/assets/javascripts/metamaps/codeleft.js b/app/assets/javascripts/metamaps/codeleft.js index 12230b3c..ba192b80 100644 --- a/app/assets/javascripts/metamaps/codeleft.js +++ b/app/assets/javascripts/metamaps/codeleft.js @@ -48,142 +48,4 @@ function centerOn(nodeid) { } }); } -} - - - -function MconsoleReset() { - - var tX = Mconsole.canvas.translateOffsetX; - var tY = Mconsole.canvas.translateOffsetY; - Mconsole.canvas.translate(-tX, -tY); - - var mX = Mconsole.canvas.scaleOffsetX; - var mY = Mconsole.canvas.scaleOffsetY; - Mconsole.canvas.scale((1 / mX), (1 / mY)); -} - - -// create filters for maps - -function switchVisible(category, duration) { - if (categoryVisible[category] == true) { - hideCategory(category, duration); - } - else if (categoryVisible[category] == false) { - showCategory(category, duration); - } -} - -function hideCategory(category, duration) { - if (duration == null) duration = 500; - Mconsole.graph.eachNode( function (n) { - if (n.getData('metacode') == category) { - n.setData('alpha', 0.4, 'end'); - n.eachAdjacency(function(adj) { - adj.setData('alpha', 0.4, 'end'); - }); - } - }); - Mconsole.fx.animate({ - modes: ['node-property:alpha', - 'edge-property:alpha'], - duration: duration - }); -} - -function showCategory(category, duration) { - if (duration == null) duration = 500; - Mconsole.graph.eachNode( function (n) { - if (n.getData('metacode') == category) { - n.setData('alpha', 1, 'end'); - n.eachAdjacency(function(adj) { - adj.setData('alpha', 1, 'end'); - }); - } - }); - Mconsole.fx.animate({ - modes: ['node-property:alpha', - 'edge-property:alpha'], - duration: duration - }); -} - -// These functions toggle ALL nodes and synapses on the page -function hideAll(duration) { - if (duration == null) duration = 500; - Mconsole.graph.eachNode( function (n) { - n.setData('alpha', 0.4, 'end'); - n.eachAdjacency(function(adj) { - adj.setData('alpha', 0.2, 'end'); - }); - }); - Mconsole.fx.animate({ - modes: ['node-property:alpha', - 'edge-property:alpha'], - duration: duration - }); -} -function showAll(duration) { - if (duration == null) duration = 500; - Mconsole.graph.eachNode( function (n) { - n.setData('alpha', 1, 'end'); - n.eachAdjacency(function(adj) { - adj.setData('alpha', 0.4, 'end'); - }); - }); - Mconsole.fx.animate({ - modes: ['node-property:alpha', - 'edge-property:alpha'], - duration: duration - }); -} - -function filterTopicsByMap(mapID) { - Mconsole.graph.eachNode(function (n) { - if (n.getData('inmaps').indexOf(parseInt(mapID)) !== -1) { - n.setData('alpha', 1, 'end'); - } - else { - n.setData('alpha', 0.4, 'end'); - } - Mconsole.fx.animate({ - modes: ['node-property:alpha', - 'edge-property:alpha'], - duration: 500 - }); - }); -} // filterTopicsByName - -function filterTopicsByMapper(mapperID) { - Mconsole.graph.eachNode(function (n) { - if (n.getData('userid').toString() == mapperID) { - n.setData('alpha', 1, 'end'); - } - else { - n.setData('alpha', 0.4, 'end'); - } - Mconsole.fx.animate({ - modes: ['node-property:alpha', - 'edge-property:alpha'], - duration: 500 - }); - }); -} // filterTopicsByName - -function filterTopicsByName(searchQuery) { - Mconsole.graph.eachNode(function (n) { - nodeName = n.name.toLowerCase(); - if (nodeName.indexOf(searchQuery) !== -1 && searchQuery != "") { - n.setData('alpha', 1, 'end'); - } - else { - n.setData('alpha', 0.4, 'end'); - } - Mconsole.fx.animate({ - modes: ['node-property:alpha', - 'edge-property:alpha'], - duration: 500 - }); - }); -} // filterTopicsByName \ No newline at end of file +} \ No newline at end of file diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index cb55f04c..d7b824bb 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -791,6 +791,47 @@ li.accountInvite span { width: 35px; height: 35px; } + +.zoomIn { + position: absolute; + bottom: 100px; + right: 20px; + z-index: 200; + width: 35px; + height: 35px; + background: blue; +} + +.zoomOut { + position: absolute; + bottom: 60px; + right: 20px; + z-index: 200; + width: 35px; + height: 35px; + background: blue; +} + +.centerMap { + position: absolute; + bottom: 140px; + right: 20px; + z-index: 200; + width: 35px; + height: 35px; + background: blue; +} + +.zoomExtents { + position: absolute; + bottom: 180px; + right: 20px; + z-index: 200; + width: 35px; + height: 35px; + background: blue; +} + .sidebarFilter.loggedout { right: 35px; } @@ -810,38 +851,33 @@ li.accountInvite span { position: fixed; top: -1000px; right: -1000px; - display: block; - /* - position:absolute; - top: 35px; - right:-72px; - display:none; - */ - height: auto; - width: 260px; - background: #000; + position:absolute; + top: 35px; + right:-150px; + display:none; + height: 400px; + width: 320px; + background: #f5f5f5; padding: 10px; border: 1px solid black; font-family: 'LatoLight', helvetica, sans-serif; text-align: center; + color:#3e3e3e; + overflow: scroll; + } -h3.filterByMetacode { - margin-bottom: 10px; +h3.filterBox { text-align: left; float: left; } .sidebarFilterBox span { - float: left; + float: right; background: #15bad4; padding: 1px 4px; border-radius: 2px; margin-left: 5px; cursor: pointer; } -.sidebarFilterBox #filter_by_metacode { - height: 270px; - overflow: hidden; -} .sidebarFilterBox ul { list-style: none; } @@ -852,9 +888,10 @@ h3.filterByMetacode { cursor: pointer; } .sidebarFilterBox li:hover { - background-color: rgba(255, 255, 255, 0.1); + background: #000; } .sidebarFilterBox li img { + background-color: rgba(255, 255, 255, 0.1); width: 45px; height: 45px; margin: 0 auto; @@ -867,6 +904,22 @@ h3.filterByMetacode { .sidebarFilterBox li.toggledOff { opacity: 0.4; } +.sidebarFilterBox h3 { + text-align: left; + text-transform: uppercase; + font-weight: bold; +} +#filter_by_metacode { + border-bottom: 1px solid black; + margin: 5px; +} +#filter_by_mapper { + margin: 5px auto; +} +#filter_by_synapse { + margin: 5px auto; + border-bottom: 1px solid black; +} /* end filter by metacode */ /* collaborate */ @@ -2524,4 +2577,4 @@ span.blue { } .templates { display: none; -} \ No newline at end of file +} diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index 35dea28e..ae6feadb 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -64,13 +64,14 @@ class MapsController < ApplicationController redirect_to root_url and return end + @allmappers = @map.contributors @alltopics = @map.topics # should limit to topics visible to user @allsynapses = @map.synapses # should also be limited @allmappings = @map.mappings @allmetacodes = Metacode.all respond_to do |format| - format.html { respond_with(@allmetacodes, @allmappings, @allsynapses, @alltopics, @map, @user) } + format.html { respond_with(@allmappers, @allmetacodes, @allmappings, @allsynapses, @alltopics, @map, @user) } format.json { render json: @map } end end diff --git a/app/views/maps/show.html.erb b/app/views/maps/show.html.erb index 8b1d85d8..77cb06f9 100644 --- a/app/views/maps/show.html.erb +++ b/app/views/maps/show.html.erb @@ -38,12 +38,15 @@
    -

    Filter By Metacode

    allnone -
    - <%= render :partial => 'shared/filterbymetacode' %> + <%= render :partial => 'shared/filterBox' %>
    +
    +
    +
    -
    +
    C
    +
    E
    +
    @@ -75,8 +78,9 @@ \ No newline at end of file + diff --git a/app/views/shared/_filterBox.html.erb b/app/views/shared/_filterBox.html.erb new file mode 100644 index 00000000..bc2cb821 --- /dev/null +++ b/app/views/shared/_filterBox.html.erb @@ -0,0 +1,85 @@ +<%# + # @file + # this code generates the list of icons in the filter box in the upper right menu area + #%> + +<% + @mappers = [] + @synapses = [] + @metacodes = [] + @metacodelist = '' + @mapperlist = '' + @synapselist = '' +# There are essentially three functions happening here one to fill data to +#@mappers with all people who have mapped on the selected map, which +#actually gets checked twice once for topics or within @metacodes and once +#for synapses on the map. @synapses get filled with all synapses on the map +#and metacodes is filled with all the metacodes that are being used on the map. + + @map.topics.each_with_index do |topic, index| + if @metacodes.index(topic.metacode) == nil + @metacodes.push(topic.metacode) + end + if @mappers.index(topic.user) == nil + @mappers.push(topic.user) + end + end + @map.synapses.each_with_index do |synapse, index| + if @synapses.index{|s| s.desc == synapse.desc} == nil + @synapses.push(synapse) + end + if @mappers.index(synapse.user) == nil + @mappers.push(synapse.user) + end + end + + @metacodes.sort! {|x,y| x.name <=> y.name } + @synapses.sort! {|x,y| x.desc <=> y.desc } + @mappers.sort! {|x,y| x.name <=> y.name } + + @metacodes.each_with_index do |metacode, index| + @metacodelist += '
  • ' + @metacodelist += '' + metacode.name + '' + @metacodelist += '

    ' + metacode.name.downcase + '

  • ' + end + @synapses.each_with_index do |synapse, index| + @synapselist += '
  • ' + @synapselist += 'synapse icon

    ' + synapse.desc + @synapselist += '

  • ' + end + @mappers.each_with_index do |mapper, index| + @mapperlist += '
  • ' + @mapperlist += '' + mapper.name + '' + @mapperlist += '

    ' + mapper.name + '

  • ' + end +%> +
    + +
    +
    +

    metacodes

    all none +
    +
      + <%= @metacodelist.html_safe %> +
    +
    +
    +
    +

    synapses

    all none +
    +
      + <%= @synapselist.html_safe %> +
    +
    +
    +
    +

    mappers

    all none +
    +
      + <%= @mapperlist.html_safe %> +
    +
    +
    + +
    + diff --git a/app/views/shared/_filterbymetacode.html.erb b/app/views/shared/_filterbymetacode.html.erb deleted file mode 100644 index 41ea33f5..00000000 --- a/app/views/shared/_filterbymetacode.html.erb +++ /dev/null @@ -1,23 +0,0 @@ -<%# - # @file - # this code generates the list of icons in the filter by metacode box in the upper right menu area - #%> - - - -
    -
      - <%= @list.html_safe %> -
    -
    -
    \ No newline at end of file