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.

147 lines
2.7 KiB

5 years ago
// miniprogram/pages/Dubbing/Dubbing.js
Page({
/**
* 页面的初始数据
*/
5 years ago
data: {
isSpeaking: false,//是否正在说话
voices: [],//音频数组:
muted: false
5 years ago
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
this.videoContext = wx.createVideoContext('myVideo');
5 years ago
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
5 years ago
//预览素材
playingFodder: function () {
5 years ago
this.setData({
muted: false
5 years ago
})
this.videoContext.play();
},
// 开始录音,
5 years ago
startDub: function () {
this.videoContext.seek(0);
5 years ago
this.videoContext.play();
//speaking.call(this);
this.setData({
isSpeaking: true,
5 years ago
muted: true,
})
wx.startRecord({
success: function (res) {
var tempFilepath = res.tempFilePath;
5 years ago
wx.saveFile({
tempFilePath: tempFilepath,
success: function (res) {
var savedFilepath = res.savedFilePath;
5 years ago
getApp().globalData.workPath = savedFilepath;
// this.setData({
// wfilePath: savedFilePath
// });
5 years ago
console.log(getApp().globalData.workPath);
},
}),
wx.showToast({
title: '录音成功',
icon: 'success',
duration: 200
})
5 years ago
},
fail: function (res) {
5 years ago
wx.showModal({
title: '提示',
content: '录音出错'
})
},
});
},
funended: function () {
console.log('录音结束');
wx.stopRecord();// 结束录音
wx.navigateTo({//视频播放完成自动跳转到预览页面
url: '../previewWork/previewWork',
})
},
//重新录音
reDub: function () {
wx.stopRecord();
this.setData({
isSpeaking: false
});
wx.showModal({
title: '提示',
content: '重新录音'
});
this.startDub();
},
//结束录音
endDub: function () {
console.log('录音结束');
this.videoContext.stop();
wx.stopRecord();
wx.navigateTo({
url: '../previewWork/previewWork',
})
},
5 years ago
})