aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/mediakeysession/index.html
blob: 2896b7eb8bf1186dabb508519428b225f2d9d003 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
---
title: MediaKeySession
slug: Web/API/MediaKeySession
tags:
  - API
  - Audio
  - EncryptedMediaExtensions
  - Interface
  - Media
  - MediaKeySession
  - NeedsExample
  - NeedsTranslation
  - Reference
  - TopicStub
  - Video
translation_of: Web/API/MediaKeySession
---
<p>{{APIRef("EncryptedMediaExtensions")}}{{SeeCompatTable}}</p>

<p>The <code><strong>MediaKeySession</strong></code> interface of the <a href="/en-US/docs/Web/API/EncryptedMediaExtensions_API">EncryptedMediaExtensions API</a> represents a context for message exchange with a content decryption module (CDM).</p>

<h2 id="Properties">Properties</h2>

<dl>
 <dt>{{domxref("MediaKeySession.closed")}} {{readonlyInline}}</dt>
 <dd>Returns a {{jsxref("Promise")}} signaling when a <code>MediaKeySession</code> closes. This promise can only be fulfilled and is never rejected. Closing a session means that licenses and keys associated with it are no longer valid for decrypting media data. </dd>
 <dt>{{domxref("MediaKeySession.expiration")}} {{readonlyInline}}</dt>
 <dd>The time after which the keys in the current session can no longer be used to decrypt media data, or <code>NaN</code> if no such time exists. This value is determined by the CDM and measured in milliseconds since January 1, 1970, UTC. This value may change during a session lifetime, such as when an action triggers the start of a window.</dd>
 <dt>{{domxref("MediaKeySession.keyStatuses")}} {{readonlyInline}}</dt>
 <dd>Contains a reference to a read-only {{domxref("MediaKeyStatusMap")}} of the current session's keys and their statuses.</dd>
 <dt>{{domxref("MediaKeySession.sessionId")}} {{readonlyInline}}</dt>
 <dd>Contains a unique string generated by the CDM for the current media object and its associated keys or licenses.</dd>
</dl>

<h3 id="Event_handlers">Event handlers</h3>

<dl>
 <dt>{{domxref("MediaKeySession.onkeystatuseschange")}}</dt>
 <dd>Sets the {{domxref('EventHandler')}} called when there has been a change in the keys in a session or their statuses.</dd>
 <dt>{{domxref("MediaKeySession.onmessage")}}</dt>
 <dd>Sets the {{domxref('EventHandler')}} called when the content decryption module has generated a message for the session.</dd>
</dl>

<h2 id="Methods">Methods</h2>

<dl>
 <dt>{{domxref("MediaKeySession.close()")}}</dt>
 <dd>
 <p class="p1">Returns a {{jsxref("Promise")}} after notifying the current media session is no longer needed and that the CDM should release any resources associated with this object and close it.</p>
 </dd>
 <dt>{{domxref("MediaKeySession.generateRequest()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} after generating a media request based on initialization data.</dd>
 <dt>{{domxref("MediaKeySession.load()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} that resolves to a boolean value after loading data for a specified session object. </dd>
 <dt>{{domxref("MediaKeySession.remove()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} after removing any session data associated with the current object.</dd>
 <dt>{{domxref("MediaKeySession.update()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} after loading messages and licenses to the CDM.</dd>
</dl>

<h2 id="Examples">Examples</h2>

<pre class="brush: js">// TBD</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('EME', '#mediakeysession-interface', 'MediaKeySession')}}</td>
   <td>{{Spec2('EME')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Edge</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatChrome(42.0)}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>onkeystatuseschange</code> and <code>onmessage</code></td>
   <td>{{CompatChrome(55.0)}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatOpera(42)}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Android Webview</th>
   <th>Edge</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Firefox OS</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
   <th>Chrome for Android</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatChrome(43.0)}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatChrome(42.0)}}</td>
  </tr>
  <tr>
   <td><code>onkeystatuseschange</code> and <code>onmessage</code></td>
   <td>{{CompatNo}}</td>
   <td>{{CompatChrome(55.0)}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatOperaMobile(42)}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatChrome(55.0)}}</td>
  </tr>
 </tbody>
</table>
</div>