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.
|
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
const { app, BrowserWindow, ipcMain } = require('electron');
|
2023-06-15 14:42:27 +00:00
|
|
|
const path = require('node:path');
|
2017-03-29 23:23:30 +00:00
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
const MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
|
|
|
|
const FIVE_MINUTES = 5 * 60 * 1000;
|
2017-03-29 23:23:30 +00:00
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
let window;
|
2017-03-29 23:23:30 +00:00
|
|
|
|
2020-02-03 22:43:22 +00:00
|
|
|
app.whenReady().then(() => {
|
2017-03-29 23:23:30 +00:00
|
|
|
window = new BrowserWindow({
|
2019-01-07 19:19:27 +00:00
|
|
|
show: false,
|
|
|
|
webPreferences: {
|
2021-03-01 21:52:29 +00:00
|
|
|
nodeIntegration: true,
|
|
|
|
contextIsolation: false
|
2019-01-07 19:19:27 +00:00
|
|
|
}
|
2020-03-20 20:28:31 +00:00
|
|
|
});
|
2017-03-29 23:23:30 +00:00
|
|
|
|
2023-02-16 09:25:41 +00:00
|
|
|
window.webContents.on('render-process-gone', (event, details) => {
|
|
|
|
console.log(`WebContents crashed ${JSON.stringify(details)}`);
|
2020-03-20 20:28:31 +00:00
|
|
|
app.exit(1);
|
|
|
|
});
|
2018-09-20 21:15:33 +00:00
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
window.loadFile(path.resolve(__dirname, 'test.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') {
|
2020-03-20 20:28:31 +00:00
|
|
|
console.log('Video played, proprietary codecs are included');
|
|
|
|
app.exit(1);
|
|
|
|
return;
|
2017-03-29 23:23:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (message === 'error' && error === MEDIA_ERR_SRC_NOT_SUPPORTED) {
|
2020-03-20 20:28:31 +00:00
|
|
|
app.exit(0);
|
|
|
|
return;
|
2017-03-29 23:23:30 +00:00
|
|
|
}
|
|
|
|
|
2020-03-20 20:28:31 +00:00
|
|
|
console.log(`Unexpected response from page: ${message} ${error}`);
|
|
|
|
app.exit(1);
|
|
|
|
});
|
2017-03-30 21:39:48 +00:00
|
|
|
|
|
|
|
setTimeout(() => {
|
2020-03-20 20:28:31 +00:00
|
|
|
console.log('No IPC message after 5 minutes');
|
|
|
|
app.exit(1);
|
|
|
|
}, FIVE_MINUTES);
|
|
|
|
});
|