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?
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
You can use events on MediaControllers:
http://dev.w3.org/html5/spec/Overview.html#handler-mediacontroller-oncanplay
Example:
var controller = new MediaController();
var audio = document.createElement('audio');
audio.controller = controller;
audio.oncanplay = function (event) {};
精彩评论