jwyu 2 年之前
父节点
当前提交
4c23c45e17
共有 2 个文件被更改,包括 6 次插入4 次删除
  1. 1 0
      pages-voice/addVoice.vue
  2. 5 4
      pages/voice/voice.vue

+ 1 - 0
pages-voice/addVoice.vue

@@ -316,6 +316,7 @@ export default {
             })
             })
             innerAudioContext.onEnded(()=>{
             innerAudioContext.onEnded(()=>{
                 console.log('录音播放自然结束');
                 console.log('录音播放自然结束');
+                this.temAudio.curTime=this.temAudio.duration
                 this.temAudio.paused=true
                 this.temAudio.paused=true
                 innerAudioContext.src=''
                 innerAudioContext.src=''
             })
             })

+ 5 - 4
pages/voice/voice.vue

@@ -74,7 +74,7 @@ import {apiVoiceList,apiVoiceSectionList,apiVoicePlayRecord,apiVoiceDel} from '@
 import {apiGetSceneToParams} from '@/api/common'
 import {apiGetSceneToParams} from '@/api/common'
 import noAuth from './components/noAuth.vue'
 import noAuth from './components/noAuth.vue'
 const moment=require('@/utils/moment-with-locales.min')
 const moment=require('@/utils/moment-with-locales.min')
-const innerAudioContext = uni.createInnerAudioContext();//播放音频实例
+let innerAudioContext = uni.createInnerAudioContext();//播放音频实例
 export default {
 export default {
     components:{
     components:{
         noAuth
         noAuth
@@ -288,7 +288,7 @@ export default {
         handlePlay(item){
         handlePlay(item){
             
             
             //没有初始化时
             //没有初始化时
-            if(!innerAudioContext.src){
+            if(this.temAudio.id==0){
                 this.listenAudio()
                 this.listenAudio()
                 this.temAudio.id=item.BroadcastId
                 this.temAudio.id=item.BroadcastId
                 this.temAudio.duration=item.VoicePlaySeconds
                 this.temAudio.duration=item.VoicePlaySeconds
@@ -326,13 +326,14 @@ export default {
             })
             })
             innerAudioContext.onEnded(()=>{
             innerAudioContext.onEnded(()=>{
                 console.log('录音播放自然结束');
                 console.log('录音播放自然结束');
-                this.temAudio.paused=true
                 setTimeout(() => {
                 setTimeout(() => {
+                    this.temAudio.paused=true
                     this.temAudio.id=0
                     this.temAudio.id=0
+                    innerAudioContext.src=''
                 }, 100);
                 }, 100);
-                innerAudioContext.src=''
             })
             })
             innerAudioContext.onTimeUpdate(()=>{
             innerAudioContext.onTimeUpdate(()=>{
+                // console.log('时间更新');
                 this.temAudio.curTime=parseInt(this.temAudio.duration)-parseInt(innerAudioContext.currentTime)
                 this.temAudio.curTime=parseInt(this.temAudio.duration)-parseInt(innerAudioContext.currentTime)
             })
             })
         },
         },