×

Electron 教程

Electron 教程简介Electron 快速入门Electron 桌面环境集成Electron 在线/离线事件探测Electron 进程支持的 Chrome 命令行开关Electron 环境变量Electron 支持的平台Electron 应用部署Mac App Store 应用提交向导Electron 应用打包Electron 使用原生模块Electron 主进程调试使用 Selenium 和 WebDriverElectron DevTools扩展使用 Pepper Flash 插件使用 Widevine CDM 插件Electron 术语表Electron 离屏渲染Electron 交互式解释器 (REPL)Electron 自动更新功能autoUpdater

Electron API

Electron DOM File对象Electron DOM <webview>Electron window.open 函数

在主进程内可用的模块

Electron app 模块Electron autoUpdater 模块Electron BrowserWindow 模块Electron contentTracing 模块Electron dialog 模块Electron global-shortcut 模块Electron ipcMain 模块Electron menu 模块Electron MenuItem 模块Electron powerMonitor 模块Electron powerSaveBlockerElectron protocol 模块Electron session 模块Electron webContents 模块Electron Tray 模块Electron Locales

在渲染进程(网页)可用模块

Electron desktopCapturer模块Electron ipcRenderer 模块Electron remote 模块Electron webFrame 模块

两种进程都可用的模块

Electron clipboard 模块Electron crashReporter 模块Electron nativeImage 模块Electron screen 模块Electron shell 模块

Electron 开发

Electron 编码规范Electron 源码目录结构Electron 和 NW.js技术上的差异Electron 构建系统概览Electron 构建步骤 (OS X)Electron 构建步骤 (Windows)Electron 构建步骤 (Linux)调试中使用 Symbol ServerElectron 常见问题Electron 版本管理electron window 提交指南自动化持续集成系统(CI)测试Electron 文档风格指南

Electron 使用 Widevine CDM 插件


在 Electron ,你可以使用 Widevine CDM 插件装载 Chrome 浏览器 .

获取插件

Electron 没有为 Widevine CDM 插件 配制许可 reasons, 为了获得它,首先需要安装官方的 chrome 浏览器,这匹配了体系架构和 Electron 构建使用的 chrome 版本 .

注意: Chrome 浏览器的主要版本必须和 Electron 使用的版本一样,否则插件不会有效,虽然 navigator.plugins 会显示你已经安装了它 .

Windows & OS X

在 Chrome 浏览器中打开 chrome://components/ ,找到 WidevineCdm 并且确定它更新到最新版本,然后你可以从 APP_DATA/Google/Chrome/WidevineCDM/VERSION/_platform_specific/PLATFORM_ARCH/ 路径找到所有的插件二进制文件 .

APP_DATA 是系统存放数据的地方,在 Windows 上它是%LOCALAPPDATA%, 在 OS X 上它是 ~/Library/Application Support. VERSION 是Widevine CDM 插件的版本字符串, 类似 1.4.8.866. PLATFORMmacwin. ARCHx86x64.

在 Windows,必要的二进制文件是 widevinecdm.dll andwidevinecdmadapter.dll, 在 OS X ,它们是 libwidevinecdm.dylibwidevinecdmadapter.plugin. 你可以将它们复制到任何你喜欢的地方,但是它们必须要放在一起.

Linux

在 Linux ,Chrome 浏览器将插件的二进制文件装载在一起 , 你可以在 /opt/google/chrome 下找到,文件名是 libwidevinecdm.solibwidevinecdmadapter.so.

使用插件

在获得了插件文件后,你可以使用 --widevine-cdm-path 命令行开关来将 widevinecdmadapter 的路径传递给 Electron , 插件版本使用 --widevine-cdm-version 开关.

注意: 虽然只有 widevinecdmadapter 的二进制文件传递给了 Electron, widevinecdm 二进制文件应当放在它的旁边.

必须在 app 模块的 ready 事件触发之前使用命令行开关,并且 page 使用的插件必须激活.

示例代码 :

// You have to pass the filename of `widevinecdmadapter` here, it is
// * `widevinecdmadapter.plugin` on OS X,
// * `libwidevinecdmadapter.so` on Linux,
// * `widevinecdmadapter.dll` on Windows.
app.commandLine.appendSwitch('widevine-cdm-path', '/path/to/widevinecdmadapter.plugin');
// The version of plugin can be got from `chrome://plugins` page in Chrome.
app.commandLine.appendSwitch('widevine-cdm-version', '1.4.8.866');

var mainWindow = null;
app.on('ready', function() {
  mainWindow = new BrowserWindow({
    webPreferences: {
      // The `plugins` have to be enabled.
      plugins: true
    }
  })
});

验证插件

为了验证插件是否工作,你可以使用下面的方法 :

  • 打开开发者工具查看是否 navigator.plugins 包含了 WidevineCDM 插件.
  • 打开 https://shaka-player-demo.appspot.com/ 加载一个使用Widevine 的 manifest.
  • 打开 http://www.dash-player.com/demo/drm-test-area/, 检查是否界面输出 bitdash uses Widevine in your browser, 然后播放 video.

分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)