Skip to content

armgit / ente

Public Imported from GitHub
0

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

Show video controls disabled while file is loading

Anand Baburajan087f78848b02
diff --git a/web/apps/photos/src/styles/photoswipe.css b/web/apps/photos/src/styles/photoswipe.css
index 197c55efb0..6ca38ba76c 100644
--- a/web/apps/photos/src/styles/photoswipe.css
+++ b/web/apps/photos/src/styles/photoswipe.css
@@ -349,6 +349,7 @@
being attached to the video.
*/
.pswp-ente .pswp__media-controls {
+ display: none;
position: absolute;
bottom: 0px;
left: 0px;
@@ -395,9 +396,19 @@
flex-direction: column;
}
-/* Hide the controls if they're not associated to a media-controller. */
-media-control-bar:not([mediacontroller]) {
- display: none;
+/* Controls are shown in a disabled state while video data is still loading. */
+.pswp-ente .pswp__media-controls.pswp__media-controls--visible {
+ display: block;
+}
+
+.pswp-ente
+ .pswp__media-controls.pswp__media-controls--disabled
+ media-control-bar:not(:first-child),
+.pswp-ente
+ .pswp__media-controls.pswp__media-controls--disabled
+ media-playback-rate-menu {
+ opacity: 0.45;
+ pointer-events: none;
}
media-control-bar {
diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.ts
index c66401af92..449512aa56 100644
--- a/web/packages/gallery/components/viewer/photoswipe.ts
+++ b/web/packages/gallery/components/viewer/photoswipe.ts
@@ -769,10 +769,11 @@ export class FileViewerPhotoSwipe {
let shouldIgnoreNextVideoQualityChange = false;
/**
- * If a {@link mediaControllerID} is present in the given
- * {@link itemData}, then make the media controls visible and link the
- * media-control-bars (and other containers that house controls) to the
- * given controller. Otherwise hide the media controls.
+ * Update the media controls for the given {@link itemData}.
+ *
+ * - Show controls only for videos.
+ * - Keep controls visible but disabled while video playback is loading.
+ * - Link controls to the media controller once available.
*/
const updateVideoControlsAndPlayback = (itemData: ItemData) => {
// For reasons possibly related to the 1 tick wait in the hls-video
@@ -855,6 +856,20 @@ export class FileViewerPhotoSwipe {
const _updateVideoControlsAndPlayback = (itemData: ItemData) => {
const container = mediaControlsContainerElement;
+ const showVideoControls =
+ itemData.fileType == FileType.video && !itemData.fetchFailed;
+ const areVideoControlsDisabled =
+ showVideoControls &&
+ (!!itemData.isContentLoading || !itemData.mediaControllerID);
+ container?.classList.toggle(
+ "pswp__media-controls--visible",
+ showVideoControls,
+ );
+ container?.classList.toggle(
+ "pswp__media-controls--disabled",
+ areVideoControlsDisabled,
+ );
+
const controls =
container?.querySelectorAll(
"media-control-bar, media-playback-rate-menu",