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

    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.