jwyu 2 жил өмнө
parent
commit
eb8438fc11

+ 15 - 2
pages-voice/addVoice.vue

@@ -178,9 +178,20 @@ export default {
             success() {}
             success() {}
         })
         })
         this.listenVoice()
         this.listenVoice()
-        this.listenAudio()
+        
         this.getOptionsList()
         this.getOptionsList()
     },
     },
+    onShow(){
+        innerAudioContext = uni.createInnerAudioContext()
+        this.listenAudio()
+    },
+    onHide(){
+        innerAudioContext.destroy()
+        this.temAudio.paused=true
+    },
+    onUnload(){
+        innerAudioContext.destroy()
+	},
     methods: {
     methods: {
         //录音事件
         //录音事件
         listenVoice(){
         listenVoice(){
@@ -286,7 +297,9 @@ export default {
 
 
         //点击播放\暂停音频
         //点击播放\暂停音频
         handlePlayAudio(){
         handlePlayAudio(){
-            if(innerAudioContext.url==this.temAudio.url){
+            console.log(innerAudioContext.src);
+            if(innerAudioContext.src==this.temAudio.url){
+                console.log('同一个音频');
                 if(innerAudioContext.paused){
                 if(innerAudioContext.paused){
                     innerAudioContext.play()
                     innerAudioContext.play()
                 }else{
                 }else{

+ 11 - 1
pages/voice/voice.vue

@@ -127,11 +127,21 @@ export default {
         if(!this.isAuth){
         if(!this.isAuth){
             this.getVoiceList()
             this.getVoiceList()
         }
         }
-        // this.innerAudioContext=uni.createInnerAudioContext()
+        innerAudioContext=uni.createInnerAudioContext();
         this.listenAudio()
         this.listenAudio()
     },
     },
+    onHide(){
+        innerAudioContext.destroy()
+        this.temAudio.id=0
+        this.temAudio.paused=true
+        this.temAudio.curTime=''
+    },
     onUnload(){
     onUnload(){
 		uni.$off('addVoiceSuccess')
 		uni.$off('addVoiceSuccess')
+        innerAudioContext.destroy()
+        this.temAudio.id=0
+        this.temAudio.paused=true
+        this.temAudio.curTime=''
 	},
 	},
     onShareAppMessage({from,target}) {
     onShareAppMessage({from,target}) {
         console.log(from,target);
         console.log(from,target);