加密媒體擴充 API

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2019.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

加密媒體擴充 API(Encrypted Media Extensions API)提供用以控制受數位版權管理(DRM)機制保護的影音內容播放的介面。

可以透過 Navigator.requestMediaKeySystemAccess() 存取此 API。

介面

MediaEncryptedEvent

表示當 HTMLMediaElement 偵測到初始化資料時觸發的特定 encrypted 事件。

MediaKeyMessageEvent

包含當內容解密模組(CDM)為會話產生訊息時的內容與相關資料。

MediaKeys

表示一組能讓關聯的 HTMLMediaElement 在播放時解密媒體資料的金鑰。

MediaKeySession

表示與內容解密模組(CDM)交換訊息的上下文。

MediaKeyStatusMap

提供金鑰 ID 與金鑰狀態之間的唯讀對應表。

MediaKeySystemAccess

提供可用於解密或內容保護的金鑰系統存取權限。

擴充其他介面

加密媒體擴充 API 會擴充以下 API,並加上這些功能。

HTMLMediaElement

HTMLMediaElement.mediaKeys Read only

提供一個 MediaKeys 物件,代表這個元素在播放時可以用來解密媒體資料的金鑰集合。

HTMLMediaElement.setMediaKeys()

設定 MediaKeys,讓這個元素在播放時能夠解密媒體內容。

encrypted 事件

當媒體內含的初始化資料被偵測到時,會在 HTMLMediaElement 上觸發這個事件,表示該媒體已加密。

回傳一個 Promise,兌現後會獲得 MediaKeySystemAccess 物件。這個物件可用來存取特定的媒體金鑰系統,接著就能建立金鑰來解密媒體串流。

規範

Specification
Encrypted Media Extensions
# navigator-extension-requestmediakeysystemaccess

瀏覽器相容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
requestMediaKeySystemAccess

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.