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

+ 3 - 1
pages/main/detail.wxml

@@ -211,4 +211,6 @@
211 211
   </view>
212 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 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 37
     if (options.type == "show") {
46 38
       wx.setNavigationBarTitle({
@@ -129,10 +121,7 @@ Page({
129 121
         that.init();
130 122
   },
131 123
   onUnload: function () {
132
-    if (innerAudioContext) {
133
-      innerAudioContext.stop();
134
-      isPlaying = false;
135
-    }
124
+    isPlaying = false;
136 125
   },
137 126
   onPullDownRefresh: function () {
138 127
     var that = this;
@@ -243,10 +232,7 @@ Page({
243 232
       scrollTop: 0,
244 233
     });
245 234
 
246
-    if (innerAudioContext) {
247
-      innerAudioContext.stop();
248
-      isPlaying = false;
249
-    }
235
+    isPlaying = false;
250 236
   },
251 237
   practiceToday: function () {
252 238
     var that = this;
@@ -423,9 +409,6 @@ Page({
423 409
       timeoutPlayAudio = setTimeout(function () {
424 410
         isPlaying = false;
425 411
       }, 60000);
426
-      if (innerAudioContext) {
427
-        innerAudioContext.stop();
428
-      }
429 412
       wx.showLoading({
430 413
         title: '音频下载中',
431 414
         mask: true,
@@ -439,8 +422,8 @@ Page({
439 422
         success(res) {
440 423
           wx.hideLoading();
441 424
           if (res.statusCode === 200) {
442
-            innerAudioContext.src = res.tempFilePath;
443
-            innerAudioContext.play();
425
+            that.audioCtx.setSrc(res.tempFilePath);
426
+            that.audioCtx.play();
444 427
             tempPlayUrl=url;
445 428
           }
446 429
         },
@@ -450,12 +433,13 @@ Page({
450 433
       });
451 434
     }
452 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 443
   getDetailInfo: function () {
460 444
     wx.navigateTo({
461 445
       url: './cardInfo?id=' + this.data.MiaoguoCardID,

+ 3 - 1
pages/main/preview.wxml

@@ -101,4 +101,6 @@
101 101
     </view>
102 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 39
       IsCollect = 1;
40 40
     }
41 41
 
42
+    var count=0;
43
+    if (options.count)
44
+      count=options.count;
45
+
42 46
     that.setData({
43 47
       IsCollect: IsCollect,
44 48
       Search: Search,
45 49
       IsToday: IsToday,
46
-      Count: options.count,
50
+      Count: count,
47 51
       Containnerheight: main.getWindowHeight(),
48 52
     });
49 53
   },

+ 1 - 1
project.config.json

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