Remove red icon after stopping recording

I am using record.js. The functionality works fine, but after I stop recording, the red icon still appears in the chrome tab (next to the title). Please suggest what to do. Sorry if it's just .... P

This is my code:

window.URL = window.URL || window.webkitURL;
    navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;

    var recorder;
    var savedSrc = '';
    var audio = document.querySelector('audio');

var onFail = function(e)
    {
        console.log('Rejected!', e);
    };

    var onSuccess = function(s)
    {
        var context = new AudioContext();
        var mediaStreamSource = context.createMediaStreamSource(s);
        recorder = new Recorder(mediaStreamSource);
        recorder.record();
        $('#recordText').html('Recording...');
        // audio loopback
        // mediaStreamSource.connect(context.destination);
    };



    function startRecording()
    {
        if (navigator.getUserMedia)
        {
            navigator.getUserMedia(
            {
                video : false,
                audio : true,
                toString : function()
                {
                    return "audio";
                }
            }, onSuccess, onFail);
        }
        else
        {
            console.log('navigator.getUserMedia not present');
        }

    };

    function stopRecording()
    {
        $('#recordText').html('Record');
        recorder.stop();
        recorder.exportWAV(function(s)
        {

            audio.src = window.URL.createObjectURL(s);
        });
    }

      

+3


source to share


3 answers


This is a browser function , not a site function. It will remain until the tab is closed, which means "This tab has access to a microphone or webcam or using a microphone."



At the time of writing this answer, there was no way to remove this icon. Now you can delete it after you stop recording. Check @akaravashkin's answer, I haven't tested it.

+1


source


To remove the red icon after using Recorder.js:

var audioStream;    
var onSuccess = function(s) {
    ...
    audioStream = s;
}

function stopRecording() {
   ...
   audioStream.getTracks()[0].stop();
}

      



getTracks () only returns one item as your config only uses audio.

I hope this helps someone.

+10


source


You can terminate the stream directly using the stream object returned by the success handler in getUserMedia. Example

 localMediaStream.stop()

      

0


source







All Articles