Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 583
Qrious Avatar asked May 12 '13 05:05

Qrious


2 Answers

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.

like image 195
apsillers Avatar answered Oct 27 '22 01:10

apsillers


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

like image 26
antoine129 Avatar answered Oct 27 '22 00:10

antoine129