老师像这个gotDevices(deviceInfos)函数以及gotMediaStream(stream)函数,他们里面的参数是怎么推导的?
来源:6-3 【安全管理】获取音视频设备的访问权限

wonderofsky
2019-11-16
function gotDevices(deviceInfos){
deviceInfos.forEach(function(deviceinfo){
var option = document.createElement('option');
option.text = deviceinfo.label;
option.value = deviceinfo.deviceId;
if(deviceinfo.kind === 'audioinput'){
audioSource.appendChild(option);
}else if(deviceinfo.kind === 'audiooutput'){
audioOutput.appendChild(option);
}else if(deviceinfo.kind === 'videoinput'){
videoSource.appendChild(option);
}
})
}
function gotMediaStream(stream){
window.stream = stream;
videoplay.srcObject = stream;
return navigator.mediaDevices.enumerateDevices();
}
就是像上面的这两个函数,在编程的时候如何知道这个函数参数(deviceInfos,streams)的类型呢?还是说它们有一个固定的格式啥的。怎样确保它的参数是正确的?JS这块一直不大明白。
写回答
1回答
-
李超
2019-11-21
没法推导,按照WebRTC API手册来的
00
相似问题