as

Settings
Sign out
Notifications
Alexa
亚马逊应用商店
Ring
AWS
文档
Support
Contact Us
My Cases
新手入门
设计和开发
应用发布
参考
支持
跳转到主要内容
此项代表媒体密钥会话。 有关更多信息,请参阅https://www.w3.org/TR/encrypted-media/#mediakeysession-interface。

扩展

属性

sessionId

readonly sessionId: string 此对象的会话ID以及相关的密钥或许可证。 有关更多信息,请参阅https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-sessionid。

expiration

readonly expiration: number 会话中所有密钥的到期时间,或者如果不存在此类时间或许可证明确声明永不过期,则为NaN,由CDM确定。 有关更多信息,请参阅https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-expiration。

closed

readonly closed: Promise<void> | null 当对象因运行会话关闭算法而关闭时发出信号。 有关更多信息,请参阅https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-closed。

keyStatuses

readonly keyStatuses: MediaKeyStatusMap | null 对于会话已知的密钥ID到关联密钥当前状态的只读映射的引用。每个条目都有唯一的密钥ID。 有关更多信息,请参阅https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-keystatuses。

onkeystatuseschange

onkeystatuseschange: ((this: MediaKeySession, ev: Event) => any) | null “keystatuseschange”事件的事件处理程序。 有关更多信息,请参阅https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-onkeystatuseschange。

onmessage

onmessage: ((this: MediaKeySession, ev: MediaKeyMessageEvent) => any) | null “message”事件的事件处理程序。 有关更多信息,请参阅https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-onmessage。

方法

generateRequest()

generateRequest(initDataType: string, initData: ArrayBuffer): Promise<void> 根据initData生成许可证请求。如果算法成功且promise得到解析,则类型为“license-request”或“individualization-request”的消息将始终排在队列中。 有关更多信息,请参阅https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-generaterequest。

参数

initDataType
string initData的初始化数据类型。
initData
ArrayBuffer 初始化数据。

返回值

Promise<void>

load()

load(sessionId: string): Promise<boolean> | null 将为指定会话存储的数据加载到此对象中。 有关更多信息,请参阅https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-load。

参数

sessionId
string 要加载的会话的会话ID。

返回值

Promise<boolean> | null

update()

update(response: ArrayBuffer): Promise<void> 向CDM提供消息,包括许可证。 有关更多信息,请参阅https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-update。

参数

response
ArrayBuffer 将向CDM提供的消息。当方法成功执行时将履行的Promise。内容专门针对密钥系统。它不得包含可执行代码。

返回值

Promise<void>

close()

close(): Promise<void> | null 表示应用程序不再需要会话,CDM应释放与该会话相关的所有资源并将其关闭。保留的数据不会被释放或清除。 有关更多信息,请参阅https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-close。

返回值

Promise<void> | null

remove()

remove(): Promise<void> | null 移除与会话关联的所有许可证和密钥。对于持久会话类型,update() 处理了发布消息确认之后,将按照针对每种会话类型的定义清除其他会话数据。 有关更多信息,请参阅https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-remove。

返回值

Promise<void> | null

addEventListener()

addEventListener(type: K, listener: (this: MediaKeySession, ev: MediaKeySessionEventMap[K]) => any | EventListener, options?: boolean | AddEventListenerOptions | undefined): void 添加事件侦听器。

参数

type
K 事件的类型。
listener
(this: MediaKeySession, ev: MediaKeySessionEventMap[K]) => any | EventListener 事件处理程序。
options?
boolean | AddEventListenerOptions | undefined 已忽略。

addEventListener()

addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions | undefined): void 添加事件侦听器。

参数

type
string 事件的类型。
listener
EventListener 事件处理程序。
options?
boolean | AddEventListenerOptions | undefined 已忽略。
最后修改于 2026年10月26日