The difference between canPlayType may be and possibly the output

I am creating a video framework where I have to sniff out the possibilities of playing HTML5 in videos of different browsers. For this, I used the canPlayType () method, which gives me three possible results:

  • empty line (if the video fails to start)
  • "may be"
  • "probably"

I need to know the exact difference between "maybe" and "maybe." Please let me know if anyone can solve my confusion. Thanks in advance.

+6
source share
3 answers

probably means that the browser can play the described media type. maybe means the type can be played. This is usually due to the fact that the described type of media is not well defined to make a decision.

For example, the audio/ogg type may or may not be reproducible, because Ogg is a container type that can contain several different codecs. Vorbis and Opus are two Ogg-contained codecs. The browser’s ability to play Ogg files says nothing at all about the browser’s ability to play in Vorbis or Opus code, so it cannot tell if 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 tell you for sure if it can play this type.

To make an analogy: suppose you ask me if I can drive your boat. I am good at managing tiny speedboats, but I can't control a huge cruise ship. I have to answer the question: "Can you drive my boat?" with Maybe because you didn’t tell me which boat.

+5
source

Specification of the W3 specification: http://www.w3.org/TR/2011/WD-html5-20110113/video.html#mime-types

media.canPlayType(type) returns an empty string (negative), “maybe” or “maybe” based on how confident the user agent is that it can play media of this type.

See the MDN for more information: https://developer.mozilla.org/en/docs/Web/API/HTMLMediaElement#Methods

  • "possible": if the specified type seems reproducible.
  • "possible": if it is impossible to determine whether this type is reproduced without reproducing it.
  • Empty line: if the specified type definitely cannot be played.

Also, in some cases (although this only happens for <audio> elements), the return value is "no" instead of an empty string:

http://24ways.org/2010/the-state-of-html5-audio

http://diveintohtml5.info/everything.html

+2
source

Source: http://www.w3schools.com/tags/av_met_canplaytype.asp

The canPlayType () method can return one of the following values:

  • "possible" - the browser most likely supports this type of audio / video
  • "possible" - the browser can support this type of audio / video
  • "" - (empty line) browser does not support this audio / video type
-2
source

Source: https://habr.com/ru/post/944804/


All Articles