SoundManager 2: Download
Get SoundManager 2
Get the latest and greatest.
Download SoundManager 2
Current version: 2.95a.20090717
New shiny! onready()
subscriber method for multiple onload/onerror handlers, useFastPolling
for increased whileplaying()/related event callback frequency (higher framerates when drawing EQ/spectrum, etc.), multiShotEvents
so onfinish() fires for each shot, new Flashblock demo and more. See revision history for details.
Revision History
Latest changes and archived notes from bug fixes, API updates, feature development etc.
Revision History
A changelog of sorts.
-
V2.95a.20090717
New features: onready(), fast polling, flash blocking demos etc.
-
API Updates
- New
soundManager.onready(myFunction[,scope])
method, for asynchronous queueing ofonload()
-style handlers. Fires when SM2 has finished initializing. 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 asuccess
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 toonload()
. 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-possiblewhileplaying()
and related JS callback frequency (default is 20 msec.) Use withsoundManager.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 (currentlyonfinish()
only). Eg. WhenmySound.play()
is called three times,onfinish()
will subsequently fire three times.
- New
-
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 insoundManager.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, relatedsoundManager.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, relatedonbufferchange()
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.)
- Added
-
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 setsoundManager.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 tosoundObject.url
should now work as expected.
- Off-screen flash with
-
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 tosoundObject.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. WhenuseHighPerformance = 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, relatedonbufferchange()
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.)
- New
-
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. WhenuseHighPerformance = 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
andplayState
not being correctly set. - Fixed a bug with
onfinish()
not firing whenautoPlay
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"
- Fixed Flash 8 bug with
-
-
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
-relatednormalizeURL()
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 beforeonfinish()
-related issue, so it is possible to nicely loop sounds from withinonfinish()
- 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()
.
- Improved regular-expression-based URL detection for
-
-
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 DOMcreateElement()
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)
- True XHTML DOM compatibility. Rewrote
-
-
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, ~3xwhileplaying()
frequency! (Most noticeable on Mac OS X, and Safari on Windows? Investigating IE cases.)soundManager.pauseAll()
/soundManager.resumeAll()
: Global pause/resumesoundManager.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()
andresume()
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
- Changed 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
andNetConnection
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.
- New soundManager
-
-
-
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 toload()
, 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.
- Added
-
API: New shiny!
- Added
soundManager.altURL
property (anduseAltURL
conditional) for convenient offline and other URL switching cases (dev vs. production environments, etc.)
- Added
-
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 ofonbeforeunload
, 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
- Renamed internal soundManager and SMSound
-
-
V2.78a.20080920
-
API: Bug fixes
- Added
SoundLoaderContext
parameter toload()
, 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.
- Added
-
API: New shiny!
- Added
soundManager.altURL
property (anduseAltURL
conditional) for convenient offline and other URL switching cases (dev vs. production environments, etc.)
- Added
-
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 ofonbeforeunload
, 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
- Renamed internal soundManager and SMSound
-
-
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()
andsound.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.
- Fixed some
-
-
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/orsoundManager.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 withautoPlay
. - 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.
- 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
-
API: New shiny!
- New
useWaveformData
anduseEQData
sound options, providing access to raw waveform and sound frequency/EQ spectrum data via sound.waveformData and sound.eqData. - Renamed
useSpectrumData
touseWaveformData
- if using waveform stuff currently, make sure you update your code! - Added
soundManager.features
object, which reflects the "support" state forpeakData
,waveformData
andeqData
. Handy for current and future version/support branching.
- New
-
API: Miscellaneous
- New
flash9Options
configuration object for logical separation. When Flash 9+ is used, these options are merged into thedefaultOptions
object. - Added
allowDomain()
stubs and documentation to .as source for allowing .swf on external domains to work (recompile of .swf required)
- New
-
"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()
anddestruct()
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), newspectrumData
andpeakData
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 allowsplay()
to be called multiple times on a sound object, creating desired "chorus" effect. Will callonfinish()
multiple times, butwhileplaying()
etc. are called only for the first "play instance" to avoid complications.- New
soundSpectrum
andpeakData
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.)
- Flash 9 support! (soundmanager2_flash9.swf) -
-
V2.5b.20080525
- Added
waitForWindowLoad
for delayed init - Added
onpause()
andonresume()
event handlers - Added
mute()
andunmute()
- Updated demos, revised documentation
- Added
-
V2.5b.20080505
- To improve startup time,
soundManager.go()
(createMovie()
alias) now fires atdocument.onDOMContentLoaded()
by default if supported. (Otherwise, falls back towindow.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 ofwindow.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.)
- To improve startup time,
-
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, thesupported()
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()
orsetInterval()
. As a reulst, SoundManager 2 events likeonfinish()
,whileplaying()
andonfinish()
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()
whensoundManager.defaultOptions.autoLoad = true;
from withinsoundManager.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.
- 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
-
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 addedposition
option parameter, documentation + demo (bugfix) - Corrected
createSound()
andplay()
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 useposition
option parameter rather than undocumentedoffset
(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
- Modified
-
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
- Added
-
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