chengjie 6 年之前
父节点
当前提交
dc5c81e93c
共有 6 个文件被更改,包括 31 次插入62 次删除
  1. 9 32
      pages/main/detail.js
  2. 3 1
      pages/main/detail.wxml
  3. 10 26
      pages/main/preview.js
  4. 3 1
      pages/main/preview.wxml
  5. 5 1
      pages/main/searchCardList.js
  6. 1 1
      project.config.json

+ 9 - 32
pages/main/detail.js

@@ -36,7 +36,6 @@ var intervalSound = 0,
36
 var isCollecting = false;
36
 var isCollecting = false;
37
 
37
 
38
 var isPlaying = false;
38
 var isPlaying = false;
39
-var innerAudioContext;
40
 
39
 
41
 var timeoutPlayAudio;
40
 var timeoutPlayAudio;
42
 var tempPlayUrl = "";
41
 var tempPlayUrl = "";
@@ -74,16 +73,8 @@ Page({
74
       Color: main.getDetailColor(app.globalData.ColorIndex),
73
       Color: main.getDetailColor(app.globalData.ColorIndex),
75
     });
74
     });
76
 
75
 
76
+    this.audioCtx = wx.createAudioContext('myAudio'); 
77
     innerAudioContext1 = wx.createInnerAudioContext();
77
     innerAudioContext1 = wx.createInnerAudioContext();
78
-    
79
-    innerAudioContext = wx.createInnerAudioContext();
80
-    innerAudioContext.onPlay(() => {
81
-      //console.log('开始播放');
82
-    });
83
-    innerAudioContext.onEnded(() => {
84
-      //console.log('结束播放');
85
-    });
86
-
87
 
78
 
88
     this.getList();
79
     this.getList();
89
 
80
 
@@ -139,10 +130,6 @@ Page({
139
     clearInterval(intervalSound);
130
     clearInterval(intervalSound);
140
     clearTimeout(timeoutEveryCard);
131
     clearTimeout(timeoutEveryCard);
141
     listTaskFinished = [];
132
     listTaskFinished = [];
142
-    if (innerAudioContext) {
143
-      innerAudioContext.stop();
144
-      isPlaying = false;
145
-    }
146
   },
133
   },
