2017-03-29 23:30:04 +00:00
|
|
|
// Verifies that Electron cannot play a video that uses proprietary codecs
|
|
|
|
//
|
|
|
|
// This application should be run with the ffmpeg that does not include
|
|
|
|
// proprietary codecs to ensure Electron uses it instead of the version
|
|
|
|
// that does include proprietary codecs.
|
|
|
|
|
2017-03-29 23:23:30 +00:00
|
|
|
const {app, BrowserWindow, ipcMain} = require('electron')
|
|
|
|
const path = require('path')
|
|
|
|
|
|
|
|
const MEDIA_ERR_SRC_NOT_SUPPORTED = 4
|
2017-03-30 21:39:48 +00:00
|
|
|
const FIVE_MINUTES = 5 * 60 * 1000
|
2017-03-29 23:23:30 +00:00
|
|
|
|
|
|
|
let window
|
|
|
|
|
|
|
|
app.once('ready', () => {
|
|
|
|
window = new BrowserWindow({
|
|
|
|
show: false
|
|
|
|
})
|
|
|
|
|
2018-09-04 14:50:53 +00:00
|
|
|
window.loadFile(path.resolve(__dirname, 'asar', 'video.asar', 'index.html'))
|
2017-03-29 23:23:30 +00:00
|
|
|
|
2017-03-30 21:39:48 +00:00
|
|
|
ipcMain.on('asar-video', (event, message, error) => {
|
2017-03-29 23:23:30 +00:00
|
|
|
if (message === 'ended') {
|
|
|
|
console.log('Video played, proprietary codecs are included')
|
|
|
|
app.exit(1)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if (message === 'error' && error === MEDIA_ERR_SRC_NOT_SUPPORTED) {
|
|
|
|
app.exit(0)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-03-29 23:38:34 +00:00
|
|
|
console.log(`Unexpected response from page: ${message} ${error}`)
|
2017-03-29 23:23:30 +00:00
|
|
|
app.exit(1)
|
|
|
|
})
|
2017-03-30 21:39:48 +00:00
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
console.log('No IPC message after 5 minutes')
|
|
|
|
app.exit(1)
|
|
|
|
}, FIVE_MINUTES)
|
2017-03-29 23:23:30 +00:00
|
|
|
})
|