当我尝试实现基本的示例应用程序时,我开始学习webrtc
<html>
<head>
</head>
<body>
<script type="text/javascript">
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia || navigator.msGetUserMedia;
window.URL = window.URL || window.webkitURL;
navigator.getUserMedia({video: true}, function(localMediaStream) {
var video = document.createElement("video");
video.autoplay = true;
video.src = window.URL.createObjectURL(localMediaStream);
document.body.appendChild(video);
}, function(error) {
console.log(error);
});
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我使用此代码在locaL浏览器中运行google canary我启用了peerconnection并且我没有在我的浏览器中找到mediastream但我认为它可能在我的浏览器中启用了defalut.
问题是这个代码结果为console.i中的NavigatorUserMediaError没有找到解决这个问题的方法.任何人都知道我的代码出错了.
你是从网络服务器上运行的吗?
如果从file:// URL运行它,您将获得NavigatorUserMediaError.
我刚刚在Chrome 22.0中尝试了localhost中的代码,它运行正常.
请注意,此示例不使用RTCPeerConnection,您现在不必在Chrome中启用任何标记.
| 归档时间: |
|
| 查看次数: |
4088 次 |
| 最近记录: |