//index.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 < res.fileList.length; i++) {
//格式化时间
var createTime = new Date(res.fileList[i].createTime)
//将音频大小B转为KB
var size = (res.fileList[i].size / 1024).toFixed(2);
var voice = { filePath: res.fileList[i].filePath, createTime: createTime, size: size };
console.log("文件路径: " + res.fileList[i].filePath)
console.log("文件时间: " + createTime)
console.log("文件大小: " + size)
voices = voices.concat(voice);
}
_this.setData({
voices: voices
})
}
})
},
fail: function (res) {
//录音失败
wx.showModal({
title: '提示',
content: '录音的姿势不对!',
showCancel: false,
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
return
}
}
})
}
})
},
//手指抬起
touchup: function () {
console.log("手指抬起了...")
this.setData({
isSpeaking: false,
})
clearInterval(this.timer)
wx.stopRecord()
},
//点击播放录音
gotoPlay: function (e) {
var filePath = e.currentTarget.dataset.key;
//点击开始播放
wx.showToast({
title: '开始播放',
icon: 'success',
duration: 1000
})
wx.playVoice({
filePath: filePath,
success: function () {
wx.showToast({
title: '播放结束',
icon: 'success',
duration: 1000
})
}
})
}
})
//麦克风帧动画
function speaking() {
var _this = this;
//话筒帧动画
var i = 1;
this.timer = setInterval(function () {
i++;
i = i % 5;
_this.setData({
j: i
})
}, 200);
}
没有合适的资源?快使用搜索试试~ 我知道了~
微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)
共13个文件
png:5个
js:3个
wxss:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 144 浏览量
2022-06-19
18:58:10
上传
评论 1
收藏 20KB ZIP 举报
温馨提示
微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图)微信小程序开发之录音机 音频播放 动画 (真机可
资源推荐
资源详情
资源评论
收起资源包目录
微信小程序开发之录音机 音频播放 动画 (真机可用)(源代码+截图).zip (13个子文件)
微信小程序开发之录音机 音频播放 动画 (真机可用)
Record
images
voice_icon_speech_sound_4.png 2KB
voice_icon_speech_sound_1.png 2KB
voice_icon_speech_sound_3.png 2KB
voice_icon_speech_sound_5.png 2KB
voice_icon_speech_sound_2.png 2KB
app.json 235B
pages
index
index.js 3KB
index.json 2B
index.wxss 988B
index.wxml 1KB
app.wxss 204B
app.js 719B
utils
util.js 481B
共 13 条
- 1
资源评论
荣华富贵8
- 粉丝: 123
- 资源: 7649
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- database-project-massunaAi笔记
- 2%EF%BC%9A%E9%99%95%E8%A5%BF%E
- yyspdz62_944.apk
- SAP公司间采购EDI配置-如何触发自动MIRO.docx
- python197基于图像识别的仪表实时监控系统.rar
- python196基于循环神经网络的情感分类系统.rar
- I2C驱动SHT30温湿度传感器和LCD12864使用例程(RSCG12864B)
- python193中学地理-中国的江河湖泊教学网(django).rar
- python191基于时间序列分析的大气污染预测软件(django).rar
- python190基于人脸识别智能化小区门禁管理系统.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功