This commit is contained in:
Renan LE CARO 2025-03-18 15:26:56 +01:00
parent ffdbd71a88
commit 83b9b8b9e8
12 changed files with 7661 additions and 80 deletions

View file

@ -117,20 +117,42 @@ export function startRecordingGame(gameState: GameState) {
video.loop = true;
video.muted = true;
video.playsInline = true;
video.src = URL.createObjectURL(blob);
targetDiv.appendChild(video);
const a = document.createElement("a");
a.download = captureFileName("webm");
a.target = "_blank";
a.href = video.src;
if (window.location.href.endsWith("index.html?isInWebView=true")) {
a.href = await blobToBase64(blob);
} else {
a.href = video.src;
}
a.textContent = t("main_menu.record_download", {
size: (blob.size / 1000000).toFixed(2),
});
targetDiv.appendChild(video);
targetDiv.appendChild(a);
};
}
function blobToBase64(blob: Blob): Promise<string> {
return new Promise((resolve, reject) => {
let reader = new FileReader();
reader.onload = function () {
resolve(reader.result);
};
reader.onerror = function (e) {
console.error(e);
reject(new Error("Failed to readAsDataURL of the video "));
};
reader.readAsDataURL(blob);
});
}
export function pauseRecording() {
if (!isOptionOn("record")) {
return;