我正在用Agora.io构建一个网络应用程序。我希望能够在客户的智能手机上从正面切换到后置摄像头。我看过switchCamera的阿格拉博士。我试过以下几种方法:
switchCamera();
myAgoraClient.switchCamera();
localStream.switchCamera();它们都会抛出一个no such function错误。
什么是正确的方式切换在agora.io中的摄像头的网页?
发布于 2018-11-16 18:33:30
您可以使用https://docs.agora.io/en/Video/API%20Reference/web/interfaces/agorartc.stream.html#switchdevice方法在2.5 SDK中完成这一任务。
switchDevice(类型: string,deviceId: string,onSuccess: function,onFailure: function)
例如;
localStream.switchDevice("video", "<deviceid>", console.log,console.log)应该做这件事。我也尝试过同样的方法,但是示例中包含了旧的2.4jsSDK,您需要专门下载^2.5
发布于 2018-10-09 06:45:03
我不认为Agora的最新版本有这些现成的方法。
但是,您可以通过以下方法创建照相机列表:
AgoraRTC.getDevices(function(devices){
cameras = devices.filter(device => device.kind === 'videoinput');
});然后给switchCamera一个实现:
function switchCamera(){
cameraIndex = (++cameraIndex) % cameras.length;
}使用cameras[cameraIndex].deviceId作为cameraId创建一个新的本地视频流并将其发布出来。
https://stackoverflow.com/questions/52572229
复制相似问题