Play sound in Angular 4

前端 未结 7 1539
暗喜
暗喜 2020-12-12 22:17

I\'m working on an Electron app with Angular 4. I want to play sound on some specific action. Is there any module or code for that? It can be in the angular 4 o

7条回答
  •  鱼传尺愫
    2020-12-12 22:53

    As per Robin's comment, i have checked that link we can use it using the audio() object in the ts file like this:

    this.audio = new Audio();
    this.audio.src = "../../../assets/sounds/button_1.mp3";
    this.audio.load();
    this.audio.play();
    

提交回复
热议问题