已使用navigator.mediaDevices.getUserMedia()开始记录。以下是代码:(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>
也尝试了Stop/Close webcam which is opened by navigator.getUserMedia。 调用track.stop()之后,立即将音频的“ readyState”设置为结束。但是录制图标不会从选项卡中删除。