W3C home > Mailing lists > Public > public-html-media@w3.org > September 2014

Re: [EME] Exposing key status to applications

From: Boris Zbarsky <bzbarsky@mit.edu>
Date: Fri, 26 Sep 2014 11:54:47 -0400
Message-ID: <54258C47.1020007@mit.edu>
To: Mark Watson <watsonm@netflix.com>, David Dorwin <ddorwin@google.com>
CC: "public-html-media@w3.org" <public-html-media@w3.org>
On 9/26/14, 10:49 AM, Mark Watson wrote:
> Personally, I would think a simple API that would achieve this would
> look like a Key ID -> Status map that can be synchronously accessed,
> with events when it changes. So, if session is my MediaKeySession, I
> would be able to do things like
> var mykeystatus = session.keys[ myKeyId ];
> and
> for ( keyId in session.keys ) { ... }

I assume myKeyId is some kinda arbitrary string, right?

The best way to do that, as of today's thinking on API design, is to 
create an interface that mimics the ES Map API but doesn't provide any 
of the mutation methods.

That would give you things like:

   var mykeystatus = session.keys.get(myKeyId)


   for (keyId of session.keys.keys())  // loops over key ids


   for (keyStatus of session.keys.values()) // loops over key statuses

The fact that two very different things are being called "keys" here is 
a bit annoying, I agree.  :(

You can certainly do this all with Web IDL, though it's a pretty manual 
process to define things like keys() and values().  There are some 
proposals to doing it somewhat automagically via dedicated "make this 
look like a Map" IDL syntax, but nothing concrete there yet.

The reason to do it that way instead of using direct JS property access 
as you proposed is that this will prevent issues like name collisions 
with various builtin stuff (like methods on the object itself).

Whether this sort of API is best for solving your initial problem, I 
can't tell you, but if it is it's quite possible to create.

Received on Friday, 26 September 2014 15:55:22 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 15:48:54 UTC