Skip to content

armgit / ente

Public Imported from GitHub
0

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

Chrome warnings

Manav Rathieaf576967bbb
diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.ts
index 686c7a10ad..185890ebee 100644
--- a/web/packages/gallery/components/viewer/photoswipe.ts
+++ b/web/packages/gallery/components/viewer/photoswipe.ts
@@ -347,7 +347,7 @@ export class FileViewerPhotoSwipe {
if (livePhotoPlay) {
button?.classList.remove("pswp-ente-off");
- void video.play();
+ void abortablePlayVideo(video);
video.style.display = "initial";
} else {
button?.classList.add("pswp-ente-off");
@@ -356,6 +356,29 @@ export class FileViewerPhotoSwipe {
}
};
+ /**
+ * A wrapper over video.play that prevents Chrome from spamming the
+ * console with errors about interrupted plays when scrolling through
+ * files fast by keeping arrow keys pressed.
+ */
+ const abortablePlayVideo = async (videoElement: HTMLVideoElement) => {
+ try {
+ await videoElement.play();
+ } catch (e) {
+ if (
+ e instanceof Error &&
+ e.name == "AbortError" &&
+ e.message.startsWith(
+ "The play() request was interrupted by a call to pause().",
+ )
+ ) {
+ // Ignore.
+ } else {
+ throw e;
+ }
+ }
+ };
+
/**
* Update the state of the given {@link videoElement} and the
* {@link livePhotoMuteButtonElement} to reflect {@link livePhotoMute}.