# SoundManager 2: Download

## Get SoundManager 2

Get the latest and greatest.

### Download SoundManager 2

Current version: 2.94a.20090206

New sound object stuff: `isBuffering` and `onbufferchange()` (Flash 9), new `soundManager.reboot()` method, `soundManager.useHighPerformance` is now false (off) by default. See revision history for details.

Download SoundManager 2.94a.20090206

## Revision History

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

### Revision History

A changelog of sorts.

- ### V2.94a.20090206 (current)

  The latest and greatest.

  - 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 `document.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

## Discussion / Support

Get Satisfaction support network