最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

uni-app實(shí)現(xiàn)微信小程序長按拍視頻功能

 更新時間:2022年08月28日 09:06:46   作者:紅豆O(∩_∩)O  
這篇文章主要為大家詳細(xì)介紹了uni-app實(shí)現(xiàn)微信小程序長按拍視頻功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了uni-app實(shí)現(xiàn)微信小程序長按拍視頻功能的具體代碼,供大家參考,具體內(nèi)容如下

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標(biāo)簽最前面聲明拍攝視頻需要的api
?? ?const recorderManager = uni.getRecorderManager();
?? ?const innerAudioContext = uni.createInnerAudioContext('myAudio');
?? ?innerAudioContext.autoplay = true;
?? ?//錄制視頻start
?? ??? ??? ?startShootVideo() {
?? ??? ??? ??? ?let index = 0;
?? ??? ??? ??? ?let that = this
?? ??? ??? ??? ?this.timer=setInterval(() => { //注意箭頭函數(shù)??!
?? ??? ??? ??? ??? ?if(that.deflautWidth !=100){
?? ??? ??? ??? ??? ??? ?index += 1;
?? ??? ??? ??? ??? ??? ?that.deflautWidth = index
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?if (that.deflautWidth == 100) {
?? ??? ??? ??? ??? ??? ?clearInterval(this.timer);
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ?}, 100);
?? ??? ??? ??? ?console.log("========= 調(diào)用開始錄像 ===========")
?? ??? ??? ??? ?this.cameraContext = uni.createCameraContext();
?? ??? ??? ??? ?this.cameraContext.startRecord({
?? ??? ??? ??? ??? ?success: res => {
?? ??? ??? ??? ??? ??? ?console.log("錄像成功")
?? ??? ??? ??? ??? ??? ?console.log(res)
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ?});
?? ??? ??? ?},
?? ??? ??? ?stopShootVideo() {
?? ??? ??? ??? ?// ? console.log("========= 調(diào)用結(jié)束錄像 ===========")
?? ??? ??? ??? ?this.cameraContext = uni.createCameraContext();
?? ??? ??? ??? ?this.cameraContext.stopRecord({
?? ??? ??? ??? ??? ?success: res => {
?? ??? ??? ??? ??? ??? ?console.log('結(jié)束videoSrc')
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ?this.videoSrc.push(res.tempVideoPath)
?? ??? ??? ??? ??? ??? ?console.log(this.videoSrc)
?? ??? ??? ??? ??? ??? ?this.hidden = false
?? ??? ??? ??? ??? ??? ?this.showvideoimage = true
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ?});
?? ??? ??? ?},
?? ??? ??? ?// //touch start 手指觸摸開始
?? ??? ??? ?handleTouchStart(e){ ? ?
?? ??? ??? ??? ?this.starttime ?= ?e.timeStamp; ? ?
?? ??? ??? ??? ?console.log(" startTime = " ?+ ?e.timeStamp); ?
?? ??? ??? ??? ?console.log(" 手指觸摸開始 " , ?e); ?
?? ??? ??? ??? ?console.log(" this " , this); ?
?? ??? ??? ?},
?? ??? ??? ?//touch end 手指觸摸結(jié)束
?? ??? ??? ?handleTouchEnd(e){ ? ?
?? ??? ??? ??? ?clearInterval(this.timer);
?? ??? ??? ??? ?this.endtime ?= ?e.timeStamp; ? ?
?? ??? ??? ??? ?this.stopShootVideo();
?? ??? ??? ??? ?// console.log(" endTime = " ?+ ?e.timeStamp); ?
?? ??? ??? ??? ?console.log(" 手指觸摸結(jié)束 ", e);
?? ??? ??? ??? ?//判斷是點(diǎn)擊還是長按 點(diǎn)擊不做任何事件,長按 觸發(fā)結(jié)束錄像
?? ??? ??? ??? ?if (this.endtime - this.starttime > 350) {
?? ??? ??? ??? ??? ?//長按操作 調(diào)用結(jié)束錄像方法
?? ??? ??? ??? ??? ?this.stopShootVideo();
?? ??? ??? ??? ?}
?? ??? ??? ??? ?this.showProgress = false
?? ??? ??? ??? ?this.hidden = true
?? ??? ??? ??? ?this.showvideoimage = true
?? ??? ??? ?},
?? ??? ??? ?// /**
?? ??? ??? ?// ?* 長按按鈕 - 錄像
?? ??? ??? ?// ?*/
?? ??? ??? ?handleLongPress(e){
?? ??? ??? ? ?console.log("endTime - startTime = " ?+ ?(this.endtime ?- ?this.starttime));
?? ??? ??? ? ?console.log("長按");
?? ??? ??? ? ?// 長按方法觸發(fā),調(diào)用開始錄像方法
?? ??? ??? ? ?this.startShootVideo();
?? ??? ??? ?},
?? ??? ??? ?showvideo(){
?? ??? ??? ? ?this.hidden = true
?? ??? ??? ? ?this.showProgress = true
?? ??? ??? ? ?// this.showvideoimga = true
?? ??? ??? ?
?? ??? ??? ?},
?? ??? ??? ?//錄制視頻end

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • JS中showModalDialog關(guān)閉子窗口刷新主窗口用法詳解

    JS中showModalDialog關(guān)閉子窗口刷新主窗口用法詳解

    這篇文章主要介紹了JS中showModalDialog關(guān)閉子窗口刷新主窗口用法,結(jié)合具體實(shí)例形式較為詳細(xì)的分析了showModalDialog常見用法與相關(guān)使用技巧,需要的朋友可以參考下
    2017-03-03
  • JS實(shí)現(xiàn)的駝峰式和連字符式轉(zhuǎn)換功能分析

    JS實(shí)現(xiàn)的駝峰式和連字符式轉(zhuǎn)換功能分析

    這篇文章主要介紹了JS實(shí)現(xiàn)的駝峰式和連字符式轉(zhuǎn)換功能,結(jié)合實(shí)例形式分析了JS實(shí)現(xiàn)字符串的駝峰式與連接符式轉(zhuǎn)換的實(shí)現(xiàn)技巧,涉及js字符串遍歷、轉(zhuǎn)換及正則表達(dá)式相關(guān)操作方法,需要的朋友可以參考下
    2016-12-12
  • 基于mouseout和mouseover等類似事件的冒泡問題解決方法

    基于mouseout和mouseover等類似事件的冒泡問題解決方法

    這篇文章主要介紹了關(guān)于mouseout和mouseover等類似事件的冒泡問題解決方法。需要的朋友可以過來參考下,希望對大家有所幫助
    2013-11-11
  • JavaScript?WeakMap的具體使用

    JavaScript?WeakMap的具體使用

    本文主要介紹了JavaScript?WeakMap的具體使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-02-02
  • javascript設(shè)計(jì)模式 接口介紹

    javascript設(shè)計(jì)模式 接口介紹

    最近在看javascript設(shè)計(jì)模式的書籍《pro javascript design pattrens》,覺得很不錯,可以提高自己對js oo的理解,也可能幫助自己更好的理解別人寫的js library,提高自己js的水平
    2012-07-07
  • js模擬hashtable的簡單實(shí)例

    js模擬hashtable的簡單實(shí)例

    本篇文章主要是對js模擬hashtable的簡單實(shí)例進(jìn)行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助
    2014-03-03
  • JavaScript設(shè)計(jì)模式中的觀察者模式

    JavaScript設(shè)計(jì)模式中的觀察者模式

    這篇文章主要介紹了JavaScript設(shè)計(jì)模式中的觀察者模式,觀察者設(shè)計(jì)模式適用于監(jiān)聽一對多的操作,例如監(jiān)聽對象屬性的修改等等,觀察者模式能夠降低代碼耦合度,提升可擴(kuò)展性
    2022-06-06
  • BootStrap組件之進(jìn)度條的基本用法

    BootStrap組件之進(jìn)度條的基本用法

    bootstrap組件在前端開發(fā)中經(jīng)常會用到,今天小編通過本文給大家分享bootstrap組件之進(jìn)度條的基本用法,需要的朋友參考下吧
    2017-01-01
  • js實(shí)現(xiàn)隨機(jī)抽選效果、隨機(jī)抽選紅色球效果

    js實(shí)現(xiàn)隨機(jī)抽選效果、隨機(jī)抽選紅色球效果

    本文主要分享了js實(shí)現(xiàn)隨機(jī)抽選效果、隨機(jī)抽選紅色球效果的示例代碼。具有一定的參考價值,下面跟著小編一起來看下吧
    2017-01-01
  • 小程序開發(fā)實(shí)現(xiàn)access_token統(tǒng)一管理

    小程序開發(fā)實(shí)現(xiàn)access_token統(tǒng)一管理

    本文主要介紹了小程序開發(fā)實(shí)現(xiàn)access_token統(tǒng)一管理,文中通過示例代碼介紹的非常詳細(xì),需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2021-07-07

最新評論

康定县| 阿勒泰市| 田林县| 饶阳县| 汝南县| 丹寨县| 青阳县| 安阳县| 延寿县| 禹城市| 托里县| 鸡西市| 友谊县| 南京市| 灵璧县| 固始县| 湘潭县| 通渭县| 贵溪市| 临汾市| 靖州| 府谷县| 红安县| 遂溪县| 邵阳市| 株洲市| 乌鲁木齐县| 高清| 达州市| 慈溪市| 普安县| 庆安县| 博爱县| 绍兴县| 宁远县| 南投县| 宁晋县| 临安市| 海宁市| 博爱县| 砀山县|