Skip to content

The simplest flash fallback for HTML5 audio playback available, written in under 50 LOC.

Notifications You must be signed in to change notification settings

sauspiel/flash-sound-player

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flash-sound-player

The simplest flash fallback for HTML5 audio playback available, written in under 50 LOC.

Why?

Because Firefox still can't play sounds without crashing, see https://bugzilla.mozilla.org/show_bug.cgi?id=744836.

Usage

Embed the swf in your markup:

<object id="flash_sound_player" type="application/x-shockwave-flash" data="flash_sound_player.swf" width="0" height="0" allowscriptaccess="always">
  <p>You should not see this if flash is working</p>
</object>

Use javascript to play a sound:

document.getElementById("flash_sound_player").playSound("http://assets.sauspiel.de/sounds/male/allgaeuerisch/greeting/begruessung-1.mp3");

Be sure to have a crossDomain.xml file on the host that allows the loading of the sound files, for more information see the Adobe Developer Conneciton site.

Need to detect Flash first? There you go.

var hasFlash = false;
try {
  ao = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
  hasFlash = ao != null;
} catch (e) {
  hasFlash = navigator.mimeTypes["application/x-shockwave-flash"] !== void 0;
}

Building

Get the Flex SDK, and set FLEX_HOME, e.g.:

export FLEX_HOME=~/Downloads/flex_sdk_4

and run ./build.sh.

© 2013 Martin Kavalar, Sauspiel GmbH

About

The simplest flash fallback for HTML5 audio playback available, written in under 50 LOC.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published