You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
2.4 KiB

// miniprogram/pages/txtDubbing/txtDubbing.js
Page({
/**
* 页面的初始数据
*/
data: {
isSpeaking: false,//是否正在说话
list: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.request({//获取文本内容
url: 'https://6475-dunning-bar-enr-3e46z-1300499016.tcb.qcloud.la/txt/%E7%99%BD%E9%9B%AA%E5%85%AC%E4%B8%BB.txt?sign=818727931597dc72ea2db421b0577e3b&t=1578100879',
header: { 'cntent-type': 'application/json;charset=utf-8' },
success: (res) => {
console.log(res.data);
this.setData({
list: res.data,
});
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
// 开始录音,
startDub: function () {
this.setData({
isSpeaking: true,
})
wx.startRecord({
success: function (res) {
var tempFilepath = res.tempFilePath;
wx.saveFile({
tempFilePath: tempFilepath,
success: function (res) {
var savedFilepath = res.savedFilePath;
getApp().globalData.workPath = savedFilepath;
console.log(getApp().globalData.workPath);
},
}),
wx.showToast({
title: '录音成功',
icon: 'success',
duration: 200
})
},
fail: function (res) {
wx.showModal({
title: '提示',
content: '录音出错'
})
},
});
},
//重新录音
reDub: function () {
wx.stopRecord();
this.setData({
isSpeaking: false
});
wx.showModal({
title: '提示',
content: '重新录音'
});
this.startDub();
},
//结束录音
endDub: function () {
console.log('录音结束');
wx.stopRecord();
wx.navigateTo({
url: '../previewTxtWork/previewTxtWork?list=' + this.data.list,
})
},
})