Forráskód Böngészése

修复语音备注无法播放

dedsudiyu 2 hete
szülő
commit
5de394dbb0

+ 3 - 20
pages_safetyCheck/views/inspectManage/conductInspections.vue

@@ -117,6 +117,7 @@
 </template>
 
 <script>
+	const myaudio = uni.createInnerAudioContext();
 	// #ifdef WEB
 	import Recorder from 'recorder-core';
 	import 'recorder-core/src/engine/mp3';
@@ -490,26 +491,8 @@
 			/******语音备注  *******/
 			//语音备忘播放
 			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.src = url;
-				innerAudioContext.autoplay = true;
-				innerAudioContext.onPlay(() => {
-					uni.showToast({ title: '开始播放', icon: "none", mask: true });
-				});
-				innerAudioContext.onError(() => {
-					uni.showToast({ title: '播放失败', icon: "none", mask: true });
-				});
-				// #endif
+				myaudio.src = config.base_url + item;
+				myaudio.play();
 			},
 			//语音备忘删除
 			async voiceDele(item, voiceIndex) {