Skip to content

armgit / ente

Public Imported from GitHub
0

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

Tinker

Manav Rathibb8d2369c01b
diff --git a/web/apps/cast/src/services/chromecast.ts b/web/apps/cast/src/services/chromecast.ts
index bac20e3de4..e7539e8c51 100644
--- a/web/apps/cast/src/services/chromecast.ts
+++ b/web/apps/cast/src/services/chromecast.ts
@@ -218,10 +218,10 @@ const advertiseCode = (cast: Cast) => {
* is kept at the top level to avoid passing it around.
*/
export const isChromecast = () => {
- let result = castReceiver.isChromecast;
- if (result === undefined) {
- result = window.navigator.userAgent.includes("CrKey");
- castReceiver.isChromecast = result;
+ let isCast = castReceiver.isChromecast;
+ if (isCast === undefined) {
+ isCast = window.navigator.userAgent.includes("CrKey");
+ castReceiver.isChromecast = isCast;
}
- return result;
+ return isCast;
};
diff --git a/web/apps/cast/src/services/render.ts b/web/apps/cast/src/services/render.ts
index a304d2dc65..cc06f5aa35 100644
--- a/web/apps/cast/src/services/render.ts
+++ b/web/apps/cast/src/services/render.ts
@@ -298,9 +298,15 @@ const createRenderableURL = async (castToken: string, file: EnteFile) => {
const renderableImageBlob = async (castToken: string, file: EnteFile) => {
let fileName = file.metadata.title;
- let blob = await downloadFile(castToken, file);
- if (file.metadata.fileType === FILE_TYPE.LIVE_PHOTO) {
+ // Chromecast devices (at least the 2nd gen one) is not powerful enough to
+ // do the WASM HEIC conversion, so for such files use their thumbnails
+ // instead. Nb: the check is using the filename and might not be accurate.
+ const shouldUseThumbnail = isChromecast() && isHEICExtension(fileName);
+
+ let blob = await downloadFile(castToken, file, shouldUseThumbnail);
+
+ if (!shouldUseThumbnail && file.metadata.fileType == FILE_TYPE.LIVE_PHOTO) {
const { imageData, imageFileName } = await decodeLivePhoto(
fileName,
blob,
@@ -316,23 +322,20 @@ const renderableImageBlob = async (castToken: string, file: EnteFile) => {
if (!mimeType)
throw new Error(`Could not detect MIME type for file ${fileName}`);
- if (!isChromecast()) {
- if (mimeType == "image/heif" || mimeType == "image/heic") {
- blob = await heicToJPEG(blob);
- }
- }
+ if (mimeType == "image/heif" || mimeType == "image/heic")
+ blob = await heicToJPEG(blob);
return new Blob([blob], { type: mimeType });
};
-const downloadFile = async (castToken: string, file: EnteFile) => {
- const fileName = file.metadata.title;
-
+const downloadFile = async (
+ castToken: string,
+ file: EnteFile,
+ shouldUseThumbnail: boolean,
+) => {
if (!isImageOrLivePhoto(file))
throw new Error("Can only cast images and live photos");
- const shouldUseThumbnail = isChromecast() && isHEICExtension(fileName);
-
const url = shouldUseThumbnail
? getCastThumbnailURL(file.id)
: getCastFileURL(file.id);