Play sound in Angular 4(在 Angular 4 中播放声音)
问题描述
我正在使用 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 = "Li4vLi4vLi4vYXNzZXRzL2F1ZGlvL2FsYXJtLndhdg==";
audio.load();
audio.play();
}
this.playAudio();
确保路径正确并引用现有音频
make sure the path is correct and references an existing audio
这篇关于在 Angular 4 中播放声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Angular 4 中播放声音


- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01