Play sound in Angular 4

前端 未结 7 1313
暗喜
暗喜 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:44

    just did this in a project am working (angular 4) and it worked

    playAudio(){
      let audio = new Audio();
      audio.src = "../../../assets/audio/alarm.wav";
      audio.load();
      audio.play();
    }
    this.playAudio();
    

    make sure the path is correct and references an existing audio

提交回复
热议问题