Location>code7788 >text

uni-app's camera component - face shooting

Popularity:358 ℃/2024-08-30 15:19:18
<script> export default { data() { return { cameraContext: null, //timekeeping device (sundial, water clock) timer: null, //recording time totalSeconds: 10, //screen height screenHeight: "", //Whether or not to display the Finish Mask achieveShow: false } }, onLoad() { let that = this ({ success: (res) => { ('Screen width in px:', ); ('Screen height in px:', ); = ; }, }); setTimeout(() => { this.startShoot() }, 500) }, onReady() { // Create the camera context CameraContext object. this.cameraContext = () }, methods: { // Start filming. startShoot() { this.({ timeoutCallback: () => { ('Exceeded limit hours'.this.totalSecond); }, timeout: this.totalSeconds, success: (res) => { //Turn on the timer this.timer = setInterval(() => { this.totalSeconds-- }, 1000) (res, 'Start filming'); }, fail: (err) => { this.errToast('Camera startup failed, please reopen')) } }) }, // Finish filming. stopShoot() { // Contact Timer if (this.timer) clearInterval(this.timer) this.({ compressed: true, success: (res) => { //Show Mask this.achieveShow = true // TODO Get Data Frame (res, 'end shot'); }, fail: (err) => { this.errToast('Video save failed, please re-record')) }, }) }, // Camera Error onCameraError(error) { ('Camera error: ', ); }, //Camera - Failed Operation errToast(e) { this.$({ title: e }) setTimeout(() => { this.confirmBut() }, 500) }, //OK-Back to previous page confirmBut() { () }, }, watch: { //listen in on a countdown totalSeconds: { handler(newVal) { // (newVal, 'Countdown'). //End shooting when countdown = 1 if (newVal == 1) { //Finish filming. this.stopShoot() } } } } } </script>