bayi 2 anni fa
parent
commit
e4b4201909
2 ha cambiato i file con 21 aggiunte e 12 eliminazioni
  1. 17 10
      pages/reading/index.js
  2. 4 2
      pages/reading/index.wxml

+ 17 - 10
pages/reading/index.js

@@ -58,7 +58,6 @@ Page({
   onLoad(options) {
     let videoId = options.videoId
     this.getreadInfo(videoId, options.reset)
-    console.log(options, 'options');
     this.setData({
       readingReset: options.reset || false,
       readingType: options.readingType || 'public',
@@ -136,9 +135,11 @@ Page({
     } else {
       this.innerAudioContext.src = videoInfo.userRead.originVideo
       this.innerAudioContext.onEnded(res => {
+        console.log("138innerAudioContext触发的");
         this.finishRecord()
       })
       this.innerAudioContext.onStop((res) => {
+        console.log("143innerAudioContext触发的");
         this.finishRecord()
       });
     }
@@ -156,7 +157,7 @@ Page({
       this.finishRecord()
       return
     }
-    if (this.data.readingReset) {
+    if (!this.data.readingReset) {
       this.getHeight()
     }
     this.stopMediaState()
@@ -234,6 +235,9 @@ Page({
         console.log("fail=============  " + res);
       },
     });
+    recorderManager.onError(res => {
+      console.log(res, 'rrrrrsse');
+    })
     //监听录音开始事件
     recorderManager.onStart(() => {});
     //监听录音结束事件
@@ -417,7 +421,9 @@ Page({
       }
       this.videoContext.play()
     }
-    this.startRecording()
+    /*    if (!this.data.readingReset) {
+         this.startRecording()
+       } */
   },
   // 控制视频或音频的播放状态
   async playMediaState() {
@@ -455,17 +461,19 @@ Page({
       this.rowH = rect.height
     }).exec()
   },
-  /**
-   * 生命周期函数--监听页面卸载
-   */
+  onHide() {
+    wsEngine.reset()
+    if (this.innerAudioContext) {
+      this.innerAudioContext.stop()
+    }
+    this.finishRecord()
+  },
   onUnload() {
     wsEngine.reset()
-    recorderManager.stop();
     if (this.innerAudioContext) {
       this.innerAudioContext.stop()
     }
-    clearTimeout(this.setTimeoutObj)
-    clearInterval(this.stl)
+    this.finishRecord()
   },
   creatShare() {
     return new Promise((resolve, reject) => {
@@ -547,7 +555,6 @@ Page({
                       wx.canvasToTempFilePath({
                         canvas: canvas,
                         success(res) {
-                          console.log(wx.getStorageSync('shareVideoId'));
                           resolve({
                             title: '我的新作品发布啦,快来捧场点赞!',
                             path: `/pages/pkPage/index?videoId=${wx.getStorageSync('shareVideoId')}&uid=${wx.getStorageSync('uid')}`,

+ 4 - 2
pages/reading/index.wxml

@@ -2,9 +2,11 @@
   <block wx:if="{{!videoInfo.userReadExtend||videoInfo.userReadExtend.resourcesType==0}}">
     <image src="{{videoInfo.userRead.coverImg}}" class='poster' wx:if="{{!state&&!exampleState}}" bindtap="videoPlay" />
     <video id="myVideo" src="{{state?videoInfo.userRead.originVideo:videoInfo.userRead.videoPath}}" bindended='videoEnd'
-      show-center-play-btn="{{readingReset}}" controls="{{false}}" muted="{{muted}}"></video>
+      show-center-play-btn="{{readingReset}}" controls="{{!state&&!readingReset}}" muted="{{muted}}"></video>
+    <!-- 这个用于预加载资源 -->
+    <video src="{{videoInfo.userRead.originVideo}}" style="display: none;"></video>
   </block>
-  <view class="audio" wx:else>
+  <view class=" audio" wx:else>
     <image src="{{videoInfo.userRead.coverImg}}" class="audioBg" mode="" />
     <view class="mask"></view>
     <view class="audioPlay" style="background-image: url({{videoInfo.userReadExtend.backgroundVirtualImg}});">