Reputation: 277
So this is what I want.
If audio src is valid, then the audio shows controls.
If not then it doesn't show controls
But how in the world do I detect if audio src is valid?
Upvotes: 1
Views: 881
Reputation: 546
You dont actally need jQuery to check if it has been loaded correctly
HTML:
<audio onloadeddata="myOnLoadedData()" controls preload="auto">
<source src="source here" type="audio/ogg">
<source src="source here" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
JS:
function myOnLoadedData() { ... do your thing, show controls }
You can also check if the audio can be played by using oncanplay
attribute
Upvotes: 2