1、首先需要引用eloamWebCamera.js 封装js和需要jquery.min.js(如果已经引用了jquery则不需要引用)
2、设备初始化,创建webCamera对象,后续其他接口使用这个对象来调用
3、设备初始化时,如果需要视频展示,则需要传对应的视频显示id;否则可以不传id
/**
* <!--如果服务需要使用视图显示则复制下面代码并修改对应的id值;如果不使用视频,初始化时,可以传空对象{}-->
// 非ie浏览器,包含视频显示img的div
<div id="noniediv">
<img id="ImgMain" width="760" height="475"/>
</div>
<!-- 如果是ie浏览器,会显示ocx -->
<div id="ocxdiv">
<OBJECT classid="clsid:A4B4E9B5-78E6-4CE3-B8A1-4B36237943F8" id="ocxstreamimageId" width="360px"
height="270px"></OBJECT>
</div>
**/
webCamera = new WebCamera($, {
initCamera: true, // 是否要初始化摄像头状态,如果为true,则会检查摄像头状态,如果是打开的,会将摄像头关闭
hideDivImg: true,// 初始化是否要隐藏显示摄像头窗口;true 隐藏,打开摄像头会显示,关闭摄像头时会隐藏;false
port: '38088',// CameraWebService 服务端口,默认38088
ocxDivId: 'ocxdiv',// ocx 对应的div ID 为了;使用ie浏览器时这个值必填
ocxId: 'ocxstreamimageId',// ocx 对应的id;这个传ocx 的id;使用ie浏览器时这个值必填
imgMainDivId: 'noniediv',// 包含img div 的id,
imgMainId: 'ImgMain',// 非IE img id 显示预览
}, function (data) {//成功回调
console.log(data)
}, function (err) {//失败回调
console.log(err)
})
或使用js 扩展方式初始化
webCamera = $.eloamWebCamera({
initCamera: true, // 是否要初始化摄像头状态,如果为true,则会检查摄像头状态,如果是打开的,会将摄像头关闭
port: '38088',// CameraWebService 服务端口,默认38088
ocxDivId: 'ocxdiv',// ocx 对应的div ID 为了
ocxId: 'ocxstreamimageId',// ocx 对应的id;这个传ocx 的id
imgMainDivId: 'noniediv',// 包含img div 的id,
imgMainId: 'ImgMain',// 非IE img id 显示预览
}, function (data) {//成功回调
console.log(data)
}, function (err) {//失败回调
console.log(err)
})