Commit a42fe477303591281b9865c72b28733f146866ba

Authored by xwenliang
1 parent cc2425f4

feat: reset audio when destroy list

README.md
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 - [x] 内容安全问题处理 10 - [x] 内容安全问题处理
11 - https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.msgSecCheck.html 11 - https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/sec-check/security.msgSecCheck.html
12 12
13 -- [ ] 从列表页返回后应该关闭正在播放的列表页语音 13 +- [x] 从列表页返回后应该关闭正在播放的列表页语音
14 14
15 -- [ ] 时间长了本地缓存文件失效后应当清除对应播放列表 15 +- [x] 时间长了本地缓存文件失效后应当清除对应播放列表
16 16
pages/result/result.js
@@ -18,15 +18,18 @@ Page({ @@ -18,15 +18,18 @@ Page({
18 data: { 18 data: {
19 audioList: formateDate(app.globalData.getAudioList()) 19 audioList: formateDate(app.globalData.getAudioList())
20 }, 20 },
21 - onLoad (options) { 21 + onLoad(options){
22 this.setData({ 22 this.setData({
23 audioList: formateDate(app.globalData.getAudioList()) 23 audioList: formateDate(app.globalData.getAudioList())
24 }); 24 });
25 }, 25 },
  26 + onUnload(){
  27 + this.resetAudio();
  28 + },
26 play(e){ 29 play(e){
27 const { path } = e.target.dataset; 30 const { path } = e.target.dataset;
28 const target = app.globalData.getAudioList().find(v => v.path === path); 31 const target = app.globalData.getAudioList().find(v => v.path === path);
29 - audio && audio.destroy(); 32 + this.resetAudio();
30 audio = wx.createInnerAudioContext({useWebAudioImplement: true}); 33 audio = wx.createInnerAudioContext({useWebAudioImplement: true});
31 audio.autoplay = true; 34 audio.autoplay = true;
32 audio.src = target.path; 35 audio.src = target.path;
@@ -71,5 +74,11 @@ Page({ @@ -71,5 +74,11 @@ Page({
71 }); 74 });
72 } 75 }
73 }); 76 });
  77 + },
  78 + resetAudio(){
  79 + if(audio){
  80 + audio.destroy();
  81 + audio = null;
  82 + }
74 } 83 }
75 }); 84 });
76 \ No newline at end of file 85 \ No newline at end of file