简体   繁体   English

canPlayType背后的原理是什么?

[英]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.

相关问题 JavaScript中构造函数指针的行为背后的原理是什么? - What is the rationale behind the behavior of constructor pointer in JavaScript? AJAX跨域安全性的基本原理是什么? - What is the rationale behind AJAX cross-domain security? 将函数接收器默认为全局对象的理由是什么? - What was the rationale behind having the receiver in functions default to the global object? jQuery $(this)背后的原理 - Rationale behind $(this) in jQuery AngularJS中属性规范化的基本原理 - Rationale behind attribute normalisation in AngularJS 在ECMAScript 6草案中,使用StopIteration异常来表示迭代结束的原因是什么? - In Draft ECMAScript 6, what's the rationale behind using StopIteration exception to signal the end of iteration? 选择完整的基于 CSS 的菜单和基于 Javascript/CSS 的菜单的理由是什么? - What is the rationale behind choose a complete CSS based menu and Javascript/CSS based menu? JavaScript中'this'关键字行为的基本原理是什么? - What is the rationale for the behavior of the 'this' keyword in JavaScript? 此JavaScript表达式的结构是什么,为什么将其评估为“真”? (HTML5音频标签和canPlayType()函数) - What is the structure of this JavaScript expression and why does it evaluate to 'true'? (HTML5 audio tag and canPlayType() function) 请解释这个简单的javascript面试问题背后的基本原理 - Please explain the rationale behind this simple javascript interview question
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM