How you would test to see if the source type worked, is to find a web browser that cannot play the media that you want to play. The type attribute prevents the web browser from starting to download media that it doesn’t know how to play.
You can set type on the player all you like, but it has no effect, because player refers to the <audio> element, not a <source> element. Any attribute on an element that the browser doesn’t understand, it just simply ignores.
Each element also has a type attribute. This is optional, but it is advised that you include them — they contain the MIME types of the video files, and browsers can read these and immediately skip videos they don’t understand. If they are not included, browsers will load and try to play each file until they find one that works, taking even more time and resources.
I was reading about this, what exactly is its purpose, what’s it for, and what does it do?
What would be a reason why someone would include this in the code?
If I were to add it to this, as an exercise, how would it be done?
audio.canPlayType
Would this go inside the javascript, and it’s supposed to do something?
Definition and Usage
The canPlayType() method checks if the browser can play the specified audio type.
The canPlayType() method can return one of the following values:
"probably" - the browser most likely supports this audio type
"maybe" - the browser might support this audio type
"" - (empty string) the browser does not support this audio type