阅读:1695回复:1
请问为什么共享的摄像头看不到内容呢?
代码是这一段,不知道是不是代码的问题?这个好像是写给fx16的
虽然共享成功了,但是<video>里看不到任何东西 图片:1.png <!DOCTYPE html> <html lang="en"> <head> <title>HTML5 Exploding Camera Demo</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, user-scalable=yes"> </head> <body> <div role="main"> <video id="sourcevid" autoplay>Sorry, you're browser doesn't support video. Please try <a href="http://snapshot.opera.com/labs/camera/">Opera</a>.</video> <br/> <input type="button" value="Start" onclick="start()" > <input type="button" value="Stop" onclick="stop()" > </div> <script type="text/javascript"> var video; function start() { video = document.getElementById('sourcevid'); // Get the stream from the camera using getUserMedia navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL; if (navigator.getUserMedia) { // This beautiful hack for the options is from @kanasansoft: // http://www.kanasansoft.com/weblab/2012/06/arguments_of_getusermedia.html var gumOptions = {video: true, toString: function(){return 'video';}}; console.log(gumOptions); navigator.getUserMedia(gumOptions, function successCallback(stream) { // Replace the source of the video element with the stream from the camera if(navigator.getUserMedia==navigator.mozGetUserMedia) { video.src = stream; } else { video.src = window.URL.createObjectURL(stream) || stream; } video.play(); }, function errorCallback(error) { console.error('An error occurred: [CODE ' + error.code + ']'); video.play(); }); } else { var errorMsg = '<p class="error">Uh oh, it appears your browser doesn\'t support this feature. Please try with a <a href="http://www.opera.com/next/">browser that has camera support</a>.</p>'; document.querySelector('[role=main]').innerHTML = errorMsg; console.log('Native web camera streaming (getUserMedia) is not supported in this browser.'); video.play(); } } function stop() { video = document.getElementById('sourcevid'); video.src = ""; } </script> </body> </html> |
|
|
1楼#
发布于:2013-02-23 22:23
貌似因為 WebRTC getUserMedia 還在杯具裡面阿?!
|
|
|