4

I try to develop a native app using electron and angular2. Its purpose is to conduct Psychology experiments connected with sound perception.

In order to do this, I want to play sounds that will be stored in some assets directory in my app directories. But I find difficulties with accessing those audio files from angular in order to play it. And the internet seems to be pretty unhelpful after half day of searching I did not find and supporting articles.

What is the best way to do it?

Should I add to my app some server application, with angular proxying api requests to it? That solution will most likely work accordingly to what I found.

But is there any simple solution? Like some Electron library that allows offline access from Angular level to file system and files that are in app directory?

Thanks in advance Tomasz

1
  • Can you give us some more info on exactly what you've tried so far to play these sounds? If you post some code we can try and work out what the problem is.
    – Alex Warren
    Commented May 9, 2017 at 14:05

1 Answer 1

2

You could try using howler.js You can install it to your project with npm install --save howler and play a sound with

var sound = new Howl({
  src: ['sound.mp3']
});

sound.play();

You would also probably want to install @types/howler via npm to work with typescript

1
  • The problem is how to load files. The audio api expect a an http url. Or a relative path. Which will be resolved to an http request. Also it can expect a data URL. But it will be nice if we can give it the files as in file://path.wav Commented Apr 20, 2019 at 18:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.