ws-audio-api
ws-audio-api copied to clipboard
Can't get the example working
Is it because of the SSL?
This is the output when clicking all top four buttons in order from left to right:
Yes, looks like it's SSL problem
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 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 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 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