Actions
Bug #9022
closedAdd meter mic on phone
Start date:
05/14/2022
Due date:
% Done:
0%
Estimated time:
Description
Add meter on phone
in agent.php add this code at Line 1788:
<div class="sidebar-toggle-labels" style="font-weight: bold; text-transform: uppercase;"><label for="muteMicrophone"><?=$lh->translationFor('microphone')?></label></div>
<!-- mio codice barre this mdy code -->
<script>
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia;
if (navigator.getUserMedia) {
navigator.getUserMedia({
audio: true
},
function(stream) {
audioContext = new AudioContext();
analyser = audioContext.createAnalyser();
microphone = audioContext.createMediaStreamSource(stream);
javascriptNode = audioContext.createScriptProcessor(2048, 1, 1);
analyser.smoothingTimeConstant = 0.3;
analyser.fftSize = 1024;
microphone.connect(analyser);
analyser.connect(javascriptNode);
javascriptNode.connect(audioContext.destination);
canvasContext = $("#canvas")[0].getContext("2d");
javascriptNode.onaudioprocess = function() {
var array = new Uint8Array(analyser.frequencyBinCount);
analyser.getByteFrequencyData(array);
var values = 0;
var length = array.length;
for (var i = 0; i < length; i++) {
values += (array[i]);
}
var average = values / length;
// console.log(Math.round(average - 40));
canvasContext.clearRect(0, 0, 150, 300);
canvasContext.fillStyle = '#e08e0b';
canvasContext.fillRect(0, 100 - average, 150, 300);
//canvasContext.fillStyle = '#262626';
//canvasContext.font = "20px impact";
//canvasContext.fillText(Math.round(average - 0), -2, 100);
} // end fn stream
},
function(err) {
console.log("The following error occured: " + err.name)
});
} else {
console.log("getUserMedia not supported");
}
</script>
<div class="sidebar-toggle-labels" style="font-weight: bold; text-transform: uppercase;">MIC TEST</div>
<canvas id="canvas" width="25" height="100"></canvas>
Files
Updated by Wittie Manansala over 2 years ago
- File MicMeter.zip MicMeter.zip added
- Assignee changed from Demian Biscocho to Wittie Manansala
Hi Enzo,
Thank you very much for sharing your code.
We noticed when we turnoff the mic the mic meter still working.
Video attached.
Actions
Go to top