Recording has been started using navigator.mediaDevices.getUserMedia(). Following is the code: (Vue Js)
<a href="javascript:void(null)" @click="stopRecording">Stop</a>
<script>
methods:{
stopRecording() {
if (window.mediaStream) {
window.mediaStream.getTracks().forEach(function(track) {
track.stop();
});
}
}
</script>
Also tried Stop/Close webcam which is opened by navigator.getUserMedia. Immediately after calling track.stop(), the 'readyState' of audio is set to ended. But the recording icon is not removed from the tab.