微信小程序?qū)崿F(xiàn)錄音Record功能
更新時(shí)間:2021年05月09日 09:59:56 作者:勘察加熊人
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)錄音Record功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了微信小程序?qū)崿F(xiàn)錄音Record功能的具體代碼,供大家參考,具體內(nèi)容如下
布局
<!--pages/record/record.wxml--> <view> <button class="tui-menu-list" bindtap="startRecordAac" type="primary">錄音開始(aac)</button> <button class="tui-menu-list" bindtap="startRecordMp3" type="primary">錄音開始(mp3)</button> <button class="tui-menu-list" bindtap="stopRecord" type="primary">錄音結(jié)束</button> <button class="tui-menu-list" bindtap="playRecord" type="primary">播放錄音</button> </view>
樣式:
/* pages/record/record.wxss */ .tui-menu-list{ flex-direction: row; margin: 20rpx; padding: 20rpx; }
開始錄音和停止錄音
// pages/record/record.js Page({ /** * 頁面的初始數(shù)據(jù) */ data: { }, onLoad:function (options) { var that = this this.recorderManager = wx.getRecorderManager(); this.recorderManager.onError(function () { that.tip("錄音失敗!"); }) this.recorderManager.onStop(function (res) { that.setData({ src:res.tempFilePath }) console.log(res.tempFilePath) that.tip("錄音完成!") }) this.innerAudioContext = wx.createInnerAudioContext() this.innerAudioContext.onError((res) =>{ that.tip("播放錄音失敗!") }) }, //提示 tip:function (msg) { wx.showModal({ cancelColor: 'cancelColor', title:'提示', content:msg, showCancel:false }) }, //錄制aac startRecordAac:function () { this.recorderManager.start({ format:'aac' }) }, //錄制mp3 startRecordMp3:function () { this.recorderManager.start({ format:'mp3' }) }, //停止錄音 stopRecord:function () { this.recorderManager.stop() }, //播放錄音 playRecord:function () { var that = this var src = this.data.src if (src='') { this.tip('請先錄音') return } this.innerAudioContext.src = this.data.src this.innerAudioContext.play() } })
效果圖:
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- 微信小程序用戶后臺定位及錄音授權(quán)及請求示例
- 微信小程序?qū)崿F(xiàn)錄音與音頻播放功能
- 微信小程序錄音實(shí)現(xiàn)功能并上傳(使用node解析接收)
- 微信小程序?qū)崿F(xiàn)錄音功能
- 微信小程序?qū)崿F(xiàn)錄音時(shí)的麥克風(fēng)動畫效果實(shí)例
- 微信小程序錄音文件格式silk遇到的問題及解決方法
- 微信小程序錄音與播放錄音功能
- 微信小程序開發(fā)之錄音機(jī) 音頻播放 動畫實(shí)例 (真機(jī)可用)
- 微信小程序-圖片、錄音、音頻播放、音樂播放、視頻、文件代碼實(shí)例
- 微信小程序?qū)崿F(xiàn)錄音播放錄音功能
相關(guān)文章
JS+CSS實(shí)現(xiàn)仿支付寶菜單選中效果代碼
這篇文章主要介紹了JS+CSS實(shí)現(xiàn)仿支付寶菜單選中效果代碼,涉及JavaScript基于鼠標(biāo)事件動態(tài)設(shè)置頁面css樣式的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09微信小程序?qū)崿F(xiàn)客服功能(客服消息)的全過程
在最近做的微信小程序中需要實(shí)現(xiàn)一個自帶的客服功能,下面這篇文章主要給大家介紹了關(guān)于微信小程序?qū)崿F(xiàn)客服功能(客服消息)的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-12-12JS實(shí)現(xiàn)判斷對象是否為空對象的5種方法
這篇文章主要介紹了JS實(shí)現(xiàn)判斷對象是否為空對象的5種方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-04-04js實(shí)現(xiàn)隨機(jī)點(diǎn)名器精簡版
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)隨機(jī)點(diǎn)名器的精簡版,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-06-06