mirror of
https://github.com/pavlobu/deskreen.git
synced 2025-05-16 15:30:20 -07:00
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
export default async (
|
|
sourceID: string,
|
|
width: number | null | undefined = undefined,
|
|
height: number | null | undefined = undefined,
|
|
minSizeDivisor = 1,
|
|
maxSizeDivisor = 1,
|
|
minFrameRate = 15,
|
|
maxFrameRate = 60
|
|
) => {
|
|
if (width && height) {
|
|
return navigator.mediaDevices.getUserMedia({
|
|
audio: false,
|
|
video: {
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// @ts-ignore: fine here, mandatory does not exist, it's a problem with types
|
|
mandatory: {
|
|
chromeMediaSource: 'desktop',
|
|
chromeMediaSourceId: sourceID,
|
|
|
|
minWidth: width / minSizeDivisor,
|
|
maxWidth: width / maxSizeDivisor,
|
|
minHeight: height / minSizeDivisor,
|
|
maxHeight: height / maxSizeDivisor,
|
|
|
|
minFrameRate,
|
|
maxFrameRate,
|
|
},
|
|
},
|
|
});
|
|
}
|
|
|
|
return navigator.mediaDevices.getUserMedia({
|
|
audio: false,
|
|
video: {
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// @ts-ignore: fine here, mandatory does not exist, it's a problem with types
|
|
mandatory: {
|
|
chromeMediaSource: 'desktop',
|
|
chromeMediaSourceId: sourceID,
|
|
minFrameRate,
|
|
maxFrameRate,
|
|
},
|
|
},
|
|
});
|
|
};
|