Testing Widevine CDM
In Electron you can use the Widevine CDM library shipped with Chrome browser.在Electron中,您可以使用Chrome浏览器附带的Widevine CDM库。
Widevine Content Decryption Modules (CDMs) are how streaming services protect content using HTML5 video to web browsers without relying on an NPAPI plugin like Flash or Silverlight. Widevine内容解密模块(CDM)是流媒体服务如何在不依赖Flash或Silverlight等NPAPI插件的情况下,使用HTML5视频向web浏览器保护内容。Widevine support is an alternative solution for streaming services that currently rely on Silverlight for playback of DRM-protected video content. Widevine支持是当前依赖Silverlight播放受DRM保护的视频内容的流媒体服务的替代解决方案。It will allow websites to show DRM-protected video content in Firefox without the use of NPAPI plugins. 它将允许网站在Firefox中显示受DRM保护的视频内容,而无需使用NPAPI插件。The Widevine CDM runs in an open-source CDM sandbox providing better user security than NPAPI plugins.Widevine CDM在开源CDM沙盒中运行,提供比NPAPI插件更好的用户安全性。
Note on VMP
As of Electron v1.8.0 (Chrome v59), the below steps are may only be some of the necessary steps to enable Widevine; any app on or after that version intending to use the Widevine CDM may need to be signed using a license obtained from Widevine itself.从Electron v1.8.0 (Chrome v59)开始,以下步骤可能只是启用Widevine的一些必要步骤;在该版本上或之后,打算使用Widevine CDM的任何应用程序可能需要使用从Widevine自身获得的许可证进行签名。
Per Widevine:
Chrome 59 (and later) includes support for Verified Media Path (VMP).Chrome 59(及更高版本)包括对验证媒体路径(VMP)的支持。VMP provides a method to verify the authenticity of a device platform.VMP提供了一种验证设备平台真实性的方法。For browser deployments, this will provide an additional signal to determine if a browser-based implementation is reliable and secure.对于浏览器部署,这将提供一个额外的信号,以确定基于浏览器的实现是否可靠和安全。
The proxy integration guide has been updated with information about VMP and how to issue licenses.代理集成指南已更新了有关VMP和如何颁发许可证的信息。
Widevine recommends our browser-based integrations (vendors and browser-based applications) add support for VMP.Widevine建议我们基于浏览器的集成(供应商和基于浏览器的应用程序)添加对VMP的支持。
To enable video playback with this new restriction, castLabs has created a fork that has implemented the necessary changes to enable Widevine to be played in an Electron application if one has obtained the necessary licenses from widevine.为了在这种新的限制下实现视频播放,castLabs创建了一个fork,该fork已经实现了必要的更改,以使Widevine能够在Electron应用程序中播放,前提是从Widevine获得了必要的许可证。
Getting the library
Open 打开chrome://components/
in Chrome browser, find Widevine Content Decryption Module
and make sure it is up to date, then you can find the library files from the application directory.chrome://components/
在Chrome浏览器中,找到Widevine内容解密模块并确保它是最新的,然后您可以从应用程序目录中找到库文件。
On Windows
The library file 库文件widevinecdm.dll
will be under Program Files(x86)/Google/Chrome/Application/CHROME_VERSION/WidevineCdm/_platform_specific/win_(x86|x64)/
directory.widevinecdm.dll
将位于Program Files(x86)/Google/Chrome/Application/CHROME_VERSION/WidevineCdm/_platform_specific/win_(x86|x64)/
目录下。
On macOS
The library file 库文件libwidevinecdm.dylib
will be under /Applications/Google Chrome.app/Contents/Versions/CHROME_VERSION/Google Chrome Framework.framework/Versions/A/Libraries/WidevineCdm/_platform_specific/mac_(x86|x64)/
directory.libwidevinecdm.dylib
将位于/Applications/Google Chrome.app/Contents/Versions/CHROME_VERSION/Google Chrome Framework.framework/Versions/A/Libraries/WidevineCdm/_platform_specific/mac_(x86|x64)/
目录下。
Note: Make sure that chrome version used by Electron is greater than or equal to the 确保Electron使用的chrome版本大于或等于chrome的widevine cdm组件的min_chrome_version
value of Chrome's widevine cdm component. min_crome_version
值。The value can be found in 该值可以在manifest.json
under WidevineCdm
directory.WidevineCdm
目录下的manifest.json
中找到。
Using the library使用库
After getting the library files, you should pass the path to the file with 获取库文件后,应使用--widevine-cdm-path
command line switch, and the library's version with --widevine-cdm-version
switch. --widevine-cdm-path
路径命令行开关传递文件路径,并使用--widevine-cdm-version
开关传递库版本。The command line switches have to be passed before the 在ready
event of app
module gets emitted.app
模块的ready
事件发出之前,必须传递命令行开关。
Example code:
const { app, BrowserWindow } = require('electron')
// You have to pass the directory that contains widevine library here, it is
// * `libwidevinecdm.dylib` on macOS,
// * `widevinecdm.dll` on Windows.
app.commandLine.appendSwitch('widevine-cdm-path', '/path/to/widevine_library')
// The version of plugin can be got from `chrome://components` page in Chrome.
app.commandLine.appendSwitch('widevine-cdm-version', '1.4.8.866')
let win = null
app.whenReady().then(() => {
win = new BrowserWindow()
win.show()
})
Verifying Widevine CDM support
To verify whether widevine works, you can use following ways:要验证widevine是否有效,可以使用以下方法:
Open https://shaka-player-demo.appspot.com/ and load a manifest that uses打开https://shaka-player-demo.appspot.com/并加载使用Widevine
.Widevine
的清单。Open http://www.dash-player.com/demo/drm-test-area/, check whether the page says打开http://www.dash-player.com/demo/drm-test-area/,检查页面是否显示bitdash在浏览器中使用Widevine,然后播放视频。bitdash uses Widevine in your browser
, then play the video.