فهرست منبع

英语题追加音频播放

wangxy 4 ماه پیش
والد
کامیت
04b9bb6be4
3فایلهای تغییر یافته به همراه27 افزوده شده و 5 حذف شده
  1. 0 1
      components/question/yingyu/danxuan.vue
  2. 18 3
      components/question/yingyu/mtaRadio.vue
  3. 9 1
      components/question/yingyu/useAudio.js

+ 0 - 1
components/question/yingyu/danxuan.vue

@@ -77,7 +77,6 @@
 	}
 	
 	function onSelect(index) {
-		console.log('onSelect',index)
 		if (props.showError) {
 			return;
 		}

+ 18 - 3
components/question/yingyu/mtaRadio.vue

@@ -14,12 +14,27 @@
 	} = useAudio();
 	// 播放
 	uni.$on('do-yy-audio-play', (data) => {
-		// console.log(`playing ${data.stId}:`, data)
+    if (historyData) {
+      if (historyData.stId != data.stId && historyData.index != data.index) {
+        // 播放中切换其他音频时发出事件
+        uni.$emit('reset-playing-status', historyData);
+        historyData = null
+        return;
+      }
+
+      if (historyData.stId != data.stId ) {
+        // 播放中切换其他音频时发出事件
+        uni.$emit('reset-playing-status', historyData);
+        historyData = null
+        return;
+      }
+    }
+
 		handlePlay(data)
-	})
+    historyData = data;
+  })
 	// 暂停
 	uni.$on('do-yy-audio-stop', () => {
-		// console.log(`ending ${data.stId}:`, data)
 		handleStop()
 	})
 	// 销毁

+ 9 - 1
components/question/yingyu/useAudio.js

@@ -32,6 +32,7 @@ export function useAudio() {
 	},50)
 	
 	function handlePlay(data) {
+		// console.log('play111',data)
 		if (innerAudioContext.value) {
 			innerAudioContext.value.stop();
 			innerAudioContext.value.destroy();
@@ -50,7 +51,14 @@ export function useAudio() {
 			uni.$emit('destory-stop')	
 		}
 	}
-	// 试题切换停止播放 
+
+
+	// 播放过程中点击同一个视频触发终止
+	uni.$on('repeat-play-to-stop',() => {
+		handleStop();
+	})
+
+	// 试题切换停止播放
 	uni.$on('swiper-change',() => {
 		handleStop();
 	})