HTMLMediaElement:canPlayType() 方法
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
HTMLMediaElement
的 canPlayType()
方法用于报告当前浏览器播放指定 MIME 类型媒体的可能性。
语法
js
canPlayType(type)
参数
返回值
示例
js
let obj = document.createElement("video");
console.log(obj.canPlayType("video/mp4")); // “maybe”
规范
Specification |
---|
HTML # dom-navigator-canplaytype-dev |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
canPlayType() |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
参见
HTMLMediaElement
:用于定义HTMLMediaElement.canPlayType()
方法的接口MediaCapabilities
- 处理 Web 内容中的媒体支持问题
- 媒体类型和格式指南
- 常见媒体类型的编解码器