Browse Source

日常开发

林旭祥 2 weeks ago
parent
commit
55bc50c201
2 changed files with 4 additions and 2 deletions
  1. 3 1
      src/utils/speech.ts
  2. 1 1
      src/views/game/index.vue

+ 3 - 1
src/utils/speech.ts

@@ -6,6 +6,7 @@ let myMusic: any = null;
 let browserSupport: boolean = false;
 let speechText: string = '';
 
+
 //初始化语音
 export const initSpeech = () => {
   speech = new Speech();
@@ -139,7 +140,7 @@ export const speckText = (text: any) => {
 };
 
 //播放音乐
-export const playMusic = (url: any) => {
+export const playMusic = (url: any, loop: boolean = false) => {
   let state = true;
   let voiceData: any = localStorage.getItem('voice');
   if (voiceData != undefined && voiceData == 'false') {
@@ -147,6 +148,7 @@ export const playMusic = (url: any) => {
   }
   myMusic = new Audio(url);
   myMusic.muted = state ? false : true;
+  myMusic.loop = loop;
   myMusic.play();
 };
 

+ 1 - 1
src/views/game/index.vue

@@ -376,7 +376,7 @@ const getPlayMusic = async () => {
       return item.id == music.value.id;
     });
     if (obj != undefined) {
-      playMusic(obj.url);
+      playMusic(obj.url, true);
     }
   }
 };