[mirotalksfu] - improve getMicrophoneVolumeIndicator
هذا الالتزام موجود في:
@@ -401,6 +401,7 @@ function addChild(device, els) {
|
||||
// ####################################################
|
||||
|
||||
function getMicrophoneVolumeIndicator(stream) {
|
||||
if (isAudioContextSupported() && hasAudioTrack(stream)) {
|
||||
stopMicrophoneProcessing();
|
||||
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||
const microphone = audioContext.createMediaStreamSource(stream);
|
||||
@@ -417,6 +418,7 @@ function getMicrophoneVolumeIndicator(stream) {
|
||||
};
|
||||
microphone.connect(scriptProcessor);
|
||||
scriptProcessor.connect(audioContext.destination);
|
||||
}
|
||||
}
|
||||
|
||||
function stopMicrophoneProcessing() {
|
||||
@@ -436,6 +438,20 @@ function updateVolumeIndicator(volume) {
|
||||
});
|
||||
}
|
||||
|
||||
function isAudioContextSupported() {
|
||||
return !!(window.AudioContext || window.webkitAudioContext);
|
||||
}
|
||||
|
||||
function hasAudioTrack(mediaStream) {
|
||||
const audioTracks = mediaStream.getAudioTracks();
|
||||
return audioTracks.length > 0;
|
||||
}
|
||||
|
||||
function hasVideoTrack(mediaStream) {
|
||||
const videoTracks = mediaStream.getVideoTracks();
|
||||
return videoTracks.length > 0;
|
||||
}
|
||||
|
||||
// ####################################################
|
||||
// API CHECK
|
||||
// ####################################################
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم