Skip to content

Commit

Permalink
user can stop the recording by clicking red button inside the record … (
Browse files Browse the repository at this point in the history
#3328)

* user can stop the recording by clicking red button instde the record icon

* Making Rec btn working to stop the recording
  • Loading branch information
MohitGupta14 authored Aug 24, 2023
1 parent 214a645 commit ca24861
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,6 @@ class Activity {

this._doRecordButton = () => {
const start = document.getElementById("record"),
stop = document.getElementById("stop"),
recInside = document.getElementById("rec_inside");
let mediaRecorder;
var clickEvent = new Event("click");
Expand All @@ -940,6 +939,8 @@ class Activity {
);
}

let that = this;

function saveFile(recordedChunks) {
flag = 1;
recInside.classList.remove("blink");
Expand All @@ -963,8 +964,8 @@ class Activity {
// eslint-disable-next-line no-use-before-define
recording();
doRecordButton();
that.textMsg("click on stop sharing");
}

function stopRec() {
flag = 0;
mediaRecorder.stop();
Expand All @@ -988,7 +989,7 @@ class Activity {
// eslint-disable-next-line no-console
console.log("Recording is ready to save");
stopRec();
flag=0;
flag = 0;
};

mediaRecorder.onstop = function() {
Expand Down Expand Up @@ -1021,7 +1022,6 @@ class Activity {
const node = document.createElement("p");
node.textContent = "Started recording";
document.body.appendChild(node);
start.style = null;
recInside.setAttribute("fill", "red");
}
);
Expand All @@ -1030,19 +1030,13 @@ class Activity {
if (flag == 0 && isExecuting) {
recording();
start.dispatchEvent(clickEvent);
flag = 1;
};

stop.addEventListener(
"click",
function() {
flag = 0;
recInside.classList.remove("blink");
mediaRecorder.stop();
const node = document.createElement("p");
node.textContent = "Stopped recording";
document.body.appendChild(node);
}
);
if(flag == 1 && isExecuting){
start.addEventListener('click',stopRec);
flag = 0;
}

};

Expand Down

0 comments on commit ca24861

Please sign in to comment.