How to play Netflix videos on simple electron based browser?

Viewed 347

I tried to play Netflix videos on a simple electron browser. The browser I used is present as a simple quick start for electron at https://github.com/electron/electron-quick-start.
I just loaded URL https://www.netflix.com instead of index.html in this.

But netflix failed with error code: M7701-1003

I have already tried the steps listed at https://www.electronjs.org/docs/latest/tutorial/testing-widevine-cdm and they did not work.
Can someone tell what more needs to be done in this?

Update: I followed the steps mentioned in the "Verifying Widevine CDM support Section" of documentation, for the first link it says "Your browser lacks features to play this video" and the second link does not exist.

1 Answers

Widevine is a pain. I used the Castlabs Electron fork for ECS located here.

  • Most services will NOT work when you play actual content if you just run the code
  • You must build a package signed by Widevine for it to work properly

I used the Castlabs EVS for this located here.

  • You must add a call in the build process to EVS via the electron-builder afterPack or afterSign hook
  • You must sign prior to code signing on Mac and after code signing on Windows

Something like this for mac (named afterPack.js and referenced in afterPack in your package.json build key):

exports.default = function (context) {
  // Skip if not mac
  if (process.platform !== 'darwin') return

  // VMP sign via EVS
  const { execSync } = require('child_process')
  console.log('VMP signing start')
  execSync('python3 -m castlabs_evs.vmp sign-pkg ./dist/mac ' + context.appOutDir)
  console.log('VMP signing complete')
}

NOTE: You must sign up for an EVS account (free) and you will need to have Python to use it.

In your main.js instantiate your window when Widevine is ready (read guide for the appropriate setup):

// Widevine DRM setup
app.commandLine.appendSwitch('no-verify-widevine-cdm')
const isOffline = false
const widevineDir = app.getPath('userData')

// Widevine DRM ready
app.on('widevine-ready', () => {
  createWindow()
})

On the browser support part of this, be sure to set a valid user agent e.g. (mac):

[BrowserWindow or BrowserView].webContents.loadURL('https://urltostream', { userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36' })

I have a working app located here.

Related