國內這方面的資料真少的可憐,翻出去一搜一大把,推薦一個github的插件庫,非常強大,支持各種各樣的錄制方式.
下載完成之后,引用對應的js立即可以使用.
<script src="RecordRTC/RecordRTC.js"></script> <script src="part-of-screen-sharing/screenshot.js"></script> <div id="elementToShare" style="width:50%;height:50%;background:green;"> <input></input> </div> <button onclick="start()">start</button> <button onclick="stop()">stop</button> <script> var elementToShare = document.getElementById('elementToShare'); var recorder = RecordRTC(elementToShare, { type: 'canvas' }); function start(){ recorder.startRecording(); } function stop(){ recorder.stopRecording(function(url) { window.open(url); }); } </script>