Video canPlayType() Method
Definition and Usage
canPlayType()
Method checks if the browser can play the specified video type.
canPlayType()
The method can return one of the following values:
- "probably" - The browser is most likely to support this video type
- "maybe" - The browser may support this video type
- "" - (empty string) The browser does not support this video type
Example
Check if your browser can play different types of video:
var x = document.createElement("VIDEO"); isSupp = x.canPlayType(vidType+';codecs="'+codType+'"');
Syntax
videoObject.canPlayType(type)
Parameter
Parameter | Description |
---|---|
type |
Define the video 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 support levels. Possible return values:
|
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 9.0 | Support | Support | Support |