Upload index.html
Browse files- templates/index.html +12 -28
templates/index.html
CHANGED
@@ -234,7 +234,7 @@
|
|
234 |
container.appendChild(header);
|
235 |
|
236 |
if (result.status === "completed") {
|
237 |
-
// Processed video display
|
238 |
const videoContainer = document.createElement("div");
|
239 |
videoContainer.className = "max-w-md mx-auto mt-2";
|
240 |
const videoElem = document.createElement("video");
|
@@ -242,37 +242,21 @@
|
|
242 |
videoElem.controls = true;
|
243 |
videoElem.className = "w-full";
|
244 |
videoElem.style.maxHeight = "500px";
|
245 |
-
videoContainer.appendChild(videoElem);
|
246 |
-
container.appendChild(videoContainer);
|
247 |
-
|
248 |
-
// Preload the video file as a Blob and create an object URL
|
249 |
-
// (We do this once per result; if already fetched, we reuse it)
|
250 |
-
if (!result.blobUrl) {
|
251 |
-
fetch(window.location.origin + result.video_url)
|
252 |
-
.then(response => response.blob())
|
253 |
-
.then(blob => {
|
254 |
-
result.blobUrl = URL.createObjectURL(blob);
|
255 |
-
})
|
256 |
-
.catch(err => console.error("Error fetching video blob:", err));
|
257 |
-
}
|
258 |
|
259 |
-
//
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
dragComponent.addEventListener("dragstart", (e) => {
|
266 |
-
// Use the pre-fetched blob URL if available; otherwise, fallback to the hosted URL.
|
267 |
-
const finalUrl = result.blobUrl ? result.blobUrl : window.location.origin + result.video_url;
|
268 |
-
// Define a file name (customize as needed)
|
269 |
const fileName = "video_" + id + ".mp4";
|
270 |
-
// Format
|
271 |
-
const downloadURLData = "video/mp4:" + fileName + ":" +
|
272 |
e.dataTransfer.setData("DownloadURL", downloadURLData);
|
273 |
});
|
274 |
-
|
275 |
-
|
|
|
276 |
|
277 |
// Caption with a copy button
|
278 |
const captionDiv = document.createElement("div");
|
|
|
234 |
container.appendChild(header);
|
235 |
|
236 |
if (result.status === "completed") {
|
237 |
+
// Processed video display
|
238 |
const videoContainer = document.createElement("div");
|
239 |
videoContainer.className = "max-w-md mx-auto mt-2";
|
240 |
const videoElem = document.createElement("video");
|
|
|
242 |
videoElem.controls = true;
|
243 |
videoElem.className = "w-full";
|
244 |
videoElem.style.maxHeight = "500px";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
245 |
|
246 |
+
// Make the video element draggable.
|
247 |
+
videoElem.setAttribute("draggable", "true");
|
248 |
+
videoElem.addEventListener("dragstart", (e) => {
|
249 |
+
// Build an absolute URL for the file
|
250 |
+
const fullUrl = window.location.origin + result.video_url;
|
251 |
+
// Define a file name for the dragged file (you can customize this)
|
|
|
|
|
|
|
|
|
252 |
const fileName = "video_" + id + ".mp4";
|
253 |
+
// Format: MIME type:filename:download_url
|
254 |
+
const downloadURLData = "video/mp4:" + fileName + ":" + fullUrl;
|
255 |
e.dataTransfer.setData("DownloadURL", downloadURLData);
|
256 |
});
|
257 |
+
|
258 |
+
videoContainer.appendChild(videoElem);
|
259 |
+
container.appendChild(videoContainer);
|
260 |
|
261 |
// Caption with a copy button
|
262 |
const captionDiv = document.createElement("div");
|