I want to implement a screen recorder based on this example" https://playground.babylonjs.com/#47H64G#5" but I don’t know how to download the data stored in videoBlob manually, I want avoid auto download function because i want to provide user with option to name the file and then download it , like how real screenrecorders do , also , is there any way to pause and resume the recording ? ,
The easiest in your case might be to reuse the mediaRecorder from the bare JS Api directly like we do in here Babylon.js/videoRecorder.ts at master · BabylonJS/Babylon.js · GitHub.
About the download the code is like this:
/**
* Downloads a blob in the browser
* @param blob defines the blob to download
* @param fileName defines the name of the downloaded file
*/
public static Download(blob: Blob, fileName: string): void {
if (navigator && (navigator as any).msSaveBlob) {
(navigator as any).msSaveBlob(blob, fileName);
return;
}
var url = window.URL.createObjectURL(blob);
var a = document.createElement("a");
document.body.appendChild(a);
a.style.display = "none";
a.href = url;
a.download = fileName;
a.addEventListener("click", () => {
if (a.parentElement) {
a.parentElement.removeChild(a);
}
});
a.click();
window.URL.revokeObjectURL(url);
}
which you can access with BABYLON.Tools.Download
thanks, i will try it, it seems this might work, but what about the pause and resume task, is this also defined in mediaRecorder ?
Yup it is all in here MediaRecorder - Web APIs | MDN
thanx