HTML Audio / Video DOM canPlayType () method
HTML Audio / Video DOM Reference
Examples
Detect your browser can play different types of video:
myVid=document.createElement('video');
isSupp=myVid.canPlayType(vidType+';codecs="'+codType+'"');
isSupp=myVid.canPlayType(vidType+';codecs="'+codType+'"');
try it"
Definition and Usage
canPlayType () method to detect whether the browser can play the specified audio / video type.
canPlayType () method returns one of the following values:
- "Probably" - the most likely to support the browser of the audio / video type
- "Maybe" - perhaps the browser supports the audio / video type
- "" - (Null string) browser does not support the audio / video type
Browser Support
All major browsers support canPlayType () method.
Note: 8 and earlier versions of Internet Explorer does not support this method.
grammar
audio|video .canPlayType( type ))
parameter
值 | 描述 |
---|---|
type | 规定要检测的音频/视频类型(和可选的编解码器)。 常用值:
常用值,包括编解码器:
注意:如果包含编解码器,则该方法只能返回 "probably"。 |
return value
类型 | 描述 |
---|---|
String | 表示支持的级别。可能的返回值:
|
HTML Audio / Video DOM Reference