Some audio/ogg files with special codec can't be played with html5 audio tag. How can I detect it to show a message for user to download file and play with special player?
0
votes
1 Answers
1
votes
You can use the audio element's canplaytype
method to detect whether or not the current browser can play a specific codec.
Example from diveintohtml5
function canPlay (codec) {
var a = document.createElement('audio');
return !!(a.canPlayType && a.canPlayType(codec).replace(/no/, ''));
}
canPlay('audio/ogg; codecs="vorbis"'); // true or false