[英]What is the rationale behind canPlayType?
So, I recently saw a reference to canPlayType on Twitter. 因此,我最近在Twitter上看到了对canPlayType的引用。 Basically the summary is: 基本上,摘要是:
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
Why does it not behave like a typical API and just return true/false?... And why the very ambiguous terms "maybe" and "probably"? 为什么它的行为不像典型的API并只返回true / false?...以及为什么非常模糊的术语“也许”和“可能”?
Why? 为什么? Because that is what the spec says to do http://dev.w3.org/html5/spec-preview/media-elements.html#dom-navigator-canplaytype 因为规范就是这样做的,所以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"; 如果type是用户代理知道无法呈现的类型,或者类型是“ application / octet-stream”,则canPlayType(type)
方法必须返回空字符串; 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. 通常,对于允许编解码器参数的类型,如果该参数不存在,则用户代理绝对不应返回“可能”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.