Browse Source

开发切换示范朗读

bayi 2 years ago
parent
commit
94c32e9800

+ 12 - 2
components/videoPreview/index.js

@@ -281,12 +281,22 @@ Component({
         url
       })
     },
-    // pkPage页面控制播放按钮
+    // pkPage页面示范朗读
     changeRead() {
       this.setData({
         workType: this.data.workType == 'videoPath' ? 'example' : 'videoPath',
       })
-      console.log(this.data.workType);
+      if (this.data.videoInfo.userReadExtend.resourcesType == 1) {
+        this.triggerEvent('pkPageAudio', {
+          currentTarget: {
+            dataset: {
+              id: this.data.videoInfoCopy.userRead.id,
+              audio: this.data.workType == 'videoPath' ? this.data.videoInfoCopy.userRead.audioPath : this.data.videoInfoCopy.example.audioPath,
+              isPkPage: true
+            }
+          }
+        })
+      }
     },
     // 统计作品播放次数
     async submitPlayLog(userReadId) {

+ 1 - 1
components/videoPreview/index.wxml

@@ -65,7 +65,7 @@
   <!-- 音频 -->
   <view class="workContent" wx:else>
     <view class="audioBox" bindtap="audioPlay">
-      <image src=" {{videoInfoCopy.userReadExtend.backgroundVirtualImg}}" class="audioBg" mode="aspectFill" />
+      <image src="{{videoInfoCopy.userReadExtend.backgroundVirtualImg}}" class="audioBg" mode="aspectFill" />
       <view class="titleBox">
         <view class="textOver" wx:for="{{videoInfoCopy.userRead.title}}" wx:key="index">
           {{item}}

+ 1 - 0
components/worksList/index.js

@@ -28,6 +28,7 @@ Component({
                   userReadId: res.dataset.id,
                   playStopTime: 1000
                 })
+                // 0视频1音频
                 if (res.dataset.type == 0) {
                   this.resetAudio();
                   this.setData({

+ 4 - 1
mixins/video.js

@@ -45,7 +45,10 @@ module.exports = Behavior({
       currentTarget
     }) {
       if (this.data.currentId == currentTarget.dataset.id) {
-        return this.resetAudio()
+        this.resetAudio()
+        if (!currentTarget.dataset.isPkPage) {
+          return
+        }
       }
       if (this.innerAudioContext) {
         this.resetAudio()

+ 23 - 1
pages/pkPage/index.js

@@ -12,7 +12,9 @@ Page({
     videoInfo: '',
     videoId: '',
     isShare: false,
-    recordList: []
+    recordList: [],
+    // 播放的音频
+    audioPath: ''
   },
   /**
    * 生命周期函数--监听页面加载
@@ -32,11 +34,31 @@ Page({
     wx.setNavigationBarTitle({
       title: videoInfo.userRead.title
     })
+    if (videoInfo.userReadExtend.resourcesType == 1) {
+      this.playAudio({
+        currentTarget: {
+          dataset: {
+            id: videoId,
+            audio: videoInfo.userRead.audioPath
+          }
+        }
+      })
+    }
     this.setData({
       videoInfo,
+      audioPath: videoInfo.userRead.audioPath,
       currentId: videoId
     })
   },
+  // pkPage页面示范朗读
+  pkPageAudio({
+    detail
+  }) {
+    this.setData({
+      audioPath: detail.currentTarget.dataset.audio,
+    })
+    this.playAudio(detail)
+  },
   async getPkRecord() {
     let recordList = await getPkRecord({
       userReadId: this.data.videoId

+ 2 - 1
pages/pkPage/index.wxml

@@ -2,7 +2,8 @@
 <view class="pkBox">
   <videoPreview wx:if="{{videoInfo}}" videoInfo="{{videoInfo}}" currentId="{{currentId}}"
     data-id="{{videoInfo.userRead.id}}" currentTime="{{currentTime}}" sliderValue="{{sliderValue}}"
-    bind:playVideo="playVideo" bind:playAudio="playAudio" bind:setSeek="setSeek" bind:openComment="openComment"
+    bind:playVideo="playVideo" bind:playAudio="playAudio" bind:pkPageAudio="pkPageAudio"
+    data-audio="{{audioPath}}" bind:setSeek="setSeek" bind:openComment="openComment"
     videoType='pk' />
   <!-- 挑战记录列表 -->
   <view class="pkRecord">

+ 0 - 1
pages/reading/index.js

@@ -185,7 +185,6 @@ Page({
         console.log("143innerAudioContext触发的");
       });
     }
-
   },
   // 开始录制
   setCountDown() {