The HTMLMediaElement
method canPlayType()
reports how likely it is that the current browser will be able to play media of a given MIME type.
Note: This feature is not available in Web Workers.
The HTMLMediaElement
method canPlayType()
reports how likely it is that the current browser will be able to play media of a given MIME type.
Note: This feature is not available in Web Workers.
js
canPlayType(type)
type
A 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:
js
let obj = document.createElement("video"); console.log(obj.canPlayType("video/mp4")); // "maybe"
Specification |
---|
HTML Standard # dom-navigator-canplaytype-dev |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
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 )."] |
9 | ≤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 | ≤37["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)."] |
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 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)."] |
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)."] |
HTMLMediaElement
: Interface used to define the HTMLMediaElement.canPlayType()
methodMediaCapabilities
© 2005–2023 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