This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The HTMLMediaElement method canPlayType() reports how likely it is that the current browser will be able to play media of a given MIME type.
canPlayType(type)
typeA string specifying the MIME type of the media and (optionally) a codecs parameter containing a comma-separated list of the supported codecs.
A string indicating how likely it is that the media can be played. The string will be one of the following values:
"" (empty string)The media cannot be played on the current device.
probablyThe media is probably playable on this device.
maybeThere is not enough information to determine whether the media can play (until playback is actually attempted).
let obj = document.createElement("video");
console.log(obj.canPlayType("video/mp4")); // "maybe"
| Specification |
|---|
| HTML> # dom-navigator-canplaytype-dev> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
canPlayType |
3["codecs string can contain any subset of optional parameters (should be all or none).", "Errors if codecs string contains unexpected characters (should evaluate string up to character)."] |
12["codecs string can contain any subset of optional parameters (should be all or none).", "Errors if codecs string contains unexpected characters (should evaluate string up to character)."] |
3.5["Before Firefox 28,canPlayType() returned probably when asked about WebM audio or video files without the codecs parameter. Since multiple codecs are supported, this is not enough information to determine if a file can be played, so maybe is now correctly returned.", "Before Firefox 101, canPlayType() ignored codecs parameter options for av01 codecs (treating them as av1)."] |
≤12.1["codecs string can contain any subset of optional parameters (should be all or none).", "Errors if codecs string contains unexpected characters (should evaluate string up to character)."] |
4 | 18["codecs string can contain any subset of optional parameters (should be all or none).", "Errors if codecs string contains unexpected characters (should evaluate string up to character)."] |
4["Before Firefox for Android 28,canPlayType() returned probably when asked about WebM audio or video files without the codecs parameter. Since multiple codecs are supported, this is not enough information to determine if a file can be played, so maybe is now correctly returned.", "Before Firefox for Android 101, canPlayType() ignored codecs parameter options for av01 codecs (treating them as av1)."] |
≤12.1["codecs string can contain any subset of optional parameters (should be all or none).", "Errors if codecs string contains unexpected characters (should evaluate string up to character)."] |
3 | 1.0["codecs string can contain any subset of optional parameters (should be all or none).", "Errors if codecs string contains unexpected characters (should evaluate string up to character)."] |
4.4["codecs string can contain any subset of optional parameters (should be all or none).", "Errors if codecs string contains unexpected characters (should evaluate string up to character)."] |
3 |
HTMLMediaElement: Interface used to define the HTMLMediaElement.canPlayType() methodMediaCapabilities
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/canPlayType