Browse Source

[修改]预警声音改变

master
邵佳豪 2 years ago
parent
commit
fec3ddcb03
  1. 29
      src/app/pages/home/home.component.ts
  2. BIN
      src/assets/sound/warning.mp3

29
src/app/pages/home/home.component.ts

@ -160,17 +160,18 @@ export class HomeComponent implements OnInit {
messageId = [];
receiptOfNotification(userNotification) {
// console.log('语音播报')
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()
let obj = {
id: userNotification.notification.entityId,
messageId: this.notificationService.template(this.template!, {
@ -523,4 +524,10 @@ export class HomeComponent implements OnInit {
console.log("[afterClose] The result is:", result)
);
}
Sound(){
var mp3Url = "../../../assets/sound/warning.mp3";
var player = new Audio(mp3Url);
player.play(); //播放 mp3这个音频对象
}
}

BIN
src/assets/sound/warning.mp3

Binary file not shown.
Loading…
Cancel
Save