[EME] Update examples to use 'type' attribute of MediaKeyNeededEvent (Bug 19096)
authorDavid Dorwin <ddorwin@google.com>
Thu, 31 Oct 2013 14:17:16 -0700
changeset 186 e2673ee7ed4f
parent 185 1f0ddb1a6de4
child 187 aab3a46a5c9f
[EME] Update examples to use 'type' attribute of MediaKeyNeededEvent (Bug 19096)
encrypted-media/encrypted-media.html
encrypted-media/encrypted-media.xml
--- a/encrypted-media/encrypted-media.html	Thu Oct 31 11:00:32 2013 -0700
+++ b/encrypted-media/encrypted-media.html	Thu Oct 31 14:17:16 2013 -0700
@@ -56,7 +56,7 @@
     <div class="head">
       <p><a href="http://www.w3.org/"><img src="https://www.w3.org/Icons/w3c_home" alt="W3C" width="72" height="48"></a></p>
       <h1>Encrypted Media Extensions</h1>
-      <h2 id="draft-date">W3C Editor's Draft 30 October 2013</h2>
+      <h2 id="draft-date">W3C Editor's Draft 31 October 2013</h2>
       <dl>
         <dt>This Version:</dt>
         <dd><a href="http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html">http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html</a></dd>
@@ -1172,7 +1172,7 @@
     if (!keySession)
       throw "Could not create key session";
 
