Audio Player 2.0.4.1 with HTML5 Fallback
-
Hi everyone,
I modified Audio Player 2.0.4.1 to include a HTML5 audio element as a fallback option.
The SWF is still the first option, only if this fails and HTML5-audio is available with canPlayType “mp3”, an audio element is injected. Finally, if both options fail, the behavior is like with the standard version. Even if MP3 isn’t supported by all browsers, this modification adds at least support for iPhones and iPads.The code expects the soundfile-URL to be either escaped or base64-encoded (these are the standard formats of the plugin).
As this might be of wider interest and I didn’t find a way to contact the authors, I’m posting the code here.
- The first link points to the (long) source version.
- The second link points to a minfied version of the same script.
Installation is a bit difficult:
- You could either exchange the file “audioplayer.js” in your plug-in directory, which is definitely not wise to do as it might interfere with any updates.
- I choose to not call wp_head() in my theme and to output all headers by php.
(This leaves you with the task of generating all header elements by your own.)
This way I referred a file in a special directory inside my theme:
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/js/audio-player-html5.js?ver=2.0.4.1">
Hopefully the modifications will migrate to the standard code, so that the HTML5 fallback would become available by a simple update.
Norbert
- The topic ‘Audio Player 2.0.4.1 with HTML5 Fallback’ is closed to new replies.