Commit a42fe477303591281b9865c72b28733f146866ba
1 parent
cc2425f4
feat: reset audio when destroy list
Showing
2 changed files
with
13 additions
and
4 deletions
README.md
| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | - [x] 内容安全问题处理 |
| 11 | 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 | 18 | data: { |
| 19 | 19 | audioList: formateDate(app.globalData.getAudioList()) |
| 20 | 20 | }, |
| 21 | - onLoad (options) { | |
| 21 | + onLoad(options){ | |
| 22 | 22 | this.setData({ |
| 23 | 23 | audioList: formateDate(app.globalData.getAudioList()) |
| 24 | 24 | }); |
| 25 | 25 | }, |
| 26 | + onUnload(){ | |
| 27 | + this.resetAudio(); | |
| 28 | + }, | |
| 26 | 29 | play(e){ |
| 27 | 30 | const { path } = e.target.dataset; |
| 28 | 31 | const target = app.globalData.getAudioList().find(v => v.path === path); |
| 29 | - audio && audio.destroy(); | |
| 32 | + this.resetAudio(); | |
| 30 | 33 | audio = wx.createInnerAudioContext({useWebAudioImplement: true}); |
| 31 | 34 | audio.autoplay = true; |
| 32 | 35 | audio.src = target.path; |
| ... | ... | @@ -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 | 85 | \ No newline at end of file | ... | ... |