saq1b commited on
Commit
946b149
·
verified ·
1 Parent(s): 595d9d9

Upload index.html

Browse files
Files changed (1) hide show
  1. 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 (preview)
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
- // Create a separate drag-and-drop component.
260
- const dragComponent = document.createElement("div");
261
- dragComponent.className =
262
- "mt-2 p-2 bg-gray-200 border border-dashed text-center rounded cursor-move";
263
- dragComponent.textContent = "Drag This File";
264
- dragComponent.setAttribute("draggable", "true");
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 required: "mime-type:filename:download_url"
271
- const downloadURLData = "video/mp4:" + fileName + ":" + finalUrl;
272
  e.dataTransfer.setData("DownloadURL", downloadURLData);
273
  });
274
- container.appendChild(dragComponent);
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");