HTML Audio/Video DOM canPlayType() Method

❮ HTML Audio/Video DOM Reference

Example

function supportType(e,vidType,codType) {
  var vid = document.createElement('video');
  isSupp = vid.canPlayType(vidType+';codecs="'+codType+'"');
  if (isSupp == "") {
    isSupp = "No";
  }
  e.target.parentNode.innerHTML = "Answer: " + isSupp;
}

Meaning

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

Return value:


Standard Syntax

audio|video.canPlayType(type)



Browser Support




Status







Parameter Value

Type Description
type Specifies the audio/video type to test support for.

Common values:

  • video/ogg
  • video/mp4
  • video/webm
  • audio/mpeg
  • audio/ogg
  • audio/mp4
❮ HTML Audio/Video DOM Reference