parent
6c4933a371
commit
63993fcf27
@ -0,0 +1,146 @@
|
||||
// miniprogram/pages/Dubbing/Dubbing.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
|
||||
data: {
|
||||
isSpeaking: false,//是否正在说话
|
||||
voices: [],//音频数组:
|
||||
muted:false
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
this.videoContext = wx.createVideoContext('myVideo');
|
||||
|
||||
// var time = this.videoContext.duration;
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
// this.videoContext = wx.createVideoContext('myVideo');
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
},
|
||||
endDub() {
|
||||
this.videoContext.stop();
|
||||
wx.stopRecord();
|
||||
wx.navigateTo({
|
||||
url: '../previewWork/previewWork',
|
||||
})
|
||||
|
||||
},
|
||||
//预览素材
|
||||
playingFodder:function(){
|
||||
this.setData({
|
||||
muted:false
|
||||
})
|
||||
this.videoContext.play();
|
||||
|
||||
},
|
||||
|
||||
// 开始录音,
|
||||
startDub: function () {
|
||||
/*
|
||||
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();
|
||||
//speaking.call(this);
|
||||
this.setData({
|
||||
isSpeaking:true,
|
||||
muted: 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;
|
||||
// this.setData({
|
||||
// wfilePath: savedFilePath
|
||||
// });
|
||||
console.log(getApp().globalData.workPath);
|
||||
},
|
||||
}),
|
||||
wx.showToast({
|
||||
title: '录音成功',
|
||||
icon:'success',
|
||||
duration:200
|
||||
})
|
||||
},
|
||||
fail:function(res){
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '录音出错'
|
||||
})
|
||||
},
|
||||
funended: function () {
|
||||
console.log('eeee');
|
||||
wx.stopRecord();// 结束录音
|
||||
wx.navigateTo({//视频播放完成自动跳转到预览页面
|
||||
url: '../previewWork/previewWork',
|
||||
})
|
||||
}
|
||||
});
|
||||
/*
|
||||
setTimeout(function () {
|
||||
wx.stopRecord();// 结束录音
|
||||
wx.navigateTo({//视频播放完成自动跳转到预览页面
|
||||
url: '../previewWork/previewWork',
|
||||
})
|
||||
},time);
|
||||
*/
|
||||
},
|
||||
})
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<!--miniprogram/pages/Dubbing/Dubbing.wxml-->
|
||||
<view>
|
||||
<video id="myVideo" src="cloud://dunning-bar-enr-3e46z.6475-dunning-bar-enr-3e46z-1300499016/huaizhugege-erkang.mp4"muted ="{{muted}}" binended = "funended" controls ="{{false}}" show-play-btn ="{{false}}"show-fullscreen-btn = "{{false}}" show-center-play-btn="{{false}}" style="width: 400px; height: 200px;"></video>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<button bindtap="playingFodder">预览素材</button>
|
||||
<button bindtap="startDub">开始录音</button>
|
||||
<button bindtap="endDub">完成录音</button>
|
||||
</view>
|
@ -0,0 +1 @@
|
||||
/* miniprogram/pages/Dubbing/Dubbing.wxss */
|
Loading…
Reference in new issue