@@ -80,33 +80,32 @@ function initiate() {
80
80
let recorder
81
81
82
82
const startVideo = () => {
83
- console .log (' hello' )
84
83
videoRecording .value = Date .now ()
85
84
86
85
recorder = new MediaRecorder (video .value .srcObject )
87
86
88
87
recorder .ondataavailable = (event ) => {
89
88
const blob = event .data ;
90
89
const url = URL .createObjectURL (blob);
91
-
92
- // Create a new window to display the video
93
- const newWindow = window .open (' ' , ' _blank' , ` width=${ width .value } ,height=${ height .value + 1 } ` );
94
- newWindow .document .write (`
95
- <html style="overscroll-behavior: none;"><body style="margin:0; background: black; position: relative">
96
- <button onclick="saveVideo()" style="position: absolute; top: 1em; left: 1em; font-size: 3em;">Download video</button>
97
- <video controls autoplay >
98
- <source src="${ url} " type="video/mp4">
99
- </video>
100
- </body></html>
101
- ` );
102
-
103
- newWindow .saveVideo = () => {
104
- const a = newWindow .document .createElement (' a' );
105
- a .href = url;
106
- a .download = ' recorded_video.mp4' ;
107
- a .click ();
108
- URL .revokeObjectURL (url);
109
- };
90
+ window . open (url, ' _blank ' );
91
+
92
+ // const newWindow = window.open('', '_blank', `width=${width.value},height=${height.value + 1}`);
93
+ // newWindow.document.write(`
94
+ // <html style="overscroll-behavior: none;"><body style="margin:0; background: black; position: relative">
95
+ // <button onclick="saveVideo()" style="position: absolute; top: 1em; left: 1em; font-size: 3em;">Download video</button>
96
+ // <video controls autoplay >
97
+ // <source src="${url}" type="video/mp4">
98
+ // </video>
99
+ // </body></html>
100
+ // `);
101
+
102
+ // newWindow.saveVideo = () => {
103
+ // const a = newWindow.document.createElement('a');
104
+ // a.href = url;
105
+ // a.download = 'recorded_video.mp4';
106
+ // a.click();
107
+ // URL.revokeObjectURL(url);
108
+ // };
110
109
};
111
110
recorder .start ()
112
111
}
@@ -129,20 +128,20 @@ const stopRecording = () => {
129
128
const filename = ` spectrogram_${ new Date ().toISOString ().slice (0 , 19 ).replace (/ T/ , ' _' )} .png` ;
130
129
offscreenCanvas .toBlob ((blob ) => {
131
130
const blobUrl = window .URL .createObjectURL (blob);
132
- // window.open(blobUrl, '_blank');
133
- const newWindow = window .open (undefined , ' _blank' );
134
- if (newWindow) {
135
- newWindow .document .write (`
136
- <html>
137
- <head>
138
- <title>${ filename} </title>
139
- </head>
140
- <body style="margin: 0; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #222222;">
141
- <img src="${ blobUrl} " alt="${ filename} " style="cursor: pointer; max-width: 100%; max-height: 100vh; object-fit: contain;" onclick="const a = document.createElement('a'); a.href = '${ blobUrl} '; a.download = '${ filename} '; document.body.appendChild(a); a.click();">
142
- </body>
143
- </html>
144
- ` );
145
- }
131
+ window .open (blobUrl, ' _blank' );
132
+ // const newWindow = window.open(undefined, '_blank');
133
+ // if (newWindow) {
134
+ // newWindow.document.write(`
135
+ // <html>
136
+ // <head>
137
+ // <title>${filename}</title>
138
+ // </head>
139
+ // <body style="margin: 0; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #222222;">
140
+ // <img src="${blobUrl}" alt="${filename}" style="cursor: pointer; max-width: 100%; max-height: 100vh; object-fit: contain;" onclick="const a = document.createElement('a'); a.href = '${blobUrl}'; a.download = '${filename}'; document.body.appendChild(a); a.click();">
141
+ // </body>
142
+ // </html>
143
+ // `);
144
+ // }
146
145
}, ' image/png' );
147
146
};
148
147
@@ -255,7 +254,7 @@ onKeyStroke('Enter', (e) => { e.preventDefault(); clear(); })
255
254
@pointerdown= " recording ? stopRecording() : startRecording()" )
256
255
.i - la- circle (v- if = " !recording" )
257
256
.i - la- dot- circle (v- else )
258
- .p - 0 .text - sm .font - mono (v - if = " recording && recordedWidth" ) {{ recordedWidth }} px ({{ (( time - recording) / 1000 ).toFixed (1 ) }}s)
257
+ .p - 0 .text - sm .font - mono (v - if = " recording && recordedWidth" ) {{ (( time - recording) / 1000 ).toFixed (0 ) }}s ({{ recordedWidth }}px )
259
258
button .text - xl .select - none .cursor - pointer .flex .items - center .gap - 1 (
260
259
: class = " { 'text-red': videoRecording }"
261
260
@pointerdown= " !videoRecording ? startVideo() : stopVideo()" )
0 commit comments