canPlayType背后的原理是什么?
What is the rationale behind canPlayType?
所以,我最近在Twitter上看到了一个关于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,只是返回真/假?为什么要用模棱两可的词"也许"answers"可能"呢?
为什么?因为这是规范要求的http://dev.w3.org/html5/spec-preview/media-elements.html#dom-navigator-canplaytype
如果类型是用户代理知道它不能呈现的类型或类型为"应用程序/八字节流",则
canPlayType(type)
方法必须返回空字符串;如果用户代理确信该类型代表一个媒体资源,它必须返回"probably",如果与这个音频或视频元素一起使用,它可以呈现;否则它必须返回"maybe"。鼓励实现者返回"maybe",除非可以确定该类型是否被支持。通常,如果codecs参数不存在,用户代理不应该为允许使用该参数的类型返回"probably"。
相关文章:
- “var self = this”方法背后的原理是什么?
- React Router 如何处理 onEnter 背后的逻辑是什么?
- 让函数中的接收器默认为全局对象背后的基本原理是什么?
- AJAX 跨域安全背后的基本原理是什么?
- Facebook评论API - Facebook所说的“评论框背后”是什么意思
- Lightstreamer背后的魔力是什么
- d3背后的逻辑是什么.js nice()刻度
- JavaScript:“shift”方法背后的逻辑是什么?
- Math.max方法背后的逻辑是什么
- 与compareFunction一起使用的排序方法背后的逻辑是什么
- 用continuation生成Javascript代码背后的诀窍是什么
- 窗口背后的原因和窗口的顶部属性是什么
- 名称空间背后的概念是什么
- 堆栈溢出背后的算法是什么? ajax标记搜索字段
- 网站上的3D图像非常酷,但这背后的技术是什么?
- 使用Object.assign创建对象背后的思想是什么?
- canPlayType背后的原理是什么?
- javascript中var a = (expression1, expression2)背后的原因是什么?
- 错误处理-当JavaScript抛出ReferenceError时,其背后的逻辑是什么
- 选择一个完整的基于CSS的菜单和基于Javascript/CSS的菜单背后的基本原理是什么?