Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/396.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript canPlayType背后的基本原理是什么?_Javascript_Html_Html5 Video_Html5 Audio - Fatal编程技术网

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

Javascript canPlayType背后的基本原理是什么?,javascript,html,html5-video,html5-audio,Javascript,Html,Html5 Video,Html5 Audio,所以,我最近在推特上看到了对的一个引用。基本上,总结如下: 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 ty

所以,我最近在推特上看到了对的一个引用。基本上,总结如下:

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,只返回真/假?。。。为什么用“可能”和“可能”这两个模棱两可的词?为什么?因为这就是规范所说的

如果类型是用户代理知道它无法呈现的类型,或者类型是“应用程序/八位字节流”,则
canPlayType(type)
方法必须返回空字符串;如果用户代理确信该类型表示一种媒体资源,并且如果与该音频或视频元素一起使用,则该类型必须返回“可能”;否则它必须返回“也许”。鼓励实现者返回“maybe”,除非可以确定该类型是否受支持。通常,对于允许codecs参数(如果该参数不存在)的类型,用户代理永远不应返回“可能”


MDN总是比您链接到的内容更好。是的,我知道@epascarello。。但是,没有办法只使用MDN链接到该方法……这不会让事情变得不那么混乱;)为什么这被认为是一件好事,包括在规范中?这是写规范的人对为什么这样做的看法。基本上,这是一种“遮住你的屁股”的方式,在没有确定终点的情况下添加支持检测,以确定它是否得到了真正的支持。他们应该加入“可能”、“可能”和“可以想象”来澄清问题。