<body>
<video autoplay></video>
<a download="media" class="downloadButton">下载</a>
<button class="recorderControl">录制</button>
</body>
<script>
var promise= navigator.mediaDevices.getUserMedia({video:true});
promise.then(function(stream){
var video=document.querySelector("video");
video.src = URL.createObjectURL(stream);
var recorder=new MediaRecorder(stream);
var recorderControl=document.querySelector(".recorderControl");
recorderControl.onclick=function(){
this.textContent=="录制"?video.play():video.pause();
this.textContent=="录制"?recorder.start():recorder.stop();
this.textContent=this.textContent=="录制"?"停止":"录制";
};
var buffers=[];
recorder.ondataavailab
JS视频和音频录制
最新推荐文章于 2024-05-13 09:28:30 发布