|
|
@ -17,6 +17,8 @@ var awaitingResponse; |
|
|
|
var streamConstraints; |
|
|
|
var streamConstraints; |
|
|
|
var myMediaStream; |
|
|
|
var myMediaStream; |
|
|
|
let wsChat; |
|
|
|
let wsChat; |
|
|
|
|
|
|
|
var recordedChunks = []; |
|
|
|
|
|
|
|
var mediaRecorder = null; |
|
|
|
|
|
|
|
|
|
|
|
const room = getRoom(); |
|
|
|
const room = getRoom(); |
|
|
|
|
|
|
|
|
|
|
@ -475,6 +477,60 @@ window.addEventListener('load', function(){ |
|
|
|
//enable call buttons
|
|
|
|
//enable call buttons
|
|
|
|
enableCallBtns(); |
|
|
|
enableCallBtns(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
******************************************************************************************************************************** |
|
|
|
|
|
|
|
******************************************************************************************************************************** |
|
|
|
|
|
|
|
******************************************************************************************************************************** |
|
|
|
|
|
|
|
******************************************************************************************************************************** |
|
|
|
|
|
|
|
******************************************************************************************************************************** |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
document.getElementById('record').addEventListener('click', (e)=>{ |
|
|
|
|
|
|
|
if(myMediaStream && myMediaStream.getTracks().length){ |
|
|
|
|
|
|
|
if(mediaRecorder && mediaRecorder.state == 'recording'){ |
|
|
|
|
|
|
|
//stop recording
|
|
|
|
|
|
|
|
mediaRecorder.stop(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
e.setAttribute('title', 'Record'); |
|
|
|
|
|
|
|
e.target.classList.remove('btn-danger'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
//start recording
|
|
|
|
|
|
|
|
mediaRecorder = new MediaRecorder(myMediaStream, { |
|
|
|
|
|
|
|
mimeType: 'video/webm;codecs=vp9' |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mediaRecorder.start(1000); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//change the button to reflect that recording has started
|
|
|
|
|
|
|
|
e.setAttribute('title', 'Stop recording'); |
|
|
|
|
|
|
|
e.target.classList.add('btn-danger'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mediaRecorder.ondataavailable = function(e){ |
|
|
|
|
|
|
|
recordedChunks.push(e.data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mediaRecorder.onstop = function(){ |
|
|
|
|
|
|
|
saveRecordedStream(recordedChunks); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(()=>{ |
|
|
|
|
|
|
|
recordedChunks = []; |
|
|
|
|
|
|
|
}, 3000); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mediaRecorder.onerror = function(e){ |
|
|
|
|
|
|
|
console.error(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
showSnackBar('Nothing to record', 5000); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
@ -886,6 +942,11 @@ function endCall(msg, setTimeOut){ |
|
|
|
clearTimeout(awaitingResponse); |
|
|
|
clearTimeout(awaitingResponse); |
|
|
|
|
|
|
|
|
|
|
|
document.getElementById('callerTone').pause(); |
|
|
|
document.getElementById('callerTone').pause(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//disable the record button
|
|
|
|
|
|
|
|
document.getElementById('record').removeAttribute('disabled'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stopMediaStream(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
@ -918,6 +979,7 @@ function enableCallBtns(){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
document.getElementById('terminateCall').setAttribute('disabled', true); |
|
|
|
document.getElementById('terminateCall').setAttribute('disabled', true); |
|
|
|
|
|
|
|
document.getElementById('record').setAttribute('disabled', true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
@ -937,6 +999,7 @@ function disableCallBtns(){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
document.getElementById('terminateCall').removeAttribute('disabled'); |
|
|
|
document.getElementById('terminateCall').removeAttribute('disabled'); |
|
|
|
|
|
|
|
document.getElementById('record').removeAttribute('disabled'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
@ -1062,12 +1125,8 @@ function startCounter(){ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
function stopMediaStream(){ |
|
|
|
function stopMediaStream(){ |
|
|
|
if(myMediaStream){ |
|
|
|
if(myMediaStream && myMediaStream.getTracks().length){ |
|
|
|
var totalTracks = myMediaStream.getTracks().length; |
|
|
|
myMediaStream.getTracks().forEach(track => track.stop()) |
|
|
|
|
|
|
|
|
|
|
|
for(let i = 0; i < totalTracks; i++){ |
|
|
|
|
|
|
|
myMediaStream.getTracks()[i].stop(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1133,3 +1192,13 @@ function getRoom(){ |
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function saveRecordedStream(chunk){ |
|
|
|
|
|
|
|
let blob = new Blob(chunk, {type:'video/webm'}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let file = new File([blob], `__${moment().unix()}-record.webm`); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
saveAs(file); |
|
|
|
|
|
|
|
} |