Latest web development tutorials

HTML DOM Video canPlayType () method

Video Object Reference Video Object

Examples

Detect your browser can play different types of video:

var x = document.createElement("VIDEO");
isSupp = x.canPlayType(vidType+';codecs="'+codType+'"');

try it"

Definition and Usage

canPlayType () method to specify whether the browser can play 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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support canPlayType () method

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


grammar

videoObject .canPlayType( type ))

Parameter Value

描述
type 描述要检测的音频/视频类型。

通常可以是:

  • video/ogg
  • video/mp4
  • video/webm

通常指,包含解码器:

  • video/ogg; codecs="theora, vorbis"
  • video/mp4; codecs="avc1.4D401E, mp4a.40.2"
  • video/webm; codecs="vp8.0, vorbis"

注意: 如果包含了解码器,该方法只可能返回"probably"。

technical details

return value: He expressed support level. Possible values:
    • "Probably" - most likely support
    • "Maybe" - may support
    • "" - (Null string) is not supported


Video Object Reference Video Object