問題描述
我正在使用 Angular 4 開發 Electron 應用程序
.我想在某些特定動作上播放聲音.是否有任何模塊或代碼?它可以在角度 4 中,或者如果電子為此提供一些服務,它也應該可以工作
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 or if electron is providing some service for that it should also work
因為我想在某些動作上播放它,所以我不能使用 HTML 音頻標簽和 javascript 的 audio()
As I want to play it on some action I can't use the HTML audio tag and audio() of javascript
我只想播放 2-3 秒的聲音,所以不需要其他功能.
I only want to play the sound of 2-3 seconds so no other functionalities are needed.
它可以是電子或 Angular 4,它們中的任何一個都可以工作......
It can be of electron or Angular 4 any of them can work...
推薦答案
剛剛在一個正在工作的項目中做了這個(角度 4)并且它工作了
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
這篇關于在 Angular 4 中播放聲音的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!