Audio in Node-webkit using node js and web audio API

I am working on an application using node-webkit in which I need to play audio. I have successfully played audio using the web audio API and XMLHttpRequest, but loading the song is very slow. It takes up to 1 second depending on the format and size.

Is there a way to upload a file using the node.js file system and then transfer this data to the web audio API to reduce download time? Is there a better way to do this?

Note. I am creating my own application, so I want to play audio so as not to transmit it to clients. I also need to be able to handle audio, so I looked at the web audio API.

+5
source share
1 answer

You can convert the audio data to uri data: and use this.

Check this question for more information.

There are a large number of tools for converting an audio file to data uri too .

This is npm file-component

  var file = require('file'); var img = file("/path/to/audio"); if (!img.is('image/*')) { alert('Images only!'); return; } var reader = img.toDataURL(function(err, str){ if (err) throw err; console.log("This is a data: uri: " + str); }); reader.on('progress', function(e){ console.log(e.percent); }); 
0
source

Source: https://habr.com/ru/post/1209568/


All Articles