html

<!-- 上传视频 --><view class="Voice_input"><text class="Voice_title">上传视频:</text><view class="" ><view class="video_image"><view class="video_box" v-for="(item,index) in videoSrc" :key='index'><video v-show="videoSrc" class="showvideo" :src="item"></video></view><image class="videoshow" v-show="showvideoimga"  src="../../static/images/yinyue.png" @tap="showvideo"></image></view><view><progress :percent="deflautWidth" v-show="showProgress" color="pink" stroke-width="15" class="progressStyle" /><!-- <progress percent="deflautWidth" hidden="showProgress" color="pink"   stroke-width="15"  class="progressStyle" /> --><camera   v-show="hidden" flash="off" style="width: 100%; height: 100%;position:fixed;top:0;z-index:1111;left:0;"></camera><view class="btn-area"  ><view class=""><text  class="videBtn" @touchstart="handleTouchStart" @touchend="handleTouchEnd" v-show="hidden" @longpress="handleLongPress" >按住拍</text></view></view></view></view></view>

css样式

/* 上传视频 */.video_image{width: 700rpx;/* height: 99px; */margin-bottom: 15px;display: flex;flex-wrap: wrap;margin-top: 20rpx;}.video_box{margin-right: 20rpx;margin-top: 20rpx;}.video_image image{width: 200rpx;height: 200rpx;margin-top: 20rpx;margin-left: 10rpx;}.Voice_box{display: flex;align-items: center;flex-wrap: wrap;margin-top: 15px;padding-bottom: 15px;}.videoshow{border: 1rpx solid #cccccc;width: 200rpx;height: 200rpx;/* margin:8px 10px; *//* position: relative; */}.videoConten{display: flex;align-items: center;}.showvideo{width: 200rpx;height: 200rpx;}.videBtn{position: fixed;bottom: 20rpx;left: 50%;transform:translateX(-50%);width: 200rpx;height: 200rpx;border-radius:50%;font-size: 35rpx;color:green ;text-align: center;line-height: 190rpx;border: 7rpx solid green;background:rgba(0,0,0,0);z-index: 11111;padding: 0;margin: 0;}.progressStyle{position: fixed;top: 0rpx;left: 0rpx;z-index: 111111;width: 100%;}

js部分

//在script标签最前面声明拍摄视频需要的apiconst recorderManager = uni.getRecorderManager();const innerAudioContext = uni.createInnerAudioContext('myAudio');innerAudioContext.autoplay = true;//录制视频startstartShootVideo() {let index = 0;let that = thisthis.timer=setInterval(() => { //注意箭头函数!!if(that.deflautWidth !=100){index += 1;that.deflautWidth = index}if (that.deflautWidth == 100) {clearInterval(this.timer);}}, 100);console.log("========= 调用开始录像 ===========")this.cameraContext = uni.createCameraContext();this.cameraContext.startRecord({success: res => {console.log("录像成功")console.log(res)}});},stopShootVideo() {//   console.log("========= 调用结束录像 ===========")this.cameraContext = uni.createCameraContext();this.cameraContext.stopRecord({success: res => {console.log('结束videoSrc')this.videoSrc.push(res.tempVideoPath)console.log(this.videoSrc)this.hidden = falsethis.showvideoimage = true}});},// //touch start 手指触摸开始handleTouchStart(e){    this.starttime  =  e.timeStamp;    console.log(" startTime = "  +  e.timeStamp);  console.log(" 手指触摸开始 " ,  e);  console.log(" this " , this);  },//touch end 手指触摸结束handleTouchEnd(e){    clearInterval(this.timer);this.endtime  =  e.timeStamp;    this.stopShootVideo();// console.log(" endTime = "  +  e.timeStamp);  console.log(" 手指触摸结束 ", e);//判断是点击还是长按 点击不做任何事件,长按 触发结束录像if (this.endtime - this.starttime > 350) {//长按操作 调用结束录像方法this.stopShootVideo();}this.showProgress = falsethis.hidden = truethis.showvideoimage = true},// /**//  * 长按按钮 - 录像//  */handleLongPress(e){console.log("endTime - startTime = "  +  (this.endtime  -  this.starttime));console.log("长按");// 长按方法触发,调用开始录像方法this.startShootVideo();},showvideo(){this.hidden = truethis.showProgress = true// this.showvideoimga = true},//录制视频end

uni-app实现微信小程序长按拍视频的功能相关推荐

  1. uni app 开发微信小程序及上线体验

    uni app 开发微信小程序及上线体验 项目创建及微信小程序AppId的申请 本次开发的是电商类的微信小程序,这里用到的是HBuilderX这个编辑器.之前用的Visual Studio Code ...

  2. 微信小程序实现上传视频 / 上传图片功能以及整合上传视频 / 上传图片功能(超详细)

    微信小程序有自己封装好的我们直接拿过来用就可以了 接下来我们看看如何实现的吧 上传图片功能 效果如下: 单图上传 Page({/*** 页面的初始数据*/data: {imgList: "& ...

  3. 记录uni.app开发微信小程序中地图的使用,以及项目中的解决办法

    标题先讲一下需求:需要获取用户的地址信息以及经纬度,并在地图中展示时出来 uniapp官方也提供了api uni.getLocation(OBJECT) getLocation只能获取用户的经纬度,不 ...

  4. json 微信小程序 筛选_GitHub - zhengyangkang/sl-filter: uni -app 一款使用简单的筛选组件,适配app、微信小程序、H5。...

    sl-filter 筛选 筛选组件,组件名:sl-filter dcloud插件市场地址 sl-filter 简介 一款使用简单的筛选组件,适配app.微信小程序.H5. 感谢分享 效果图 并列菜单 ...

  5. uniapp开发APP和微信小程序——使用高德实现定位

    在uniapp官网中明确说了可以使用高德地图来实现APP和微信小程序的定位. 在dcloud社区里大佬已经给出了实现方法(链接:uni-app 中使用微信小程序第三方 SDK 及资源汇总 - DClo ...

  6. 微信小程序长按保存图片

    微信小程序长按保存图片 wxml部分 <image data-url="{{item}}" bindlongtap="longPressSaveImg " ...

  7. python人脸检测与微信小程序_python+requests对app和微信小程序进行接口测试

    对于web端和app端的接口测试来说,他们都是通过请求方法,url和传递的body参数进行接口请求,区别web和app的区别就是header请求的不同.不同的地方在于header中的User-Agen ...

  8. python+requests对app和微信小程序进行接口测试

    对于web端和app端的接口测试来说,他们都是通过请求方法,url和传递的body参数进行接口请求,区别web和app的区别就是header请求的不同.不同的地方在于header中的User-Agen ...

  9. python扫描app接口_[分享】python+requests对app和微信小程序进行接口测试

    对于web端和app端的接口测试来说,他们都是通过请求方法,url和传递的body参数进行接口请求,区别web和app的区别就是header请求的不同.不同的地方在于header中的User-Agen ...

最新文章

  1. C#进行Visio二次开发之电气线路停电分析逻辑
  2. 10万视频,所有面部图像均获授权,Facebook创建大规模Deepfake数据集
  3. springboot + rabbitmq 整合示例
  4. 解决EXCEL统计问题的分享
  5. c语言,递归翻转一个单链表,c实现单链表
  6. influxDb 异常:{“error“:“retention policy not found: default“}
  7. android线程卡死,Android主线程为什么不因为Loop死循环卡死
  8. Linux下svn 安装搭建配置流程
  9. yolov5 解码使用GPU进行加速
  10. 文件磁盘相关函数[22]-文本文件读写-不同数据类型的写入
  11. 技术面试问项目难题如何解决的_技术面试中,遇到不会回答的问题怎么破?
  12. java中json转对象_Java开发中json使用,各对象与json相互转换
  13. 怎么把qq音乐flac改成mp3格式
  14. 大疆御air2怎么看经纬度_人人都能拍大片的无人机 – 大疆御 Mavic Air 2 评测
  15. 华为 P10 手机开始推送鸿蒙 HarmonyOS 2 内测版
  16. 【uni-app】uni-app实现聊天页面功能——功能篇(上)
  17. PHP redis key
  18. 如何有效记账 记账有哪些优点
  19. 西门子S7-200PLC自由口初始化
  20. BSCI验厂审核知识点

热门文章

  1. python画五角星代码_Python使用turtule画五角星的方法
  2. 如何理解数学公式中出现的极大极小minmax含义
  3. 【拓展】腾讯十大最受欢迎的开源项目!
  4. 关于阿里云aca和acp哪个好?阿里云认证证书有含金量吗?
  5. r5 7600x和r7 7700x差距
  6. Redis之时间轮机制(五)
  7. 星级评价的代码php,JavaScript_使用jQuery实现星级评分代码分享,前面有一篇原生js实现星级评 - phpStudy...
  8. 从PLC ,PAC ,到施耐德的自动化开放系统
  9. 腾讯云配置密钥使用putty登录 PuTTY实现Windows向Linux上传文件
  10. JVM架构、JVM垃圾回收机制、垃圾回收算法、垃圾回收器、JMM(内存模型)