- From: <bugzilla@jessica.w3.org>
- Date: Thu, 14 Aug 2014 00:07:47 +0000
- To: public-html-bugzilla@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=26575
--- Comment #1 from David Dorwin <ddorwin@google.com> ---
*** Option #1 ***
One option is something we discussed when createSession() was first adopted
(before promises): a separate generateLicenseRequest() method. At the time, the
asynchronous timing issue did not exist and a license request would always be
generated when a session was created, so we chose to combine the two
operations. Now, we have asynchronous object creation and session loading.
** Changes **
Make creation of MediaKeySession objects a distinct synchronous method (keeping
the createSession name):
MediaKeySession createSession(optional SessionType sessionType =
"temporary");
Note: The sessionId attribute is initially empty.
Move the old createSession() and loadSession() algorithms to MediaKeySession
and rename them:
* Promise<void> generateLicenseRequest(DOMString initDataType, (ArrayBuffer or
ArrayBufferView) initData);
* Promise<bool> load(DOMString sessionId);
Apps would always follow these synchronous steps:
1. Call mediaKeys.createSession().
2. Add an event handler for "message".
3. Call generateLicenseRequest() or load().
** Examples **
New session:
var session = mediaKeys.createSession();
session.addEventListener("message", handleMessage, false);
session.generateLicenseRequest(initDataType, initData).then(
function() {
// There is nothing to do. Just wait for the "message" event.
}
).catch() {
function() {
// Handle the failure.
}
);
Load session:
var session = mediaKeys.createSession("persistent");
session.addEventListener("message", handleMessage, false);
session.load(sessionId).then(
function(isFound) {
if (isFound) {
// Session not found.
}
else
// Session is loaded - use it. May also receive a "message" event in an
undetermined order.
}
}
).catch() {
function() {
// Handle the failure. (As with the current API, per the Promises Guide,
this does not include failing to find the session.)
}
);
--
You are receiving this mail because:
You are the QA Contact for the bug.
Received on Thursday, 14 August 2014 00:07:55 UTC