Tuesday, October 13, 2009

html5 audio




J.A.I. or "Javascript Audio Interface"


// Create an array of the <audio> resources
var playlist = document.getElementById('jai').getElementsByTagName('audio');

// Beings playing the first audio file
playlist[0].play();

// Mutes the audio
playlist[0].volume=0;

// Returns the current volume of the resource
var volume = playlist[0].volume;

// Gets the length in seconds of the audio (not always 100% accurate)
var length = playlist[0].duration;

// Gets the current position of the track in seconds
var time = playlist[0].currentTime;

// Sets the current position of the track to 10 seconds
playlist[0].currentTime = 10;

// Pauses the audio at it's current position
playlist[0].pause();

// Gets the URL of the audio file
var filename = playlist[0].src;


audio player HTML5 style
Using audio and video in Firefox
HTML 5 Draft - Media elements
nsIDOMHTMLMediaElement
HTML5 Audio Soundboard


$("audio").removeAttr("controls").each(function(i, audioElement) {
var audio = $(this);
var that = this;
$("#doc").append($('<button>'+audio.attr("title")+'</button>')
.click(function() {
that.play();
));
});