Audio canPlayType() Method
Definition and usage
canPlayType()
Method checks if the browser can play the specified audio type.
canPlayType()
The method can return one of the following values:
- "probably" - The browser is most likely to support this audio type
- "maybe" - The browser may support this audio type
- "" - (empty string) The browser does not support this audio type
Example
Check if your browser can play different types of audio:
var x = document.createElement("AUDIO"); isSupp = x.canPlayType(vidType+';codecs="'+codType+'"');
Syntax
audioObject.canPlayType(type)
Parameter value
Value | Description |
---|---|
type |
Define the supported audio types (and optional codecs) to be tested. Common values:
Common values, including codecs:
Note:If the codec is included, this method can only return "probably". |
Technical Details
Return Value: |
String values representing the support level. Possible return values:
|
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 9.0 | Support | Support | Support |