[mirotalksfu] - improve getMicrophoneVolumeIndicator
هذا الالتزام موجود في:
@@ -401,6 +401,7 @@ function addChild(device, els) {
|
|||||||
// ####################################################
|
// ####################################################
|
||||||
|
|
||||||
function getMicrophoneVolumeIndicator(stream) {
|
function getMicrophoneVolumeIndicator(stream) {
|
||||||
|
if (isAudioContextSupported() && hasAudioTrack(stream)) {
|
||||||
stopMicrophoneProcessing();
|
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);
|
||||||
@@ -417,6 +418,7 @@ function getMicrophoneVolumeIndicator(stream) {
|
|||||||
};
|
};
|
||||||
microphone.connect(scriptProcessor);
|
microphone.connect(scriptProcessor);
|
||||||
scriptProcessor.connect(audioContext.destination);
|
scriptProcessor.connect(audioContext.destination);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopMicrophoneProcessing() {
|
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
|
// API CHECK
|
||||||
// ####################################################
|
// ####################################################
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم