老师像这个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手册来的

0
0

5G时代必备音视频WebRTC实时互动直播技术入门与实战

低门槛掌握WebRTC技术,高效率快速构建一套音视频实时互动系统

2541 学习 · 728 问题

查看课程