Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Video canPlayType() method

Video canPlayType() method

Video Object Reference The Video object

Example

Detect whether your browser can play different types of video:

var x = document.createElement("VIDEO");

isSupp = x.canPlayType(vidType+';codecs="'+codType+'"');

Try it »


Definition and Usage

The canPlayType() method checks whether the browser can play the specified audio/video type.

The canPlayType() method can return one of the following values:


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the canPlayType() method

Note: Internet Explorer 8 and earlier IE versions do not support this method.


Syntax

videoObject

.canPlayType(

type

))

Parameter value

Value Description
type Describes the audio/video type to be detected.
 

通常可以是:


Usually it includes the codec:

Note: If a codec is included, the method can only return "probably".

|

Technical Details

| Return value: | Indicates the level of support. Possible values:

| | --- | --- |

Video Object Reference The Video object