[Bug 25923] isTypeSupported should be asynchronous

https://www.w3.org/Bugs/Public/show_bug.cgi?id=25923

--- Comment #4 from David Dorwin <ddorwin@google.com> ---
(In reply to Anne from comment #2)
> Can't they make a bunch of calls simultaneously and use Promise.all() or
> some such to deal with synchronizing the results?

It seems that with Promise.all(), the checked value and handling would be
separated, which could be difficult to maintain. Is there a better solution to
the following? (Some names have been shortened for readability.)

Promise.all([iTS("system1", "webm"), iTS("system1", "cenc"), iTS("system2",
"webm"), ...]).then(
  function(responses) {
    if (responses[0]) {
      keySystem = "system1";
      mediaType = "webm";
    } else if (responses[1]) {
      keySystem = "system1";
      mediaType = "cenc";
    } else if ...
    ...
});

If one of the calls is rejected for whatever reason, the application will just
fail because it will have no information. The algorithm would need to use
reject only for syntax problems.


Another advantage of the current implementation is the ability to drill down to
a specific selection without trying all possible combinations. For example:

var keySystem;
if (MediaKeys.isTypeSupported("com.example")) {
  if (MediaKeys.isTypeSupported("com.example.somesystem")) {
    keySystem = "com.example.somesystem";
    if (MediaKeys.isTypeSupported("com.example.somesystem", "webm")) {
      if (MediaKeys.isTypeSupported("com.example.somesystem", "webm",
"video/webm; codecs='vp8, vorbis'")) {
      ...
    } else if (MediaKeys.isTypeSupported("com.example.somesystem", "cenc")) {
      ...
  } else if (MediaKeys.isTypeSupported("com.example.othersystem")) {
    ...
  }
} else if (MediaKeys.isTypeSupported("com.foobar")) {
  keySystem = "com.foobar";
  ...
}


The ability to short circuit and not try all combinations would be an advantage
if each system involved a separate prompt. There's no reason to prompt the user
(as is the case with simultaneous calls) for something that isn't actually
going to be used.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Friday, 30 May 2014 18:11:55 UTC