blob: a9481870d4877ef6d79745e68d33222545b7e084 (
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
|
---
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>
{{Compat("api.MediaKeySession")}}
|