ws-audio-api icon indicating copy to clipboard operation
ws-audio-api copied to clipboard

Can't get the example working

Open metroite opened this issue 3 years ago • 5 comments

Is it because of the SSL?

This is the output when clicking all top four buttons in order from left to right: grafik

metroite avatar Mar 07 '21 02:03 metroite

Yes, looks like it's SSL problem

Ivan-Feofanov avatar Mar 07 '21 06:03 Ivan-Feofanov

Pardon me if I sound like a noob. But how to correct this error? Right now, I am testing this on localhost on Chrome Windows. Afaik, getUserMedia works on Chrome's localhost without HTTPS.

NidheeshJain avatar Mar 27 '21 14:03 NidheeshJain

@NidheeshJain chrome complains of not using port 443 for wss, you can try to test with ssl first by changing socket creations as follows in lines 75, 194

this.socket = new WebSocket('ws://'+this.config.server.host+':5000');

and the server back to non secure

var http = require('http');

also the audio context creation only allowed without user interaction, if you're running a dev server, you can click a button, then save a file, it will reload and initialize without forgetting that the user did click, after that you can start click on the player and listener it would work. Not clear why the port is hardcoded on 5000 and not in the src that is not minified, I guess to adapt this lib to more use cases and to newer versions of Chome it would require a big rework, but just the concept design and how it is working is already an awesome example.

wassfila avatar Mar 27 '21 16:03 wassfila

@wassfila Thanks for the solution. Worked well for localhost. this.config.server.host returned undefined though, and I had to replace it with (this.config.server.host || "localhost").

NidheeshJain avatar Mar 28 '21 16:03 NidheeshJain

@NidheeshJain glad it helped, but to be honest this repo is a bit outdated, as some functions start to throw errors on new browsers and some API like the ScriptProcessorNode are getting deprecated. For most recent samples you can refer to this, it has cool samples too https://github.com/mdn/webaudio-examples Although it's not with a server example, that, you might have to combine yourself in your application

wassfila avatar Mar 28 '21 17:03 wassfila