微信小程序 長按錄音+錄制視頻

<view class="bigCircle" bindtouchstart="start" bindtouchend="stop"><view class="smallCircle {{startVedio?'onVedio':''}}"><text>{{startVedio?'正在錄音':'長按錄音'}}</text></view>
</view>
<view><view class="vedio-player"><view class="vedio-file" bindtap="play"><view class="item-list"><view wx:for="{{20}}" wx:for-item="item" class="item {{vedioProcess>item*5?'active':''}}" wx:key="index"></view></view><view class="time">{{vedioTime}}</view></view></view>
</view><view class="page-body" style="margin-top: 100rpx;"><view class="page-body-wrapper"><camera device-position="back" flash="off" binderror="error" style="width: 100%; height: 300px;"></camera><view class="btn-area"><button type="primary" bindtap="startRecord">開始錄像</button></view><view class="btn-area"><button type="primary" bindtap="stopRecord">結束錄像</button></view><view class="preview-tips">預覽</view><video wx:if="{{videoSrc}}" class="video" src="{{videoSrc}}"></video></view>
</view>
.bigCircle{height:140rpx;width:140rpx;border-radius:100%;background-color:#3370FF2E;display:flex;align-items:center;justify-content:center;color:#fff}
.smallCircle{width:100rpx;height:100rpx;background-color:#3370ff;border-radius:100%;display:flex;align-items:center;justify-content:center; font-size: 20rpx;}
.onVedio{background-color:#04d7b9!important}
.vedio-player{margin-top:20px;display:flex;justify-content:center;align-items:center}
.vedio-file{width:250px;height:44px;background:#f5f5f5;border-radius:34.5px;display:flex;align-items:center;padding:0 10px;box-sizing:border-box;justify-content:space-evenly}
.vedio-file image{height:33px;width:33px}
.item-list{width:150px;height:15px;display:flex;align-items:center}
.time{color:#0d296e;font-size:12px}
.item{height:12px;width:2px;background-color:#3370FF33;margin-left:5px}
.active{background-color:#3370ff}
.item:nth-child(6n-1),.item:nth-child(6n-5){height:4px}
.item:nth-child(6n-2),.item:nth-child(6n-4){height:8px}
.item:nth-child(6n-3){height:14px}
.del-vedio{margin-left:15px}
.del-vedio image{height:25px;width:25px}

//獲取應用實例
const app = getApp()
const recorderManager = wx.getRecorderManager()
const innerAudioContext = wx.createInnerAudioContext()
var tempFilePath;
Page({data: {startVedio: false,vedioTime: '0:00',},//開始錄音的時候start: function () {const options = {duration: 20000, //指定錄音的時長,單位 mssampleRate: 16000, //采樣率numberOfChannels: 1, //錄音通道數encodeBitRate: 96000, //編碼碼率format: 'mp3', //音頻格式,有效值 aac/mp3frameSize: 50, //指定幀大小,單位 KB}//開始錄音recorderManager.start(options);this.setData({startVedio: true})recorderManager.onStart((res) => {this.setData({startVedio: false})console.log('recorder start')});//錯誤回調recorderManager.onError((res) => {console.log(res);})},//停止錄音stop: function () {recorderManager.stop();recorderManager.onStop((res) => {this.tempFilePath = res.tempFilePath;const ss = Math.floor(res.duration / 1000 % 60)const mm = Math.floor(res.duration / 1000 / 60)this.setData({vedioTime: `${mm}:${ss>10?ss:'0'+ss}`})console.log('停止錄音', res.tempFilePath)const {tempFilePath} = res})},//播放聲音play: function () {innerAudioContext.autoplay = trueinnerAudioContext.src = this.tempFilePath,innerAudioContext.onPlay(() => {console.log('開始播放')})innerAudioContext.onError((res) => {console.log(res.errMsg)console.log(res.errCode)})},onLoad() {this.ctx = wx.createCameraContext()},startRecord() {this.ctx.startRecord({success: (res) => {console.log('startRecord')}})},stopRecord() {this.ctx.stopRecord({success: (res) => {console.log(res.tempVideoPath)this.setData({src: res.tempThumbPath,videoSrc: res.tempVideoPath})}})},error(e) {console.log(e.detail)}
})

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/214176.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/214176.shtml
英文地址,請注明出處:http://en.pswp.cn/news/214176.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

排序算法:【選擇排序]

一、選擇排序——時間復雜度 定義&#xff1a;第一趟排序&#xff0c;從整個序列中找到最小的數&#xff0c;把它放到序列的第一個位置上&#xff0c;第二趟排序&#xff0c;再從無序區找到最小的數&#xff0c;把它放到序列的第二個位置上&#xff0c;以此類推。 也就是說&am…

軟件項目管理---胡亂復習版

范圍控制的一個重點是避免需求的不合理擴張。(√)一個任務原計劃2個人全職工作2周完成,而實際上只有一個人參與這個任務,到第二周末這個人完成了任務的75%,那么:BCWS = 4人周,ACWP = 2人周,BCWP = 3人周。CV = 1,SV = -1。 【在項目管理中,BCWS、ACWP和BCWP是用來衡量…

微服務測試是什么?

微服務測試是一種特殊的測試類型&#xff0c;因為它涉及到多個獨立的服務。以下是進行微服務測試的一般性步驟&#xff1a; 1. 確定系統架構 了解微服務架構對成功測試至關重要。確定每個微服務的職責、接口、依賴項和通信方式。了解這些信息可以幫助您更好地規劃測試用例和測…

ip ssl證書怎么更換ip地址

ip ssl證書是一種數字證書&#xff0c;為只有公網ip地址的站點建立安全、加密的通信通道。它通常由權威的證書頒發機構&#xff08;CA&#xff09;頒發&#xff0c;并用于驗證網站的身份和安全性。ip ssl證書的主要目的是保護敏感信息&#xff0c;如信用卡號、用戶名和密碼等&a…

IO部分筆記

IO 概述 IO: 存儲和讀取數據的解決方案 作用: 用于讀寫文件中的數據(可以讀寫文件, 或網絡中的數據) IO流的分類 按流的方向: 輸入流, 輸出流 按操作文件類型: 字節流: 可以操作所有類型的文件 字符流: 只能操作純文本文件 純文本文件: windows自帶的記事本打開能讀懂…

react Hooks(useRef、useMemo、useCallback)實現原理

Fiber 上篇文章fiber簡單理解記錄了react fiber架構&#xff0c;Hooks是基于fiber鏈表來實現的。閱讀以下內容時建議先了解react fiber。 jsx -> render function -> vdom -> fiber樹 -> dom vdom 轉 fiber 的過程稱為 recocile。diff算法就是在recocile這個過程…

認識lambda架構(架構師考試復習)

Lambda架構主要分為三層&#xff0c;批處理層、加速層和服務層。 如下圖所示&#xff1a; &#xff08;1&#xff09;批處理層&#xff08;Batch Layer&#xff09;&#xff1a;存儲數據集&#xff0c;在數據集上預先計算查詢函數&#xff0c;并構建查詢對應的view。Batch Lay…

mysql 5.7 Unknown column ‘password‘ in ‘field list‘

問題現象&#xff1a; 執行sql : select user&#xff0c;host,password from user&#xff1b;時提示 ERROR 1054(42S22):Unknown column password in field list 現象如下圖所示&#xff1a; mysql 5.7開始 密碼字段用&#xff1a;authentication_string

Redis哨兵模式:什么是哨兵模式、哨兵模式的優缺點、哨兵模式的主觀下線和客觀下線、投票選舉、Redis 哨兵模式搭建

文章目錄 什么是哨兵模式哨兵模式的優缺點主觀下線和客觀下線投票選舉哨兵模式場景應用Redis version 6.0.5 集群搭建下載文件環境安裝解壓編譯配置文件啟動關閉密碼設置 什么是哨兵模式 哨兵模式是Redis的高可用解決方案之一&#xff0c;它旨在提供自動故障轉移和故障檢測的功…

2023年四川網信人才技能大賽 實操賽Writeup

文章目錄 Crypto比base64少的baseaffine簡單的RSA Misc不要動我的flagSimpleUSB猜猜我是誰不聰明的AI Pwngetitezbbstack Reverse誰的DNA動了Dont Touch Me Weblittle_gamejustppbezbbssmart 題目附件&#xff0c;文章末尾微信公眾號點點關注親&#xff0c;謝謝親~ 題目附件鏈接…

C++ Qt開發:PushButton按鈕組件

Qt 是一個跨平臺C圖形界面開發庫&#xff0c;利用Qt可以快速開發跨平臺窗體應用程序&#xff0c;在Qt中我們可以通過拖拽的方式將不同組件放到指定的位置&#xff0c;實現圖形化開發極大的方便了開發效率&#xff0c;本章將重點介紹QPushButton按鈕組件的常用方法及靈活運用。 …

電子眼+無人機構建平安城市視頻防控監控方案

電子眼&#xff08;也稱為監控攝像機&#xff09;可以通過安裝在城市的不同角落&#xff0c;實時監控城市的各個地方。它們可以用于監測交通違法行為、監控公共場所的安全以及實時監測特定區域的活動情況。通過電子眼的應用&#xff0c;可以幫助警方及時發現并響應各類安全事件…

Ubuntu安裝TensorRT

文章目錄 1. 安裝CUDAa. 下載CUDAb. 安裝CUDAc. 驗證CUDA 2. 安裝CUDNNa. 下載CUDNNb. 安裝CUDNNc. 驗證CUDNN 3. 安裝TensorRTa. 下載TensorRTb. 解壓TensorRTc. 安裝TensorRTd. 安裝uff和graphsurgeone. 驗證是否安裝成功f. 備注 關注公眾號&#xff1a;『AI學習星球』 回復&…

spring boot學習第五篇:spring boot與JPA結合

1、準備表&#xff0c;創建表語句如下 CREATE TABLE girl (id int(11) NOT NULL AUTO_INCREMENT,cup_Size varchar(100) COLLATE utf8mb4_bin DEFAULT NULL,age int(11) DEFAULT NULL,PRIMARY KEY (id) ) ENGINEInnoDB AUTO_INCREMENT4 DEFAULT CHARSETutf8mb4 COLLATEutf8mb4…

C語言-鏈表_基礎

鏈表-基礎 1. 數組 1.1 靜態數組 例子:int nums[5] {0};struct person ps[5]; 缺點:1,無法修改地址2,無法動態定義長度3,占用內存過大或過小4,增刪速度慢 優點數組的內存是連續開辟的,所以讀取速度快1.2 動態數組 例子:int *nums (int *) calloc(5,sizeof(int));struct p…

Vmware突然無法獲取IP(二)

一 測試環境 宿主機&#xff1a; window10Vmware 17 proUbuntu 18.04虛擬機中 二 問題 之前虛擬機可以正常使用。過程中&#xff0c;安裝了docker&#xff08;不確定是否和這個有關系&#xff09;第二天開啟虛擬機時&#xff0c;發現網口為down的狀態。將網口up后&#xff0…

python第三方庫——openpyxl

Bokeh是一個Python庫&#xff0c;用于對Excel 2010 xlsx/xlsm/xltx/xltm文件進行讀寫操作。 官網對該工具的介紹為&#xff1a; openpyxl is a Python library to read/write Excel 2010 xlsx/xlsm/xltx/xltm files.It was born from lack of existing library to read/write…

使用Java實現漢諾塔問題

文章目錄 漢諾塔問題 今天和大家來看看漢諾塔問題&#xff0c;這也是一個經典的算法 漢諾塔問題 分治算法經典問題&#xff1a;漢諾塔問題 漢諾塔的傳說 漢諾塔&#xff1a;漢諾塔&#xff08;又稱河內塔&#xff09;問題是源于印度一個古老傳說的益智玩具。大梵天創造世界的…

Git 克隆子目錄

背景 有時候&#xff0c;一個倉庫太大&#xff08;包含很多個工程&#xff09;&#xff0c;下載費時&#xff0c;又占電腦的空間。 如何只下載其中一個工程&#xff08;子目錄&#xff09;呢&#xff1f; 稀疏檢出&#xff08;Spare Checkout&#xff09; git 的 Spare Chec…

Java項目-瑞吉外賣Day5

視線新增套餐功能&#xff1a; 創建SetmealDish&#xff0c;SetmealDto類&#xff0c;與相關的mapper&#xff0c;service&#xff0c;serviceImpl&#xff0c;controller類。 Setmeal表示套餐&#xff0c;SetmealDish表示套餐對應的菜品。 交互過程&#xff1a; 前端請求&a…