|
|
@ -4,27 +4,25 @@ Page({
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
isSpeaking: false,//是否正在说话
|
|
|
|
isSpeaking: false,//是否正在说话
|
|
|
|
voices: [],//音频数组:
|
|
|
|
voices: [],//音频数组:
|
|
|
|
muted:false
|
|
|
|
muted: false
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
onLoad: function (options) {
|
|
|
|
this.videoContext = wx.createVideoContext('myVideo');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var time = this.videoContext.duration;
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
onReady: function () {
|
|
|
|
// this.videoContext = wx.createVideoContext('myVideo');
|
|
|
|
this.videoContext = wx.createVideoContext('myVideo');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -68,79 +66,82 @@ Page({
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
endDub() {
|
|
|
|
|
|
|
|
this.videoContext.stop();
|
|
|
|
|
|
|
|
wx.stopRecord();
|
|
|
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
|
|
|
url: '../previewWork/previewWork',
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
//预览素材
|
|
|
|
//预览素材
|
|
|
|
playingFodder:function(){
|
|
|
|
playingFodder: function () {
|
|
|
|
this.setData({
|
|
|
|
this.setData({
|
|
|
|
muted:false
|
|
|
|
muted: false
|
|
|
|
})
|
|
|
|
})
|
|
|
|
this.videoContext.play();
|
|
|
|
this.videoContext.play();
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 开始录音,
|
|
|
|
// 开始录音,
|
|
|
|
startDub: function () {
|
|
|
|
startDub: function () {
|
|
|
|
/*
|
|
|
|
this.videoContext.seek(0);
|
|
|
|
this.videoContext.src = 'cloud://dunning-bar-enr-3e46z.6475-dunning-bar-enr-3e46z-1300499016/huaizhugege-erkang.mp4' ;
|
|
|
|
|
|
|
|
var time = this.videoContext.duration;
|
|
|
|
|
|
|
|
console.log(time);
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.videoContext.seek(0);
|
|
|
|
|
|
|
|
this.videoContext.play();
|
|
|
|
this.videoContext.play();
|
|
|
|
//speaking.call(this);
|
|
|
|
//speaking.call(this);
|
|
|
|
this.setData({
|
|
|
|
this.setData({
|
|
|
|
isSpeaking:true,
|
|
|
|
isSpeaking: true,
|
|
|
|
muted: true,
|
|
|
|
muted: true,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
wx.startRecord({
|
|
|
|
wx.startRecord({
|
|
|
|
success:function(res){
|
|
|
|
success: function (res) {
|
|
|
|
var tempFilepath=res.tempFilePath;
|
|
|
|
var tempFilepath = res.tempFilePath;
|
|
|
|
wx.saveFile({
|
|
|
|
wx.saveFile({
|
|
|
|
tempFilePath: tempFilepath,
|
|
|
|
tempFilePath: tempFilepath,
|
|
|
|
success:function(res){
|
|
|
|
success: function (res) {
|
|
|
|
var savedFilepath=res.savedFilePath;
|
|
|
|
var savedFilepath = res.savedFilePath;
|
|
|
|
getApp().globalData.workPath = savedFilepath;
|
|
|
|
getApp().globalData.workPath = savedFilepath;
|
|
|
|
// this.setData({
|
|
|
|
// this.setData({
|
|
|
|
// wfilePath: savedFilePath
|
|
|
|
// wfilePath: savedFilePath
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
console.log(getApp().globalData.workPath);
|
|
|
|
console.log(getApp().globalData.workPath);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
wx.showToast({
|
|
|
|
wx.showToast({
|
|
|
|
title: '录音成功',
|
|
|
|
title: '录音成功',
|
|
|
|
icon:'success',
|
|
|
|
icon: 'success',
|
|
|
|
duration:200
|
|
|
|
duration: 200
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
fail:function(res){
|
|
|
|
fail: function (res) {
|
|
|
|
wx.showModal({
|
|
|
|
wx.showModal({
|
|
|
|
title: '提示',
|
|
|
|
title: '提示',
|
|
|
|
content: '录音出错'
|
|
|
|
content: '录音出错'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
funended: function () {
|
|
|
|
|
|
|
|
console.log('eeee');
|
|
|
|
|
|
|
|
wx.stopRecord();// 结束录音
|
|
|
|
|
|
|
|
wx.navigateTo({//视频播放完成自动跳转到预览页面
|
|
|
|
|
|
|
|
url: '../previewWork/previewWork',
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
/*
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
},
|
|
|
|
wx.stopRecord();// 结束录音
|
|
|
|
|
|
|
|
wx.navigateTo({//视频播放完成自动跳转到预览页面
|
|
|
|
funended: function () {
|
|
|
|
url: '../previewWork/previewWork',
|
|
|
|
console.log('录音结束');
|
|
|
|
})
|
|
|
|
wx.stopRecord();// 结束录音
|
|
|
|
},time);
|
|
|
|
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',
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|