Wednesday, 7 June 2017

How to pass client-JS variable to Node-JS server-side variable?

This is my client.js

navigator.getUserMedia(constraints, successCallback, errorCallback);
function successCallback (stream) { //I want to pass the stream variable to server-side NodeJS
   var video = document.querySelector('video');
   video.src = window.URL.createObjectURL(stream);
   video.onloadedmetadata = function(e) {
      // Do something with the video here.
   };
}
//...

This is my server.js

var PitchDetect = require('pitch-detect'),
    pitchDetect = new PitchDetect(stream); // I want to get the stream variable from client.js

pitchDetect.getPitch();

How to tell nodeJS that in server.js file, the stream variable is the same as stream variable from client.js ?



via J. Doe

No comments:

Post a Comment