html5 如何关闭本地摄像头
1、打开vsCode,使用vscode 来做代码演示

3、先创建好html文件所必须的 结构填入以下的代码<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Document</title></head><body></body></html>

5、在html使用摄像头我们需要使用MediaStream添加script语句var 罕铞泱殳constraints = { video: { width: 1280, height: 720 } };navigator.mediaDevices.getUserMedia(constraints).then(function (mediaStream) {var video = document.querySelector('video');video.srcObject = mediaStream;video.onloadedmetadata = function (e) {video.play();};}).catch(function (err){ console.log(err.name + ": " + err.message); });

7、现在我们添加一个关闭摄像头的功能先添加一个关闭按钮<button onclick="funClose();">关闭摄像头</button>

8、添加关闭摄像头的逻辑
