LH-265-enable-audio-in-mediasoup #16

Closed
sergiu wants to merge 120 commits from LH-265-enable-audio-in-mediasoup into master
2 changed files with 92 additions and 70 deletions
Showing only changes of commit a21451e46d - Show all commits

View File

@ -20513,47 +20513,58 @@ const streamSuccess = (stream) => {
const getLocalStream = () => { const getLocalStream = () => {
console.log('[getLocalStream]'); console.log('[getLocalStream]');
try { navigator.permissions.query(
navigator.permissions.query( { name: 'microphone' }
{ name: 'microphone' } ).then(function(permissionStatus) {
).then(function(permissionStatus) {
console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt
console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt
// If he has entered before, the saved access is already saved
// If he has entered before, the saved access is already saved if (permissionStatus === 'grated') {
if (permissionStatus === 'grated') { doIHaveAudio = true;
}
// If it is the first time client enter and give permission
permissionStatus.onchange = function() {
console.log('🟨 [PERMISSION] onchange', this.state);
if (this.state === 'granted') {
doIHaveAudio = true; doIHaveAudio = true;
} }
navigator.mediaDevices.getUserMedia({
// If it is the first time client enter and give permission audio: true,
permissionStatus.onchange = function() { video: {
console.log('🟨 [PERMISSION] onchange', this.state); qvga : { width: { ideal: 320 }, height: { ideal: 240 } },
if (this.state === 'granted') { vga : { width: { ideal: 640 }, height: { ideal: 480 } },
doIHaveAudio = true; hd : { width: { ideal: 1280 }, height: { ideal: 720 } }
} }
} })
.then((streamSuccess) => {
})
} catch (error) { return streamSuccess
console.log('eeeeee', error); })
} .catch(error => {
console.log(error.message)
})
}
})
navigator.mediaDevices.getUserMedia({ // navigator.mediaDevices.getUserMedia({
audio: true, // audio: true,
video: { // video: {
qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, // qvga : { width: { ideal: 320 }, height: { ideal: 240 } },
vga : { width: { ideal: 640 }, height: { ideal: 480 } }, // vga : { width: { ideal: 640 }, height: { ideal: 480 } },
hd : { width: { ideal: 1280 }, height: { ideal: 720 } } // hd : { width: { ideal: 1280 }, height: { ideal: 720 } }
} // }
}) // })
.then((streamSuccess) => { // .then((streamSuccess) => {
return streamSuccess // return streamSuccess
}) // })
.catch(error => { // .catch(error => {
console.log(error.message) // console.log(error.message)
}) // })
} }
const goConnect = () => { const goConnect = () => {

View File

@ -155,47 +155,58 @@ const streamSuccess = (stream) => {
const getLocalStream = () => { const getLocalStream = () => {
console.log('[getLocalStream]'); console.log('[getLocalStream]');
try { navigator.permissions.query(
navigator.permissions.query( { name: 'microphone' }
{ name: 'microphone' } ).then(function(permissionStatus) {
).then(function(permissionStatus) {
console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt
console.log('🟨 [PERMISSION] onchange', permissionStatus.state); // granted, denied, prompt
// If he has entered before, the saved access is already saved
// If he has entered before, the saved access is already saved if (permissionStatus === 'grated') {
if (permissionStatus === 'grated') { doIHaveAudio = true;
}
// If it is the first time client enter and give permission
permissionStatus.onchange = function() {
console.log('🟨 [PERMISSION] onchange', this.state);
if (this.state === 'granted') {
doIHaveAudio = true; doIHaveAudio = true;
} }
navigator.mediaDevices.getUserMedia({
// If it is the first time client enter and give permission audio: true,
permissionStatus.onchange = function() { video: {
console.log('🟨 [PERMISSION] onchange', this.state); qvga : { width: { ideal: 320 }, height: { ideal: 240 } },
if (this.state === 'granted') { vga : { width: { ideal: 640 }, height: { ideal: 480 } },
doIHaveAudio = true; hd : { width: { ideal: 1280 }, height: { ideal: 720 } }
} }
} })
.then((streamSuccess) => {
})
} catch (error) { return streamSuccess
console.log('eeeeee', error); })
} .catch(error => {
console.log(error.message)
})
}
})
navigator.mediaDevices.getUserMedia({ // navigator.mediaDevices.getUserMedia({
audio: true, // audio: true,
video: { // video: {
qvga : { width: { ideal: 320 }, height: { ideal: 240 } }, // qvga : { width: { ideal: 320 }, height: { ideal: 240 } },
vga : { width: { ideal: 640 }, height: { ideal: 480 } }, // vga : { width: { ideal: 640 }, height: { ideal: 480 } },
hd : { width: { ideal: 1280 }, height: { ideal: 720 } } // hd : { width: { ideal: 1280 }, height: { ideal: 720 } }
} // }
}) // })
.then((streamSuccess) => { // .then((streamSuccess) => {
return streamSuccess // return streamSuccess
}) // })
.catch(error => { // .catch(error => {
console.log(error.message) // console.log(error.message)
}) // })
} }
const goConnect = () => { const goConnect = () => {