page/API/voice/voice.js
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
var util = require('../../../util/util.js')
var playTimeInterval
Page({
data: {
recording: false,
playing: false,
hasRecord: false,
recordTime: 0,
playTime: 0,
formatedRecordTime: '00:00:00',
formatedPlayTime: '00:00:00'
},
startRecord: function () {
this.setData({ recording: true })
var that = this
var interval = setInterval(function () {
that.data.recordTime += 1
that.setData({
formatedRecordTime: util.formatTime(that.data.recordTime)
})
}, 1000)
wx.startRecord({
success: function (res) {
that.setData({
hasRecord: true,
tempFilePath: res.tempFilePath,
formatedPlayTime: util.formatTime(that.data.playTime)
})
},
complete: function () {
that.setData({ recording: false })
clearInterval(interval)
}
})
},
stopRecord: function () {
wx.stopRecord()
},
playVoice: function () {
var that = this
playTimeInterval = setInterval(function () {
that.data.playTime += 1
that.setData({
playing: true,
formatedPlayTime: util.formatTime(that.data.playTime)
})
}, 1000)
wx.playVoice({
filePath: this.data.tempFilePath,
success: function () {
clearInterval(playTimeInterval)
that.data.playTime = 0
that.setData({
playing: false,
formatedPlayTime: util.formatTime(that.data.playTime)
})
}
})
后面还有 30 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。