147
   onPullDownRefresh: function () {
134
   onPullDownRefresh: function () {
148
     this.onShowAnswer({
135
     this.onShowAnswer({
@@ -386,10 +373,6 @@ Page({
386
   //回到上一张题卡
373
   //回到上一张题卡
387
   gotoPrev: function () {
374
   gotoPrev: function () {
388
     var that = this;
375
     var that = this;
389
-    if (innerAudioContext) {
390
-      innerAudioContext.stop();
391
-      isPlaying = false;
392
-    }
393
 
376
 
394
     if (listTaskFinished.length > 0) {
377
     if (listTaskFinished.length > 0) {
395
       var card = listTaskFinished.pop();
378
       var card = listTaskFinished.pop();
@@ -445,11 +428,6 @@ Page({
445
   //进入下一张题卡
428
   //进入下一张题卡
446
   gotoNext: function (e) {
429
   gotoNext: function (e) {
447
     var that = this;
430
     var that = this;
448
-    if (innerAudioContext) {
449
-      innerAudioContext.stop();
450
-      isPlaying = false;
451
-    }
452
-
453
     var btnnumber = e.currentTarget.dataset.btnnumber;
431
     var btnnumber = e.currentTarget.dataset.btnnumber;
454
     var time = e.currentTarget.dataset.time;
432
     var time = e.currentTarget.dataset.time;
455
 
433
 
@@ -712,9 +690,7 @@ Page({
712
       timeoutPlayAudio = setTimeout(function () {
690
       timeoutPlayAudio = setTimeout(function () {
713
         isPlaying = false;
691
         isPlaying = false;
714
       }, 60000);
692
       }, 60000);
715
-      if (innerAudioContext) {
716
-        innerAudioContext.stop();
717
-      }
693
+      
718
       wx.showLoading({
694
       wx.showLoading({
719
         title: '音频下载中',
695
         title: '音频下载中',
720
         mask: true,
696
         mask: true,
@@ -728,8 +704,8 @@ Page({
728
         success(res) {
704
         success(res) {
729
           wx.hideLoading();
705
           wx.hideLoading();
730
           if (res.statusCode === 200) {
706
           if (res.statusCode === 200) {
731
-            innerAudioContext.src = res.tempFilePath;
732
-            innerAudioContext.play();
707
+            that.audioCtx.setSrc(res.tempFilePath);
708
+            that.audioCtx.play();
733
             tempPlayUrl = url;
709
             tempPlayUrl = url;
734
           }
710
           }
735
         },
711
         },
@@ -739,12 +715,13 @@ Page({
739
       });
715
       });
740
     }
716
     }
741
     else {
717
     else {
742
-      if (innerAudioContext) {
743
-        innerAudioContext.stop();
744
-        isPlaying = false;
745
-      }
718
+      this.audioCtx.pause();
719
+      isPlaying = false;
746
     }
720
     }
747
   },
721
   },
722
+  audioBindEnded: function () {
723
+    isPlaying = false;
724
+  },
748
   getTaskTime: function () {
725
   getTaskTime: function () {
749
     var that = this;
726
     var that = this;
750
     var url = "GetMiaoguoTaskTime?";
727
     var url = "GetMiaoguoTaskTime?";

+ 3 - 1
pages/main/detail.wxml

@@ -211,4 +211,6 @@
211
   </view>
211
   </view>
212
 </view>
212
 </view>
213
 
213
 
214
-<canvas class='Canvas' canvas-id="shareCanvas"></canvas>
214
+<canvas class='Canvas' canvas-id="shareCanvas"></canvas>
215
+
216
+<audio hidden='true' src="{{AudioSrc}}" id="myAudio" bindended="audioBindEnded"></audio>

+ 10 - 26
pages/main/preview.js

@@ -32,15 +32,7 @@ Page({
32
     });
32
     });
33
     console.log("MiaoguoCardID:" + id);
33
     console.log("MiaoguoCardID:" + id);
34
 
34
 
35
-    innerAudioContext = wx.createInnerAudioContext();
36
-    innerAudioContext.onPlay(() => {
37
-      console.log('开始播放');
38
-    });
39
-    innerAudioContext.onEnded(() => {
40
-      console.log('结束播放');
41
-      isPlaying = false;
42
-    });
43
-
35
+    this.audioCtx = wx.createAudioContext('myAudio');
44
 
36
 
45
     if (options.type == "show") {
37
     if (options.type == "show") {
46
       wx.setNavigationBarTitle({
38
       wx.setNavigationBarTitle({
@@ -129,10 +121,7 @@ Page({
129
         that.init();
121
         that.init();
130
   },
122
   },
131
   onUnload: function () {
123
   onUnload: function () {
132
-    if (innerAudioContext) {
133
-      innerAudioContext.stop();
134
-      isPlaying = false;
135
-    }
124
+    isPlaying = false;
136
   },
125
   },
137
   onPullDownRefresh: function () {
126
   onPullDownRefresh: function () {
138
     var that = this;
127
     var that = this;
@@ -243,10 +232,7 @@ Page({
243
       scrollTop: 0,
232
       scrollTop: 0,
244
     });
233
     });
245
 
234
 
246
-    if (innerAudioContext) {
247
-      innerAudioContext.stop();
248
-      isPlaying = false;
249
-    }
235
+    isPlaying = false;
250
   },
236
   },
251
   practiceToday: function () {
237
   practiceToday: function () {
252
     var that = this;
238
     var that = this;
@@ -423,9 +409,6 @@ Page({
423
       timeoutPlayAudio = setTimeout(function () {
409
       timeoutPlayAudio = setTimeout(function () {
424
         isPlaying = false;
410
         isPlaying = false;
425
       }, 60000);
411
       }, 60000);
426
-      if (innerAudioContext) {
427
-        innerAudioContext.stop();
428
-      }
429
       wx.showLoading({
412
       wx.showLoading({
430
         title: '音频下载中',
413
         title: '音频下载中',
431
         mask: true,
414
         mask: true,
@@ -439,8 +422,8 @@ Page({
439
         success(res) {
422
         success(res) {
440
           wx.hideLoading();
423
           wx.hideLoading();
441
           if (res.statusCode === 200) {
424
           if (res.statusCode === 200) {
442
-            innerAudioContext.src = res.tempFilePath;
443
-            innerAudioContext.play();
425
+            that.audioCtx.setSrc(res.tempFilePath);
426
+            that.audioCtx.play();
444
             tempPlayUrl=url;
427
             tempPlayUrl=url;
445
           }
428
           }
446
         },
429
         },
@@ -450,12 +433,13 @@ Page({
450
       });
433
       });
451
     }
434
     }
452
     else {
435
     else {
453
-      if (innerAudioContext) {
454
-        innerAudioContext.stop();
455
-        isPlaying = false;
456
-      }
436
+      this.audioCtx.pause();
437
+      isPlaying = false;
457
     }
438
     }
458
   },
439
   },
440
+  audioBindEnded:function(){
441
+    isPlaying = false;
442
+  },
459
   getDetailInfo: function () {
443
   getDetailInfo: function () {
460
     wx.navigateTo({
444
     wx.navigateTo({
461
       url: './cardInfo?id=' + this.data.MiaoguoCardID,
445
       url: './cardInfo?id=' + this.data.MiaoguoCardID,

+ 3 - 1
pages/main/preview.wxml

@@ -101,4 +101,6 @@
101
     </view>
101
     </view>
102
   </view>
102
   </view>
103
   
103
   
104
-</view>
104
+</view>
105
+
106
+<audio hidden='true' src="{{AudioSrc}}" id="myAudio" bindended="audioBindEnded"></audio>

+ 5 - 1
pages/main/searchCardList.js

@@ -39,11 +39,15 @@ Page({
39
       IsCollect = 1;
39
       IsCollect = 1;
40
     }
40
     }
41
 
41
 
42
+    var count=0;
43
+    if (options.count)
44
+      count=options.count;
45
+
42
     that.setData({
46
     that.setData({
43
       IsCollect: IsCollect,
47
       IsCollect: IsCollect,
44
       Search: Search,
48
       Search: Search,
45
       IsToday: IsToday,
49
       IsToday: IsToday,
46
-      Count: options.count,
50
+      Count: count,
47
       Containnerheight: main.getWindowHeight(),
51
       Containnerheight: main.getWindowHeight(),
48
     });
52
     });
49
   },
53
   },

+ 1 - 1
project.config.json

@@ -14,7 +14,7 @@
14
 		"checkInvalidKey": true
14
 		"checkInvalidKey": true
15
 	},
15
 	},
16
 	"compileType": "miniprogram",
16
 	"compileType": "miniprogram",
17
-	"libVersion": "2.6.4",
17
+	"libVersion": "2.0.4",
18
 	"appid": "wx84b3feac6069eec3",
18
 	"appid": "wx84b3feac6069eec3",
19
 	"projectname": "miaoguo_master",
19
 	"projectname": "miaoguo_master",
20
 	"debugOptions": {
20
 	"debugOptions": {