Ads

Hi Friends Please Visit My BLOG for more....



Friday, April 22, 2011

Listen to the music in any browser with audio.js (HTML5)



audio.js is a javascript library that lets you use HTML5 tag everywhere. And what does it mean “everywhere”? If you can use the tag, it will use it, otherwise it will connect the player to flash. The library also includes the UI display for this player, which can be modified by using css.

So, first put audio.js, player-graphics.gif and audiojs.swf in the same folder and then Include the audio.js file

<script src="/audiojs/audio.js"></script>

Initialise audio.js:


<script> 
  audiojs.events.ready(function() { 
    var as = audiojs.createAll();
  });
</script>
Now you only have to insert the code into the page

<audio src="/mp3/juicy.mp3" preload="auto" />


A series of API tests & examples for using and extending audio.js

Example 1 — Customised playlist player
Example 2 — Multiple players, testing preload, loop & autoplay attributes

Browser & format support

With Flash as a fallback, it should work pretty much anywhere.
It has been verified to work across:
• Mobile Safari (iOS 3+)
• Android (2.2+, w/Flash)
• Safari (4+)
• Chrome (7+)
• Firefox (3+, w/ Flash)
• Opera (10+, w/ Flash)
• IE (6, 7, 8, w/ Flash)

Audio.js focuses on playing mp3s. It doesn’t currently support the ogg format. As mp3 is the current defacto music transfer format, ogg support is lower on our list of priorities.

No comments:

Post a Comment