|
@@ -9,6 +9,8 @@ export interface InitConfigType extends DisplayMediaStreamConstraints {
|
|
|
uploadUrl: '';
|
|
|
resolution: ResolutionType;
|
|
|
autoDownload?: boolean;
|
|
|
+ isElectron: boolean;
|
|
|
+ chromeMediaSourceId: null;
|
|
|
debug?: boolean;
|
|
|
}
|
|
|
export enum RecorderStatusType {
|
|
@@ -17,6 +19,7 @@ export enum RecorderStatusType {
|
|
|
hold = 2,
|
|
|
end = 3,
|
|
|
}
|
|
|
+
|
|
|
export class BasicSimaqRecorder extends EventEmitter {
|
|
|
displayMediaStreamConstraints: DisplayMediaStreamConstraints = {
|
|
|
video: videoConstraints.getValue(),
|
|
@@ -31,11 +34,14 @@ export class BasicSimaqRecorder extends EventEmitter {
|
|
|
private recordChunks: Blob[] = [];
|
|
|
private autoDownload = false;
|
|
|
private passiveEnd = false;
|
|
|
-
|
|
|
+ private isElectron: boolean;
|
|
|
+ private chromeMediaSourceId: boolean;
|
|
|
constructor(arg: InitConfigType) {
|
|
|
super();
|
|
|
console.log('arg', arg);
|
|
|
this.autoDownload = arg.autoDownload;
|
|
|
+ this.isElectron = arg.isElectron;
|
|
|
+ this.chromeMediaSourceId = arg.chromeMediaSourceId;
|
|
|
videoConstraints.subscribe((value) => {
|
|
|
console.log('subscribe', value);
|
|
|
});
|
|
@@ -50,7 +56,9 @@ export class BasicSimaqRecorder extends EventEmitter {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- const media = await this.getDisplayMedia();
|
|
|
+ const media = this.isElectron
|
|
|
+ ? await this.getEletronDisplayMedia()
|
|
|
+ : await this.getDisplayMedia();
|
|
|
console.log('media', media);
|
|
|
if (media) {
|
|
|
this.emit('startRecord');
|
|
@@ -77,6 +85,36 @@ export class BasicSimaqRecorder extends EventEmitter {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ private getEletronDisplayMedia(): Promise<MediaStream | null> {
|
|
|
+ return new Promise(async (resolve) => {
|
|
|
+ try {
|
|
|
+ const audioInput = await this.getDeaultAudio();
|
|
|
+ if (audioInput) {
|
|
|
+ this.audioInput = audioInput;
|
|
|
+ }
|
|
|
+ console.log('audioInput', audioInput);
|
|
|
+ if (navigator.mediaDevices.getDisplayMedia) {
|
|
|
+ const res = await navigator.mediaDevices.getUserMedia({
|
|
|
+ audio: false,
|
|
|
+ video: {
|
|
|
+ mandatory: {
|
|
|
+ chromeMediaSource: 'desktop',
|
|
|
+ chromeMediaSourceId: this.chromeMediaSourceId,
|
|
|
+ minWidth: 1280,
|
|
|
+ maxWidth: 1280,
|
|
|
+ minHeight: 720,
|
|
|
+ maxHeight: 720,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ } as any as MediaStreamConstraints);
|
|
|
+ return resolve(res);
|
|
|
+ }
|
|
|
+ return resolve(null);
|
|
|
+ } catch (error) {
|
|
|
+ return resolve(null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
private getDisplayMedia(): Promise<MediaStream | null> {
|
|
|
return new Promise(async (resolve) => {
|
|
@@ -200,5 +238,5 @@ export class BasicSimaqRecorder extends EventEmitter {
|
|
|
window.URL.revokeObjectURL(url);
|
|
|
}
|
|
|
|
|
|
- private uploadToServer(): void { }
|
|
|
+ private uploadToServer(): void {}
|
|
|
}
|