[mirotalksfu] - fix volume level
هذا الالتزام موجود في:
@@ -123,6 +123,8 @@ let isRoomLocked = false;
|
|||||||
|
|
||||||
let initStream = null;
|
let initStream = null;
|
||||||
|
|
||||||
|
let scriptProcessor = null;
|
||||||
|
|
||||||
// ####################################################
|
// ####################################################
|
||||||
// INIT ROOM
|
// INIT ROOM
|
||||||
// ####################################################
|
// ####################################################
|
||||||
@@ -384,9 +386,10 @@ function addChild(device, els) {
|
|||||||
// ####################################################
|
// ####################################################
|
||||||
|
|
||||||
function getMicrophoneVolumeIndicator(stream) {
|
function getMicrophoneVolumeIndicator(stream) {
|
||||||
|
stopMicrophoneProcessing();
|
||||||
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||||
const microphone = audioContext.createMediaStreamSource(stream);
|
const microphone = audioContext.createMediaStreamSource(stream);
|
||||||
const scriptProcessor = audioContext.createScriptProcessor(1024, 1, 1);
|
scriptProcessor = audioContext.createScriptProcessor(1024, 1, 1);
|
||||||
scriptProcessor.onaudioprocess = function (event) {
|
scriptProcessor.onaudioprocess = function (event) {
|
||||||
const inputBuffer = event.inputBuffer.getChannelData(0);
|
const inputBuffer = event.inputBuffer.getChannelData(0);
|
||||||
let sum = 0;
|
let sum = 0;
|
||||||
@@ -401,6 +404,14 @@ function getMicrophoneVolumeIndicator(stream) {
|
|||||||
scriptProcessor.connect(audioContext.destination);
|
scriptProcessor.connect(audioContext.destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stopMicrophoneProcessing() {
|
||||||
|
if (scriptProcessor) {
|
||||||
|
scriptProcessor.disconnect();
|
||||||
|
scriptProcessor = null;
|
||||||
|
}
|
||||||
|
volumeLevel.style.width = '0%';
|
||||||
|
}
|
||||||
|
|
||||||
function updateVolumeIndicator(volume) {
|
function updateVolumeIndicator(volume) {
|
||||||
const MIN_VOLUME = 0;
|
const MIN_VOLUME = 0;
|
||||||
const MAX_VOLUME = 100;
|
const MAX_VOLUME = 100;
|
||||||
@@ -1607,6 +1618,7 @@ function handleRoomClientEvents() {
|
|||||||
hide(stopAudioButton);
|
hide(stopAudioButton);
|
||||||
show(startAudioButton);
|
show(startAudioButton);
|
||||||
setAudioButtonsDisabled(false);
|
setAudioButtonsDisabled(false);
|
||||||
|
stopMicrophoneProcessing();
|
||||||
});
|
});
|
||||||
rc.on(RoomClient.EVENTS.startVideo, () => {
|
rc.on(RoomClient.EVENTS.startVideo, () => {
|
||||||
console.log('Room Client start video');
|
console.log('Room Client start video');
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم