Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Inline

Manav Rathifab7ecb98076
diff --git a/web/packages/new/photos/services/download.ts b/web/packages/new/photos/services/download.ts
index 7ba68a65c4..618df2e66f 100644
--- a/web/packages/new/photos/services/download.ts
+++ b/web/packages/new/photos/services/download.ts
@@ -14,7 +14,6 @@ import * as ffmpeg from "@/new/photos/services/ffmpeg";
import { renderableImageBlob } from "@/new/photos/utils/file";
import { ensure } from "@/utils/ensure";
import { CustomError } from "@ente/shared/error";
-import { isPlaybackPossible } from "@ente/shared/media/video-playback";
import HTTPService from "@ente/shared/network/HTTPService";
import { retryAsyncFunction } from "@ente/shared/utils";
@@ -595,6 +594,36 @@ async function getPlayableVideo(
}
}
+const WAIT_FOR_VIDEO_PLAYBACK = 1 * 1000;
+
+async function isPlaybackPossible(url: string): Promise<boolean> {
+ return await new Promise((resolve) => {
+ const t = setTimeout(() => {
+ resolve(false);
+ }, WAIT_FOR_VIDEO_PLAYBACK);
+
+ const video = document.createElement("video");
+ video.addEventListener("canplay", function () {
+ clearTimeout(t);
+ video.remove(); // Clean up the video element
+ // also check for duration > 0 to make sure it is not a broken video
+ if (video.duration > 0) {
+ resolve(true);
+ } else {
+ resolve(false);
+ }
+ });
+ video.addEventListener("error", function () {
+ clearTimeout(t);
+ video.remove();
+ resolve(false);
+ });
+
+ video.src = url;
+ });
+}
+
+
class PhotosDownloadClient implements DownloadClient {
constructor(
private token: string,
diff --git a/web/packages/shared/media/video-playback.ts b/web/packages/shared/media/video-playback.ts
index 2b8c5268bd..e69de29bb2 100644
--- a/web/packages/shared/media/video-playback.ts
+++ b/web/packages/shared/media/video-playback.ts
@@ -1,28 +0,0 @@
-const WAIT_FOR_VIDEO_PLAYBACK = 1 * 1000;
-
-export async function isPlaybackPossible(url: string): Promise<boolean> {
- return await new Promise((resolve) => {
- const t = setTimeout(() => {
- resolve(false);
- }, WAIT_FOR_VIDEO_PLAYBACK);
-
- const video = document.createElement("video");
- video.addEventListener("canplay", function () {
- clearTimeout(t);
- video.remove(); // Clean up the video element
- // also check for duration > 0 to make sure it is not a broken video
- if (video.duration > 0) {
- resolve(true);
- } else {
- resolve(false);
- }
- });
- video.addEventListener("error", function () {
- clearTimeout(t);
- video.remove();
- resolve(false);
- });
-
- video.src = url;
- });
-}