-    keySession.addEventListener("<a href="#dom-eventmessage">message</a>",handleMessage,false);
+    keySession.addEventListener("<a href="#dom-eventmessage">message</a>", handleMessage, false);
   }
 
   function handleMessage(event) {
@@ -1201,18 +1201,17 @@
 &lt;script&gt;
   function handleKeyNeeded(event) {
     var video = event.target;
-    var initData = event.<a href="#dom-initdata">initData</a>;
 
     if (!video.<a href="#dom-keys">keys</a>)
       video.<a href="#dom-setmediakeys">setMediaKeys</a>(new <a href="#dom-mediakeys">MediaKeys</a>("org.w3.clearkey"));
     if (!video.<a href="#dom-keys">keys</a>)
       throw "Could not create MediaKeys";
 
-    var keySession = video.<a href="#dom-keys">keys</a>.<a href="#dom-createsession">createSession</a>(mimeType, initData);
+    var keySession = video.<a href="#dom-keys">keys</a>.<a href="#dom-createsession">createSession</a>(event.<a href="#dom-type">type</a>, event.<a href="#dom-initdata">initData</a>);
     if (!keySession)
       throw "Could not create key session";
 
-    keySession.addEventListener("<a href="#dom-eventmessage">message</a>",handleMessage,false);
+    keySession.addEventListener("<a href="#dom-eventmessage">message</a>", handleMessage, false);
   }
 
   function handleMessage(event) {
@@ -1242,18 +1241,17 @@
 &lt;script&gt;
   function handleKeyNeeded(event) {
     var video = event.target;
-    var initData = event.<a href="#dom-initdata">initData</a>;
 
     if (!video.<a href="#dom-keys">keys</a>)
       video.<a href="#dom-setmediakeys">setMediaKeys</a>(new <a href="#dom-mediakeys">MediaKeys</a>("com.example.somesystem.1_0"));
     if (!video.<a href="#dom-keys">keys</a>)
       throw "Could not create MediaKeys";
 
-    var keySession = video.<a href="#dom-keys">keys</a>.<a href="#dom-createsession">createSession</a>(mimeType, initData);
+    var keySession = video.<a href="#dom-keys">keys</a>.<a href="#dom-createsession">createSession</a>(event.<a href="#dom-type">type</a>, event.<a href="#dom-initdata">initData</a>);
     if (!keySession)
       throw "Could not create key session";
 
-    keySession.addEventListener("<a href="#dom-eventmessage">message</a>",licenseRequestReady,false);
+    keySession.addEventListener("<a href="#dom-eventmessage">message</a>", licenseRequestReady, false);
   }
 
   function licenseRequestReady(event) {
@@ -1301,7 +1299,6 @@
 
   function handleKeyNeeded(event) {
     var video = event.target;
-    var initData = event.<a href="#dom-initdata">initData</a>;
 
     if (!video.<a href="#dom-keys">keys</a>) {
       selectKeySystem();
@@ -1310,11 +1307,11 @@
     if (!video.<a href="#dom-keys">keys</a>)
       throw "Could not create MediaKeys";
 
-    var keySession = video.<a href="#dom-keys">keys</a>.<a href="#dom-createsession">createSession</a>(mimeType, initData);
+    var keySession = video.<a href="#dom-keys">keys</a>.<a href="#dom-createsession">createSession</a>(event.<a href="#dom-type">type</a>, event.<a href="#dom-initdata">initData</a>);
     if (!keySession)
       throw "Could not create key session";
 
-    keySession.addEventListener("<a href="#dom-eventmessage">message</a>",licenseRequestReady,false);
+    keySession.addEventListener("<a href="#dom-eventmessage">message</a>", licenseRequestReady, false);
   }
   
   function licenseRequestReady(event) {
@@ -1381,7 +1378,6 @@
 
   function handleKeyNeeded(event) {
     var video = event.target;
-    var initData = event.<a href="#dom-initdata">initData</a>;
 
     if (!video.<a href="#dom-keys">keys</a>) {
       selectKeySystem();  // See previous example for implementation.
@@ -1390,13 +1386,13 @@
     if (!video.<a href="#dom-keys">keys</a>)
       throw "Could not create MediaKeys";
 
-    var keySession = video.<a href="#dom-keys">keys</a>.<a href="#dom-createsession">createSession</a>(mimeType, initData);
+    var keySession = video.<a href="#dom-keys">keys</a>.<a href="#dom-createsession">createSession</a>(event.<a href="#dom-type">type</a>, event.<a href="#dom-initdata">initData</a>);
     if (!keySession)
       throw "Could not create key session";
 
-    keySession.addEventListener("<a href="#dom-eventmessage">message</a>",handleMessage,false);
-    keySession.addEventListener("<a href="#dom-eventready">ready</a>",handleReady,false);
-    keySession.addEventListener("<a href="#dom-eventerror">error</a>",handleError,false);
+    keySession.addEventListener("<a href="#dom-eventmessage">message</a>", handleMessage, false);
+    keySession.addEventListener("<a href="#dom-eventready">ready</a>", handleReady, false);
+    keySession.addEventListener("<a href="#dom-eventerror">error</a>", handleError, false);
   }
 &lt;/script&gt;
 
--- a/encrypted-media/encrypted-media.xml	Thu Oct 31 11:00:32 2013 -0700
+++ b/encrypted-media/encrypted-media.xml	Thu Oct 31 14:17:16 2013 -0700
@@ -55,7 +55,7 @@
     <div class="head">
       <p><a href="http://www.w3.org/"><img src="https://www.w3.org/Icons/w3c_home" alt="W3C" width="72" height="48" /></a></p>
       <h1>Encrypted Media Extensions</h1>
-      <h2 id="draft-date">W3C Editor's Draft 30 October 2013</h2>
+      <h2 id="draft-date">W3C Editor's Draft 31 October 2013</h2>
       <dl>
         <dt>This Version:</dt>
         <dd><a href="http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html">http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html</a></dd>
@@ -1107,7 +1107,7 @@
     if (!keySession)
       throw "Could not create key session";
 
-    keySession.addEventListener("<precoderef prefix="event">message</precoderef>",handleMessage,false);
+    keySession.addEventListener("<precoderef prefix="event">message</precoderef>", handleMessage, false);
   }
 
   function handleMessage(event) {
@@ -1136,18 +1136,17 @@
 &lt;script&gt;
   function handleKeyNeeded(event) {
     var video = event.target;
-    var initData = event.<precoderef>initData</precoderef>;
 
     if (!video.<precoderef>keys</precoderef>)
       video.<premethodref>setMediaKeys</premethodref>(new <precoderef>MediaKeys</precoderef>("org.w3.clearkey"));
     if (!video.<precoderef>keys</precoderef>)
       throw "Could not create MediaKeys";
 
-    var keySession = video.<precoderef>keys</precoderef>.<premethodref>createSession</premethodref>(mimeType, initData);
+    var keySession = video.<precoderef>keys</precoderef>.<premethodref>createSession</premethodref>(event.<precoderef>type</precoderef>, event.<precoderef>initData</precoderef>);
     if (!keySession)
       throw "Could not create key session";
 
-    keySession.addEventListener("<precoderef prefix="event">message</precoderef>",handleMessage,false);
+    keySession.addEventListener("<precoderef prefix="event">message</precoderef>", handleMessage, false);
   }
 
   function handleMessage(event) {
@@ -1177,18 +1176,17 @@
 &lt;script&gt;
   function handleKeyNeeded(event) {
     var video = event.target;
-    var initData = event.<precoderef>initData</precoderef>;
 
     if (!video.<precoderef>keys</precoderef>)
       video.<premethodref>setMediaKeys</premethodref>(new <precoderef>MediaKeys</precoderef>("com.example.somesystem.1_0"));
     if (!video.<precoderef>keys</precoderef>)
       throw "Could not create MediaKeys";
 
-    var keySession = video.<precoderef>keys</precoderef>.<premethodref>createSession</premethodref>(mimeType, initData);
+    var keySession = video.<precoderef>keys</precoderef>.<premethodref>createSession</premethodref>(event.<precoderef>type</precoderef>, event.<precoderef>initData</precoderef>);
     if (!keySession)
       throw "Could not create key session";
 
-    keySession.addEventListener("<precoderef prefix="event">message</precoderef>",licenseRequestReady,false);
+    keySession.addEventListener("<precoderef prefix="event">message</precoderef>", licenseRequestReady, false);
   }
 
   function licenseRequestReady(event) {
@@ -1236,7 +1234,6 @@
 
   function handleKeyNeeded(event) {
     var video = event.target;
-    var initData = event.<precoderef>initData</precoderef>;
 
     if (!video.<precoderef>keys</precoderef>) {
       selectKeySystem();
@@ -1245,11 +1242,11 @@
     if (!video.<precoderef>keys</precoderef>)
       throw "Could not create MediaKeys";
 
-    var keySession = video.<precoderef>keys</precoderef>.<premethodref>createSession</premethodref>(mimeType, initData);
+    var keySession = video.<precoderef>keys</precoderef>.<premethodref>createSession</premethodref>(event.<precoderef>type</precoderef>, event.<precoderef>initData</precoderef>);
     if (!keySession)
       throw "Could not create key session";
 
-    keySession.addEventListener("<precoderef prefix="event">message</precoderef>",licenseRequestReady,false);
+    keySession.addEventListener("<precoderef prefix="event">message</precoderef>", licenseRequestReady, false);
   }
   
   function licenseRequestReady(event) {
@@ -1316,7 +1313,6 @@
 
   function handleKeyNeeded(event) {
     var video = event.target;
-    var initData = event.<precoderef>initData</precoderef>;
 
     if (!video.<precoderef>keys</precoderef>) {
       selectKeySystem();  // See previous example for implementation.
@@ -1325,13 +1321,13 @@
     if (!video.<precoderef>keys</precoderef>)
       throw "Could not create MediaKeys";
 
-    var keySession = video.<precoderef>keys</precoderef>.<premethodref>createSession</premethodref>(mimeType, initData);
+    var keySession = video.<precoderef>keys</precoderef>.<premethodref>createSession</premethodref>(event.<precoderef>type</precoderef>, event.<precoderef>initData</precoderef>);
     if (!keySession)
       throw "Could not create key session";
 
-    keySession.addEventListener("<precoderef prefix="event">message</precoderef>",handleMessage,false);
-    keySession.addEventListener("<precoderef prefix="event">ready</precoderef>",handleReady,false);
-    keySession.addEventListener("<precoderef prefix="event">error</precoderef>",handleError,false);
+    keySession.addEventListener("<precoderef prefix="event">message</precoderef>", handleMessage, false);
+    keySession.addEventListener("<precoderef prefix="event">ready</precoderef>", handleReady, false);
+    keySession.addEventListener("<precoderef prefix="event">error</precoderef>", handleError, false);
   }
 &lt;/script&gt;