利用WebRTC照镜子,源代码见下方SourceCode 这篇博文是在我之前使用ananote?主题发布的,在next主题上,会导致打开这个文章所在的pages,自动调用摄像头——然而没有多少影响,因为不是https「笑,https好贵」,所以对访客而言,没有什么影响。 Source code <style type="text/css"> body { margin: px; padding: px; } #player { width: 100%; height: 100%; } </style> <script> (function(){ var mediaOptions = { audio: false, video: true }; if (!navigator.getUserMedia) { navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; } if (!navigator.getUserMedia){ return alert('getUserMedia not supported in this browser.'); } navigator.getUserMedia(mediaOptions, success, function(e) { console.log(e); }); function success(stream){ var video = document.querySelector("#player"); video.src = window.URL.createObjectURL(stream); } })(); </script> <video id="player" autoplay="true"></video> ……

Continue reading