|
@@ -11,6 +11,7 @@ export interface InitConfigType extends DisplayMediaStreamConstraints {
|
|
|
autoDownload?: boolean;
|
|
|
isElectron?: boolean;
|
|
|
chromeMediaSourceId?: null;
|
|
|
+ chromeAudioSourceId?: null;
|
|
|
debug?: boolean;
|
|
|
}
|
|
|
export enum RecorderStatusType {
|
|
@@ -35,13 +36,15 @@ export class BasicSimaqRecorder extends EventEmitter {
|
|
|
private autoDownload = false;
|
|
|
private passiveEnd = false;
|
|
|
private isElectron: boolean;
|
|
|
- private chromeMediaSourceId: boolean;
|
|
|
+ private chromeMediaSourceId: string | null;
|
|
|
+ private chromeAudioSourceId: string | null;
|
|
|
constructor(arg: InitConfigType) {
|
|
|
super();
|
|
|
console.log('arg', arg);
|
|
|
this.autoDownload = arg.autoDownload;
|
|
|
this.isElectron = arg.isElectron;
|
|
|
this.chromeMediaSourceId = arg.chromeMediaSourceId;
|
|
|
+ this.chromeAudioSourceId = arg.chromeAudioSourceId;
|
|
|
videoConstraints.subscribe((value) => {
|
|
|
console.log('subscribe', value);
|
|
|
});
|
|
@@ -88,11 +91,11 @@ export class BasicSimaqRecorder extends EventEmitter {
|
|
|
private getEletronDisplayMedia(): Promise<MediaStream | null> {
|
|
|
return new Promise(async (resolve) => {
|
|
|
try {
|
|
|
- const audioInput = await this.getDeaultAudio();
|
|
|
+ const audioInput = await this.getEletronDeaultAudio();
|
|
|
if (audioInput) {
|
|
|
this.audioInput = audioInput;
|
|
|
}
|
|
|
- console.log('audioInput', audioInput);
|
|
|
+ console.log('eletron-audioInput', audioInput);
|
|
|
if (navigator.mediaDevices.getDisplayMedia) {
|
|
|
const res = await navigator.mediaDevices.getUserMedia({
|
|
|
audio: false,
|
|
@@ -153,7 +156,27 @@ export class BasicSimaqRecorder extends EventEmitter {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+ private async getEletronDeaultAudio(): Promise<MediaStream> {
|
|
|
+ return new Promise(async (resolve) => {
|
|
|
+ try {
|
|
|
+ if (navigator.mediaDevices.getUserMedia) {
|
|
|
+ const res = await navigator.mediaDevices.getUserMedia({
|
|
|
+ video: false,
|
|
|
+ audio: {
|
|
|
+ mandatory: {
|
|
|
+ chromeMediaSource: 'desktop',
|
|
|
+ chromeMediaSourceId: this.chromeMediaSourceId,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ } as any as MediaStreamConstraints);
|
|
|
+ return resolve(res);
|
|
|
+ }
|
|
|
+ return resolve(null);
|
|
|
+ } catch (error) {
|
|
|
+ return resolve(null);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
public holdRecord(): void {
|
|
|
this.isStartRecoding = false;
|
|
|
this.status = RecorderStatusType.hold;
|
|
@@ -238,5 +261,5 @@ export class BasicSimaqRecorder extends EventEmitter {
|
|
|
window.URL.revokeObjectURL(url);
|
|
|
}
|
|
|
|
|
|
- private uploadToServer(): void {}
|
|
|
+ private uploadToServer(): void { }
|
|
|
}
|