I have the following code that sends the video:
window.URL = window.URL || window.webkitURL;
navigator.getUserMedia = (
navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
if (navigator.getUserMedia){//si es compatible
navigator.getUserMedia ({audio: true, video:true}, //video:false (para solo audio)
function(vid) {
bandera = 1;
document.querySelector('video').src = window.URL.createObjectURL(vid);
},function(err) {
console.log("The following error occured: " + err);
}
);
}else{
console.log("getUserMedia not supported");
}
window.requestAnimFrame = (function(callback){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback){
window.setTimeout(callback, 1000/100 );
};
})();
function dFrame(ctx,video,canvas){
var dataURL = canvas.toDataURL('image/jpeg',0.2);
if(bandera!=0)
send(dataURL);//aca se envia con el socket
requestAnimFrame(function(){
setTimeout(function(){dFrame(ctx,video,canvas);},200)
});
}
window.addEventListener('load',init);//inicia cuando carga la pagina
function init(){
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext("2d");
var video = document.querySelector('video');
dFrame(ctx,video,canvas);
}
I want to adapt the code so that it is only audio. Since I do not have the slightest idea of how it should be captured to send it in the socket, and also how it should be received in the other clients and put into play with the label or other element if that is the case.
Thank you in advance.