I have controls that load mp3 files from other sites, but if it take the audio file a while to start loading, the controls stay disabled for a few seconds and appear not to be working.
If I show an activity indicator when the audio control starts loading the resource, is there a callback I can use to hide the indicator when the audio control is ready to start playing the audio and ready for user interaction?
The HTML <audio> element is used to play an audio file on a web page.
HTML5 features include native audio and video support without the need for Flash. The HTML5 <audio> and <video> tags make it simple to add media to a website. You need to set src attribute to identify the media source and include a controls attribute so the user can play and pause the media.
A Boolean attribute: if specified, the audio player will automatically seek back to the start upon reaching the end of the audio.
Example 1 (Adding audio to Webpage): The controls attribute is used to add audio controls such as play, pause, and volume. The “source” element is used to specify the audio files which the browser may use. The first recognized format is used by the browser.
element.addEventListener('loadedmetadata', callback, false);
apart form loadedmetadata
, load
can also be used to see if the song is also loaded
https://developer.mozilla.org/en/Introducing_the_Audio_API_Extension
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With