在源代码中进行一些搜索后,我可以通过这种方式设置后置摄像头:
easyrtc.getVideoSourceList( function(list) {
var i;
for( i = 0; i < list.length; i++ ) {
alert("label=" + list[i].label + ", id= " + list[i].id);
if(list[i].label.indexOf('back') > 0){ // Searching for label containing back (for back camera)
easyrtc.setVideoSource(list[i].id); // Set the id of back camera. Must be called before easyrtc.initMediaSource()
easyrtc.initMediaSource(
function(){ // success callback
var selfVideo = document.getElementById("self");
easyrtc.setVideoObjectSrc(selfVideo, easyrtc.getLocalStream());
easyrtc.connect("Company_Chat_Line", connectSuccess, connectFailure);
},connectFailure
);
break;
}
}
Run Code Online (Sandbox Code Playgroud)
对于版本 v1.0.17 使用list[i].deviceid而不是list[i].id
| 归档时间: |
|
| 查看次数: |
1420 次 |
| 最近记录: |