微信小程序实现录音功能

这篇文章主要为大家详细介绍了微信小程序实现录音功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了微信小程序录音功能的具体代码,供大家参考,具体内容如下

release.wxml

       存储路径:{{item.filePath}}存储时间:{{item.createTime}}音频大小:{{item.size}}KB  

release.wxss

 /* pages/index/release/release.wxss */ .microphone{ position:fixed; left: 250rpx; bottom: 0; height: 240rpx; width: 240rpx; border-radius: 20rpx; margin: 50% auto; background: #26A5FF; } .item-style{ margin-top: 30rpx; margin-bottom: 30rpx; } .text-style{ text-align: center; } .record-style{ position: fixed; bottom: 0; left: 0; height: 120rpx; width: 100%; } .btn-style{ margin-left: 30rpx; margin-right: 30rpx; } .sound-style{ position: absolute; width: 74rpx; height:150rpx; margin-top: 45rpx; margin-left: 83rpx; } .board { overflow: hidden; border-bottom: 2rpx solid #26A5FF; } /*列布局*/ .cell{ display: flex; margin: 20rpx; } .cell-hd{ margin-left: 10rpx; color: #885A38; } .cell .cell-bd{ flex:1; position: relative; } /**只显示一行*/ .date{ font-size: 30rpx; text-overflow: ellipsis; white-space:nowrap; overflow:hidden; } 

release.js

 // pages/index/release/release.js var app = getApp() Page({ data: { j: 1,//帧动画初始图片 isSpeaking: false,//是否正在说话 voices: [],//音频数组 }, onLoad: function () { }, //手指按下 touchdown: function () { console.log("手指按下了...") console.log("new date : " + new Date) var _this = this; speaking.call(this); this.setData({ isSpeaking: true }) //开始录音 wx.startRecord({ success: function (res) { //临时路径,下次进入小程序时无法正常使用 var tempFilePath = res.tempFilePath console.log("tempFilePath: " + tempFilePath) //持久保存 wx.saveFile({ tempFilePath: tempFilePath, success: function (res) { //持久路径 //本地文件存储的大小限制为 100M var savedFilePath = res.savedFilePath console.log("savedFilePath: " + savedFilePath) } }) wx.showToast({ title: '恭喜!录音成功', icon: 'success', duration: 1000 }) //获取录音音频列表 wx.getSavedFileList({ success: function (res) { var voices = []; for (var i = 0; i 

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持html中文网。

以上就是微信小程序实现录音功能的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » JavaScript 教程