简体   繁体   中英

Difference between canPlayType maybe and probably output

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:

  1. the empty String (when unable to run the video)
  2. "maybe"
  3. "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.

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 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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM