在Angular 4中播放声音

编程入门 行业动态 更新时间:2024-10-24 19:17:57
本文介绍了在Angular 4中播放声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Angular 4开发Electron app.我想在某些特定动作上播放声音.是否有任何模块或代码?它可以在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

我想在某些动作上播放它,所以我无法使用javascript的HTML音频标签和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中播放声音

本文发布于:2023-07-11 12:10:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1094008.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:声音   Angular

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!