123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- Page({
- data: {
- fullScreenBtn: false,
- playBtn: false,
- gesture: true,
- muted: true,
- gesture: false,
- centerBtn: false,
- recordFlag: 0,
- recordSource: '',
- videoCtr: 'recordingVideoEnd',
- btnFlag: false,
- microphonePng: '../../../static/image/microphone.png',
- recordingGif: '../../../static/image/readingNow.gif',
- videoUrl:'http://efunvideo.ai160.com/vs2m/001/00103075/00103075012/00103075012.m3u8',
- readingText: '江南好,\n风景旧曾谙。\n日出江花红胜火,\n春来江水绿如蓝。\n能不忆江南?\n江南好\n江南好,\n风景旧曾谙。\n日出江花红胜火,\n春来江水绿如蓝。\n能不忆江南?\n江南好\n江南好,\n风景旧曾谙。\n日出江花红胜火,\n春来江水绿如蓝。\n能不忆江南?\n江南好\n江南好,\n风景旧曾谙。\n日出江花红胜火,\n春来江水绿如蓝。\n能不忆江南?\n江南好\n江南好,\n风景旧曾谙。\n日出江花红胜火,\n春来江水绿如蓝。\n能不忆江南?\n'
- },
- onLoad: function (option) {
- this.videoCtx = null;
- if (option.title) {
- wx.setNavigationBarTitle({
- title: option.title
- })
- }
- this.recorderManager = wx.getRecorderManager();
-
-
-
- this.recorderManager.onStart(() => {
-
-
- console.log('recorder start')
- })
-
- this.recorderManager.onStop((res) => {
- this.videoCtx.stop();
- console.log('recorder stop', res)
- const recordFile = res.tempFilePath;
- this.setData({
- recordFlag: 0,
- recordSource: recordFile,
- btnFlag: true
- })
- })
- },
-
-
-
-
- recordingVideoEnd:function(){
-
- if (this.data.recordFlag === 0) {
- this.recordStop();
- this.setData({
- videoCtr : 'playingVideoEnd'
- })
- }
-
- if (this.data.recordFlag === 1) {
-
- }
- },
-
- playingVideoEnd:function(){
- this.innerAudioContext.stop();
- },
-
- audioRecord: function () {
- console.log(this.data.recordFlag)
- if (this.data.recordFlag === 0) {
-
-
- this.videoComplete();
- }
-
- if (this.data.recordFlag === 1) {
- this.recordStop();
- }
- },
-
-
- recordStart: function () {
- console.log('录音开始');
- const options = {
- duration: 600000,
- sampleRate: 44100,
- numberOfChannels: 1,
- encodeBitRate: 192000,
- format: 'mp3',
- frameSize: 50
- }
- this.recorderManager.start(options);
- },
-
- recordStop: function () {
- this.recorderManager.stop();
- },
-
- audioPlay: function () {
- console.log('音频播放');
- this.innerAudioContext = wx.createInnerAudioContext();
- this.innerAudioContext.onError((res) => {
-
- })
- this.innerAudioContext.src = this.data.recordSource;
- console.log(this.innerAudioContext.src);
- this.videoCtx.play();
- this.innerAudioContext.play();
- },
-
- videoComplete: function(){
- let videoUrl = 'http://efunimgs.ai160.com/ott/test/002tPr2Xlx07oP7B4ro40104120022hP0k010.mp4';
- this.setData({
- videoUrl: videoUrl,
- recordFlag: 1
- },()=>{
- this.videoCtx = wx.createVideoContext('myVideo', this);
- this.videoCtx.play();
- this.recordStart();
- })
- }
- })
|