added constraints and fixed device not detected
This commit is contained in:
parent
a7249ec5a6
commit
865531868d
4 changed files with 28 additions and 22 deletions
|
@ -102,8 +102,8 @@ packages:
|
|||
ajv-keywords: 3.5.2(ajv@6.12.6)
|
||||
dev: true
|
||||
|
||||
/@electron/asar@3.2.5:
|
||||
resolution: {integrity: sha512-Ypahc2ElTj9YOrFvUHuoXv5Z/V1nPA5enlhmQapc578m/HZBHKTbqhoL5JZQjje2+/6Ti5AHh7Gj1/haeJa63Q==}
|
||||
/@electron/asar@3.2.6:
|
||||
resolution: {integrity: sha512-g3Qj43/4Fi8EOB7hwVF6TCwPfwWXTYqD6R16cuCWKD3khKIQJT0WOloF55+LzaP92rYovlE6XLlaESitrxSKmg==}
|
||||
engines: {node: '>=10.12.0'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
|
@ -159,7 +159,7 @@ packages:
|
|||
resolution: {integrity: sha512-lE/U3UNw1YHuowNbTmKNs9UlS3En3cPgwM5MI+agIgr/B1hSze9NdOP0qn7boZaI9Lph8IDv3/24g9IxnJP7aQ==}
|
||||
engines: {node: '>=8.6'}
|
||||
dependencies:
|
||||
'@electron/asar': 3.2.5
|
||||
'@electron/asar': 3.2.6
|
||||
'@malept/cross-spawn-promise': 1.1.1
|
||||
debug: 4.3.4
|
||||
dir-compare: 3.3.0
|
||||
|
@ -619,8 +619,8 @@ packages:
|
|||
resolution: {integrity: sha512-OxepLK9EuNEIPxWNME+C6WwbRAOOI2o2BaQEGzz5Lu2e4Z5eDnEo+/aVEDMIXywoJitJ7xWd641wrGLZdtwRyw==}
|
||||
dev: true
|
||||
|
||||
/@types/verror@1.10.6:
|
||||
resolution: {integrity: sha512-NNm+gdePAX1VGvPcGZCDKQZKYSiAWigKhKaz5KF94hG6f2s8de9Ow5+7AbXoeKxL8gavZfk4UquSAygOF2duEQ==}
|
||||
/@types/verror@1.10.7:
|
||||
resolution: {integrity: sha512-4c5F4T0qMSoXq1KHx7WV1FMuD2h0xdaFoJ7HSVWUfQ8w5YbqCwLOA8K7/yy1I+Txuzvm417dnPUaLmqazX1F7g==}
|
||||
requiresBuild: true
|
||||
dev: true
|
||||
optional: true
|
||||
|
@ -1530,7 +1530,7 @@ packages:
|
|||
requiresBuild: true
|
||||
dependencies:
|
||||
'@types/plist': 3.0.3
|
||||
'@types/verror': 1.10.6
|
||||
'@types/verror': 1.10.7
|
||||
ajv: 6.12.6
|
||||
crc: 3.8.0
|
||||
iconv-corefoundation: 1.1.7
|
||||
|
|
3
src/main/createVirtmic.ts
Normal file
3
src/main/createVirtmic.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
export function createVirtmic () {
|
||||
|
||||
};
|
|
@ -45,6 +45,7 @@ export function registerScreenShareHandler() {
|
|||
|
||||
if (isWayland) {
|
||||
const video = data[0];
|
||||
getAudioFromVirtmic();
|
||||
callback(video ? { video } : {});
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import { createVirtmic } from "./createVirtmic";
|
||||
export function getAudioFromVirtmic() {
|
||||
const getAudioDevice = async (deviceName) => {
|
||||
await navigator.mediaDevices.getUserMedia({
|
||||
audio: true
|
||||
});
|
||||
|
||||
const getAudioDevice = async (deviceName: string|undefined) => {
|
||||
await new Promise(r => setTimeout(r, 1000));
|
||||
let devices = await navigator.mediaDevices.enumerateDevices();
|
||||
let audioDevice = devices.find(({
|
||||
|
@ -14,7 +11,7 @@ export function getAudioFromVirtmic() {
|
|||
};
|
||||
|
||||
const getDisplayMedia = async () => {
|
||||
var id;
|
||||
var id: string|undefined;
|
||||
try {
|
||||
let myDiscordAudioSink = await getAudioDevice('virtmic');
|
||||
id = myDiscordAudioSink?.deviceId;
|
||||
|
@ -23,16 +20,21 @@ export function getAudioFromVirtmic() {
|
|||
id = 'default';
|
||||
}
|
||||
|
||||
let captureSystemAudioStream = await navigator.mediaDevices.getUserMedia({
|
||||
audio: {
|
||||
/*deviceId {
|
||||
exact: id
|
||||
},
|
||||
autoGainControl: false,
|
||||
echoCancellation: false,
|
||||
noiseSuppression: false
|
||||
channelCount: 2*/
|
||||
}
|
||||
const constraints = {
|
||||
deviceId: {
|
||||
exact: id
|
||||
},
|
||||
autoGainControl: false,
|
||||
echoCancellation: false,
|
||||
noiseSuppression: false,
|
||||
channelCount: 2
|
||||
};
|
||||
|
||||
await navigator.mediaDevices.getUserMedia({
|
||||
audio: true
|
||||
}).then((MediaStream) => {
|
||||
const audioTrack = MediaStream.getAudioTracks()[0];
|
||||
let captureSystemAudioStream = audioTrack.applyConstraints(constraints);
|
||||
});
|
||||
};
|
||||
};
|
Reference in a new issue