Video 使用webrtc DOM异常的视频聊天12
我正在使用webrtc在一个网页中尝试一个简单的视频聊天,并得到以下错误 未捕获错误:语法错误:DOM异常12 我的代码是Video 使用webrtc DOM异常的视频聊天12,video,html5-video,livechat,webrtc,Video,Html5 Video,Livechat,Webrtc,我正在使用webrtc在一个网页中尝试一个简单的视频聊天,并得到以下错误 未捕获错误:语法错误:DOM异常12 我的代码是 <button id='btn2' onclick='call();'>call</button> ...... function call(){ pc1 = new webkitPeerConnection00(null,icecallback1); console.log('created
<button id='btn2' onclick='call();'>call</button>
......
function call(){
pc1 = new webkitPeerConnection00(null,icecallback1);
console.log('created local peer connection object pc1');
pc2 = new webkitPeerConnection00(null,icecallback2);
console.log('created local peer connection object pc2');
pc2.onaddstream = gotremotestream;
pc1.addstream = localstream;
console.log('loclastream added');
var offer = pc1.createOffer(null);
pc1.setLocalDescription(pc1.SDP_OFFER,offer);
console.log('localdesc');
pc2.setRemoteDescription(pc2.SDP_OFFER,offer);
console.log('pc2remotedesc');
var answer = pc2.createAnswer(offer.toSdp(),{has_audio:true,has_video:true});
pc2.setLocalDescription(pc2.SDP_ANSWER,answer);
pc1.setRemoteDescription(pc1.SDP_ANSWER,answer);
pc1.startIce();
pc2.startIce();
};
function gotremotestream(e){
video2.src = webkitURL.createObjectURL(e.stream);
}
function icecallback1(candidate,bmore){
if(candidate){
pc2.processIceMessage(candidate);
console.log("local ICE candidate: " + candidate.toSdp());
}
}
function icecallback2(candidate,bmore){
if(candidate){
pc1.processIceMessage(candidate);
console.log("remote ICE candidate: " + candidate.toSdp());
}
}
呼叫
......
函数调用(){
pc1=新webkitPeerConnection00(null,icecallback1);
log('created local peer connection object pc1');
pc2=新的webkitPeerConnection00(null,icecallback2);
log('created local peer connection object pc2');
pc2.onaddstream=gotmotestream;
pc1.addstream=localstream;
console.log('loclastream added');
var offer=pc1.createOffer(空);
pc1.setLocalDescription(pc1.SDP_OFFER,OFFER);
log('localdesc');
pc2.setRemoteDescription(pc2.SDP_报价,报价);
console.log('pc2remotedesc');
var answer=pc2.createAnswer(offer.toSdp(),{has_audio:true,has_video:true});
pc2.setLocalDescription(pc2.SDP_答案,答案);
pc1.setRemoteDescription(pc1.SDP_应答,应答);
pc1.startIce();
pc2.startIce();
};
函数gotmotestream(e){
video2.src=webkitURL.createObjectURL(e.stream);
}
函数icecallback1(候选,bmore){
如果(候选人){
pc2.processIceMessage(候选者);
log(“本地ICE候选:+candidate.toSdp());
}
}
功能icecallback2(候选,bmore){
如果(候选人){
pc1.processIceMessage(候选者);
log(“远程ICE候选:+candidate.toSdp());
}
}
有人能帮我解决我的问题吗?我完全被它难住了。你使用的是什么版本的Chrome?请注意www.webrtc.org/blog上描述的PeerConnection00弃用 我正在使用chrome 22。但是在canary上运行代码解决了我的问题。只要将浏览器更改为chrome canary,它就会工作