mirror of https://github.com/jiahaog/Nativefier
Add null reference checks for new code looking for window.navigator.mediaDevices
This commit is contained in:
parent
79009e87cd
commit
a1cffcc6d2
|
@ -65,3 +65,4 @@ nativefier*.tgz
|
|||
.actrc
|
||||
|
||||
tsconfig.tsbuildinfo
|
||||
scripts
|
||||
|
|
|
@ -66,6 +66,9 @@ async function getDisplayMedia(
|
|||
sourceId: number | string,
|
||||
): Promise<MediaStream> {
|
||||
type OriginalVideoPropertyType = boolean | MediaTrackConstraints | undefined;
|
||||
if (!window?.navigator?.mediaDevices) {
|
||||
throw Error('window.navigator.mediaDevices is not present');
|
||||
}
|
||||
// Electron supports an outdated specification for mediaDevices,
|
||||
// see https://www.electronjs.org/docs/latest/api/desktop-capturer/
|
||||
const stream = await window.navigator.mediaDevices.getUserMedia({
|
||||
|
@ -262,6 +265,9 @@ function setupScreenSharePicker(
|
|||
|
||||
function setDisplayMediaPromise(): void {
|
||||
// Since no implementation for `getDisplayMedia` exists in Electron we write our own.
|
||||
if (!window?.navigator?.mediaDevices) {
|
||||
return;
|
||||
}
|
||||
window.navigator.mediaDevices.getDisplayMedia = (): Promise<MediaStream> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const sources = ipcRenderer.invoke(
|
||||
|
|
Loading…
Reference in New Issue