Skip to content

Commit c0c17c0

Browse files
Add mobile video export
1 parent 966356d commit c0c17c0

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@
6161

6262
<div id="videoRecordingMessageDiv" class="hidden">
6363
</div>
64+
<!--
6465
<button id="downloadButton" class="hidden">Download video</button>
66+
-->
6567

6668
<div id="imageContainer" class="hidden">
6769
<img id="originalImg" src="images/HK400px.jpg">

kaleidoscope.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Add user input options -- control animation length, width of animation
88
//detect user browser
99
var ua = navigator.userAgent;
1010
var isSafari = false;
11-
var isIOS = true;
11+
var isIOS = false;
1212
if(ua.includes("Safari")){
1313
isSafari = true;
1414
}
@@ -65,8 +65,10 @@ saveButton.addEventListener('click', () => {
6565
*/
6666

6767
var finishedBlob;
68+
/*
6869
var downloadButton = document.getElementById("downloadButton");
6970
downloadButton.addEventListener("click",downloadBlob);
71+
*/
7072

7173
//user control sliders
7274
var animationSpeedInput = document.getElementById('speedInput');
@@ -379,7 +381,7 @@ async function recordVideoMuxer() {
379381
//hide input table and display user message
380382
document.getElementById("inputTable").classList.add("hidden");
381383
document.getElementById("videoRecordingMessageDiv").innerHTML =
382-
"Video recording underway. A download button will be shown in "+videoDuration+" seconds.<br><br>This feature does not currently work on Mobile -- please try on Desktop instead.";
384+
"Video recording underway. The video will be saved to your downloads folder in "+videoDuration+" seconds.<br><br>This feature can be a bit buggy on Mobile -- if it doesn't work, please try on Desktop instead.";
383385
document.getElementById("videoRecordingMessageDiv").classList.remove("hidden");
384386

385387
var recordVideoState = true;
@@ -450,11 +452,11 @@ async function recordVideoMuxer() {
450452
muxer.finalize();
451453
let buffer = muxer.target.buffer;
452454
finishedBlob = new Blob([buffer]);
453-
//downloadBlob(new Blob([buffer]));
455+
downloadBlob(new Blob([buffer]));
454456

455457
//hide user message, show download button
456458
document.getElementById("videoRecordingMessageDiv").classList.add("hidden");
457-
downloadButton.classList.remove("hidden");
459+
document.getElementById("inputTable").classList.remove("hidden");
458460

459461
}
460462

@@ -492,10 +494,6 @@ function downloadBlob() {
492494
document.body.appendChild(a);
493495
a.click();
494496
window.URL.revokeObjectURL(url);
495-
496-
//hide download button, show user menu
497-
downloadButton.classList.add("hidden");
498-
document.getElementById("inputTable").classList.remove("hidden");
499497

500498
}
501499

@@ -511,7 +509,7 @@ function startMobileRecording(){
511509
//hide input table and display user message
512510
document.getElementById("inputTable").classList.add("hidden");
513511
document.getElementById("videoRecordingMessageDiv").innerHTML =
514-
"Video recording underway. A download button will be shown in "+videoDuration+" seconds.<br><br>This feature does not currently work on Mobile -- please try on Desktop instead.";
512+
"Video recording underway. The video will be saved to your downloads folder in "+videoDuration+" seconds.<br><br>This feature can be a bit buggy on Mobile -- if it doesn't work, please try on Desktop instead.";
515513
document.getElementById("videoRecordingMessageDiv").classList.remove("hidden");
516514

517515
recorder.start(); //moved here
@@ -527,12 +525,11 @@ function finishMobileRecording(e) {
527525
console.log("finish simple video recording");
528526
var videoData = [ e.data ];
529527
finishedBlob = new Blob(videoData, { 'type': 'video/mp4' });
530-
//console.log(finishedBlob);
531-
//downloadBlob(finishedBlob);
528+
downloadBlob(finishedBlob);
532529

533530
//hide user message, show download button
534531
document.getElementById("videoRecordingMessageDiv").classList.add("hidden");
535-
downloadButton.classList.remove("hidden");
532+
document.getElementById("inputTable").classList.remove("hidden");
536533

537534
},500);
538535

0 commit comments

Comments
 (0)