白左
千年狐狸
千年狐狸
  • UID34985
  • 注册日期2010-12-29
  • 最后登录2024-09-21
  • 发帖数2039
  • 经验655枚
  • 威望0点
  • 贡献值364点
  • 好评度69点
  • 社区居民
  • 忠实会员
阅读:1695回复:1

请问为什么共享的摄像头看不到内容呢?

楼主#
更多 发布于:2013-02-23 22:23
代码是这一段,不知道是不是代码的问题?这个好像是写给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>
-いたんですか? -ええ、ずっと
taglife
千年狐狸
千年狐狸
  • UID38488
  • 注册日期2012-03-20
  • 最后登录2013-04-02
  • 发帖数2052
  • 经验10枚
  • 威望0点
  • 贡献值0点
  • 好评度1点
1楼#
发布于:2013-02-23 22:23
貌似因為 WebRTC getUserMedia 還在杯具裡面阿?!        
Firefox 開啟安全模式,停用個人設定、佈景主題及擴充套件(無附加元件)測試:
說明 > 重新啟動但停用附加元件(Firefox 4+)
Firefox Profile: 說明 > 疑難排解資訊 > 開啟資料夾
排版引擎:Firefox(Gecko), Opera(Presto), Google Chrome(WebKit),
Safari(WebKit), Internet Explorer(Trident), Konqueror(KHTML)
游客

返回顶部