Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an event callback to know when html5 <audio> has loaded the audio and is playable?

Tags:

html

audio

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?

like image 573
dan Avatar asked Aug 07 '11 14:08

dan


People also ask

What is the correct HTML5 element for playing audio files?

The HTML <audio> element is used to play an audio file on a web page.

How is playing audio and video in HTML 5.0 and give example?

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.

Which attributes of audio tag allow video automatically seek back to the start after reaching at the end?

A Boolean attribute: if specified, the audio player will automatically seek back to the start upon reaching the end of the audio.

What attributes are added for inserting an audio in HTML 5?

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.


1 Answers

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

like image 98
Achshar Avatar answered Sep 27 '22 00:09

Achshar