Skip to content

Instantly share code, notes, and snippets.

@GirlBossRush
Created November 11, 2014 08:14
Show Gist options
  • Save GirlBossRush/7719f8ca55ad6222e2a2 to your computer and use it in GitHub Desktop.
Save GirlBossRush/7719f8ca55ad6222e2a2 to your computer and use it in GitHub Desktop.
/*
* Written by Andrew Plummer @Cerego Japan
*
* This plugin will play MP3 audio in the browser natively if HTML5 audio exists,
* and using Flash otherwise. It provides a very minimal Flash satay that works in
* the major browsers that require it. UPDATE: HTML5 audio in Webkit still appears to
* have some issues with data loading. Specifically caching *occasionally* causes events
* not to fire (loadeddata, canplay, canplaythrough). Any code depending on these callbacks
* to proceed will break, so turning off html5 audio support for the time being.
*
* Additionally it will convert links with rel=audio to the <audio> tag for Apple mobile devices,
* which can't play audio natively through Javascript. UPDATE: Unfortunately this is crashing
* iPhone safari at the moment (too many audio links at the same time?) so taking this out as a
* default, and leaving it as opt-in.
*
* Note that when using the embedded SWF object, it MUST:
*
* 1. Be visible (no display:none; ... visibility: hidden MAY work...must have height and width)
* 2. Needs allowscriptaccess... 'sameDomain' is OK
* 3. FF requires a 'data' parameter on <object>
* 4. IE requires a 'classid' parameter on <object> and 'movie' parameter on <param>
* 5. On occasion 'wmode' can make it either mess up or not... still can't figure out the relation
* 6. swf can't be inside a form in IE
* 7. swf *MUST* be in the page at load
* 8. More... yes there's more
*
* Note that the flash satay MUST be included with document.write here or internet explorer will freak
* out. Apparently the connection with ExternalInterface requires the swf to be in the page at the point
* of load.
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment