gpt4 book ai didi

javascript - canPlayType 背后的基本原理是什么?

转载 作者:行者123 更新时间:2023-11-28 07:07:16 27 4
gpt4 key购买 nike

所以,我最近看到了对 canPlayType 的引用在推特上。基本上总结是:

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

The canPlayType() method can return one of the following values:

"probably" - the browser most likely supports this audio/video type
"maybe" - the browser might support this audio/video type
"" - (empty string) the browser does not support this audio/video type

为什么它的行为不像典型的 API 而只是返回 true/false?...以及为什么使用非常模糊的术语“也许”和“可能”?

最佳答案

为什么?因为这就是规范所说的 http://dev.w3.org/html5/spec-preview/media-elements.html#dom-navigator-canplaytype

The canPlayType(type) method must return the empty string if type is a type that the user agent knows it cannot render or is the type "application/octet-stream"; it must return "probably" if the user agent is confident that the type represents a media resource that it can render if used in with this audio or video element; and it must return "maybe" otherwise. Implementors are encouraged to return "maybe" unless the type can be confidently established as being supported or not. Generally, a user agent should never return "probably" for a type that allows the codecs parameter if that parameter is not present.

关于javascript - canPlayType 背后的基本原理是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31613082/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com