Add and play sound through JavaScript
var audioElement = document.createElement('audio'); audioElement.setAttribute('src', 'loading.ogg'); audioElement.play();
Get the path and duration of a song file
audioElement.src; audioElement.duration;
Download sound
var audioElement = document.createElement('audio'); audioElement.setAttribute('src', 'Mogwai2009-04-29_acidjack_t16.ogg'); audioElement.load() audioElement.addEventListener("load", function() { audioElement.play(); $(".duration span").html(audioElement.duration); $(".filename span").html(audioElement.src); }, true);
Stop song
audioElement.pause();
Change volume
audioElement.volume=0;
Play exactly 35 seconds in a song
audioElement.currentTime=35; audioElement.play();
source share