专做眼镜的网站wordpress 营销
news/
2025/9/28 10:22:47/
文章来源:
专做眼镜的网站,wordpress 营销,中国建筑官网站,给别人做的网站要复杂做安全扫描uni中可以通过调用api的方式去拍摄或者是选择相册的视频#xff0c;但是在这里我们不采取这种方式#xff0c;因为调用api的方式#xff0c;必须跳转#xff0c;而我们需要在页面中实现#xff0c;下面看下具体步骤吧... camera v-if!srcUrl showCam… uni中可以通过调用api的方式去拍摄或者是选择相册的视频但是在这里我们不采取这种方式因为调用api的方式必须跳转而我们需要在页面中实现下面看下具体步骤吧... camera v-if!srcUrl showCamera device-positionback flashauto binderroronCameraError stylewidth: 100%; height: 400rpx;/camera
video v-ifsrcUrl idmyVideo :srcsrcUrl controls/video
view clickstartShoot开始
/view
view------------------------------------------------------------------------------------
/view
view clickstopShoot结束
/viewdata() {return {cameraContext: null,showCamera: false,srcUrl: null,timer: null,totalSeconds: 0};
}接下来看下怎么样实现拍摄
onReady() {this.cameraContext uni.createCameraContext()
}methods: {// 开始拍摄startShoot() {this.totalSeconds 0this.showCamera truethis.cameraContext.startRecord({timeoutCallback: () {console.log(this.totalSeconds,超出限制时长);},timeout: 300,success: (res) {this.timer setInterval(() {this.totalSeconds}, 1000)console.log(res, 开始拍摄);},fail: (err) {this.showCamera falseuni.showToast({title: 录制视频失败,icon: none,mask: true})}})},// 结束拍摄stopShoot() {if(this.timer) clearInterval(this.timer)this.cameraContext.stopRecord({compressed: true,success: (res) {this.srcUrl res.tempVideoPath// TODO 获取数据帧console.log(res, 结束拍摄);},fail: (err) {uni.showToast({title: 录制视频失败,icon: none,mask: true})console.log(err, 录制视频失败);},complete: () {this.showCamera false}})},
}
到这里已经基本实现了所需的功能但是还需要处理一下拍摄超时的情况
watch: {totalSeconds: {handler(newVal){if(newVal 270) {console.log(newVal, newVal);this.stopShoot()}}}
}
感觉对你有帮助的小伙伴可以留个star...
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/920491.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!