问题
I am creating a Video Sniffing Framework where I have to sniff different browsers' HTML5 Video playing capability. For that I used the canPlayType() method which is giving me three possible results:
- the empty String (when unable to run the video)
- "maybe"
- "probably"
I need to know the exact difference between "maybe" and "probably". Please let me to know if anyone can resolve my confusion. Thanks in advance.
回答1:
probably
means that the browser can play the media type described. maybe
means that the type might be playable. Usually, this is because the media type described is not specific enough to make a decision.
For example, the type audio/ogg
may or may not be playable, because Ogg is a container type that could contain several different codecs. Vorbis and Opus are two Ogg-containable codecs. A browser's ability to play Ogg files in general says nothing about the browser's ability to play Vorbis or Opus codecs, so it can't say whether it can play your Ogg file.
If you ask about a specific codec with audio/ogg; codecs=vorbis
, then the browser can say for sure whether it can play that type.
To make an analogy: suppose you ask me if I am able to drive your boat. I am good at driving tiny speedboats, but I cannot drive a massive cruise boat. I must answer the question "Can you drive my boat?" with "Maybe," because you haven't told me exactly what type of boat it is.
回答2:
Stating the W3 specification: http://www.w3.org/TR/2011/WD-html5-20110113/video.html#mime-types
media.canPlayType(type)
returns the empty string (a negative response), "maybe", or "probably" based on how confident the user agent is that it can play media resources of the given type.
More details are given on MDN: https://developer.mozilla.org/en/docs/Web/API/HTMLMediaElement#Methods
- "probably": if the specified type appears to be playable.
- "maybe": if it's impossible to tell whether the type is playable without playing it.
- The empty string: if the specified type definitely cannot be played.
Also, in some cases (although that seems to happen only for <audio>
elements), the returned value is "no"
instead of the empty string:
http://24ways.org/2010/the-state-of-html5-audio
http://diveintohtml5.info/everything.html
回答3:
Source : http://www.w3schools.com/tags/av_met_canplaytype.asp
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
来源:https://stackoverflow.com/questions/16504367/difference-between-canplaytype-maybe-and-probably-output