diff --git a/src/app/pages/home/home.component.ts b/src/app/pages/home/home.component.ts index 30253ca..42f9905 100644 --- a/src/app/pages/home/home.component.ts +++ b/src/app/pages/home/home.component.ts @@ -363,17 +363,18 @@ export class HomeComponent implements OnInit { messageId = []; receiptOfNotification(userNotification) { if (this.isWarningVoice) { - if (!window.speechSynthesis) { - this.message.create("warning", `该游览器不支持语音播报`); - } else { - let speakMsg = new SpeechSynthesisUtterance( - "请注意,收到一条新的预警信息,请及时处理!" - ); - speakMsg.lang = "zh-CN"; - speakMsg.rate = 1; - speakMsg.pitch = 1.5; - window.speechSynthesis.speak(speakMsg); - } + // if (!window.speechSynthesis) { + // this.message.create("warning", `该游览器不支持语音播报`); + // } else { + // let speakMsg = new SpeechSynthesisUtterance( + // "请注意,收到一条新的预警信息,请及时处理!" + // ); + // speakMsg.lang = "zh-CN"; + // speakMsg.rate = 1; + // speakMsg.pitch = 1.5; + // window.speechSynthesis.speak(speakMsg); + // } + this.Sound(); } if (this.isWarningWindow) { let obj = { @@ -388,7 +389,11 @@ export class HomeComponent implements OnInit { this.messageId.push(obj); } } - + Sound() { + var mp3Url = "../../../assets/sound/warning.mp3"; + var player = new Audio(mp3Url); + player.play(); //播放 mp3这个音频对象 + } modalData; look(item) { console.log("推送信息", item); diff --git a/src/assets/sound/warning.mp3 b/src/assets/sound/warning.mp3 new file mode 100644 index 0000000..4800c68 Binary files /dev/null and b/src/assets/sound/warning.mp3 differ