Skip to content
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!)

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.