以下是代碼部分,測試過,瀏覽器支持getUserMedia方法的。我實在找不出錯誤,兩個回調(diào)函數(shù)函數(shù)都沒有進入。求解!?。?lt;!DOCTYPE html><html><head><meta charset="UTF-8"><title>WebRTC通信</title></head><body><h1>訪問本地攝像頭</h1><video id="myVideo" width="1024" height="888" autoplay="true"></video></body><script type="text/javascript">window.onload = function(){navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;window.URL = window.URL || window.webkitURL;navigator.getUserMedia({video:true,?audio:true},?//訪問本地設(shè)備成功時的回調(diào)函數(shù)//stream為同步媒體數(shù)據(jù)流function(stream) {var video = document.getElementById('myVideo');if (window.URL) {video.src = window.URL.createObjectURL(stream);}else{video.src = stream;}},//訪問本地設(shè)備失敗時的回調(diào)函數(shù)function (err) {console.log(err);});}</script></html>
HTML5訪問本地攝像頭失敗,求指點
Rosevil1874
2016-09-22 11:25:34