Explorar el Código

语音备注 播放修复

dedsudiyu hace 3 semanas
padre
commit
5436fa8c1b
Se han modificado 1 ficheros con 17 adiciones y 16 borrados
  1. 17 16
      pages_safetyCheck/views/inspectManage/conductInspections.vue

+ 17 - 16
pages_safetyCheck/views/inspectManage/conductInspections.vue

@@ -489,26 +489,27 @@
 			},
 			/******语音备注  *******/
 			//语音备忘播放
-			async voicePlay(item) {
+			voicePlay(item) {
+				const url = uni.getStorageSync('fileBrowseEnvironmentS') + '/' + item;
+				// #ifdef WEB
+				const audio = new Audio(url);
+				audio.play().then(() => {
+					uni.showToast({ title: '开始播放', icon: "none", mask: true });
+				}).catch(() => {
+					uni.showToast({ title: '播放失败', icon: "none", mask: true });
+				});
+				// #endif
+				// #ifndef WEB
 				const innerAudioContext = uni.createInnerAudioContext();
-				// innerAudioContext.autoplay = true;
-				innerAudioContext.src = uni.getStorageSync('fileBrowseEnvironmentS') + '/' + item;
+				innerAudioContext.src = url;
+				innerAudioContext.autoplay = true;
 				innerAudioContext.onPlay(() => {
-				  // console.log('开始播放');
-					uni.showToast({
-						title: '开始播放',
-						icon: "none",
-						mask: true,
-					});
+					uni.showToast({ title: '开始播放', icon: "none", mask: true });
 				});
-				innerAudioContext.onError((res) => {
-				  // console.log('播放失败');
-					uni.showToast({
-						title: '播放失败',
-						icon: "none",
-						mask: true,
-					});
+				innerAudioContext.onError(() => {
+					uni.showToast({ title: '播放失败', icon: "none", mask: true });
 				});
+				// #endif
 			},
 			//语音备忘删除
 			async voiceDele(item, voiceIndex) {