π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
move out and link - wip
Manav Rathi38c64ac05fcc
diff --git a/web/apps/photos/src/styles/photoswipe.css b/web/apps/photos/src/styles/photoswipe.cssindex 4f0679bae3..a1ad7edb33 100644--- a/web/apps/photos/src/styles/photoswipe.css+++ b/web/apps/photos/src/styles/photoswipe.css@@ -191,11 +191,15 @@/*Style the custom video controls we provide.- */+ - Center fit the video within the PhotoSwipe slide contents, but also ensuring+ it doesn't overflow.+ - Assumes that the slide's item data is specifying the width and height of the+ video.+ - The controls are absolutely position at the bottom of the screen instead of+ being attached to the video.+ */.pswp-ente .media-controller-container {- border: 1px solid limegreen;- box-sizing: border-box;max-width: 100%;max-height: 100%;display: flex;@@ -204,8 +208,6 @@}.pswp-ente .media-controller-container media-controller {- box-sizing: border-box;- border: 1px solid blue;max-width: 100%;max-height: 100%;}diff --git a/web/packages/gallery/components/viewer/data-source.ts b/web/packages/gallery/components/viewer/data-source.tsindex e67b61e59c..ae5d02ad82 100644--- a/web/packages/gallery/components/viewer/data-source.ts+++ b/web/packages/gallery/components/viewer/data-source.ts@@ -93,7 +93,8 @@ export type ItemData = PhotoSwipeSlideData & {* The renderable object URL of the video associated with the file.** - For images, this will not be defined.- * - For videos, this will be the object URL of a renderable video.+ * - For videos, this will be the object URL of a renderable video (but only+ * if {@link videoPlaylistURL} is not set).* - For live photos, this will be a renderable object URL of the video* portion of the live photo.*/@@ -109,6 +110,16 @@ export type ItemData = PhotoSwipeSlideData & {* time.*/videoPlaylistURL?: string;+ /**+ * The ID of the `media-controller` element that is showing the video.+ *+ * If present, this value will be used to display controls for controlling+ * the video wrapped by the media-controller.+ *+ * This is only set for videos that are streamed using HLS (i.e. videos for+ * which {@link videoPlaylistURL} has also been set).+ */+ mediaControllerElementID?: string;/*** `true` if we should indicate to the user that we're still fetching data* for this file.diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.tsindex dfa2df57b9..964828f003 100644--- a/web/packages/gallery/components/viewer/photoswipe.ts+++ b/web/packages/gallery/components/viewer/photoswipe.ts@@ -307,16 +307,18 @@ export class FileViewerPhotoSwipe {pswp.refreshSlideContent(index),);- const { videoURL, videoPlaylistURL, ...rest } = itemData;if (itemData.fileType === FileType.video) {+ const { videoURL, videoPlaylistURL } = itemData;if (videoPlaylistURL) {+ const mcID = `ente-mc-${file.id}`;return {- ...rest,- html: hlsVideoHTML(videoPlaylistURL, file.id),+ ...itemData,+ html: hlsVideoHTML(videoPlaylistURL, mcID),+ mediaControllerElementID: mcID,};} else if (videoURL) {return {- ...rest,+ ...itemData,html: videoHTML(videoURL, !!disableDownload),};}@@ -863,6 +865,36 @@ export class FileViewerPhotoSwipe {});},});++ ui.registerElement({+ name: "media-controls",+ // Arbitrary order towards the end (it doesn't matter anyways+ // since we're absolutely positioned).+ order: 31,+ appendTo: "root",+ html: hlsVideoControlsHTML(),+ onInit: (element, pswp) => {+ // TODO:+ // captionElement = element;+ pswp.on("change", () => {+ console.log("change", currSlideData());+ const { mediaControllerElementID } = currSlideData();+ // The PhotoSwipe CSS sets the display for this to be+ // block, so that's what we restore to when needed.+ element.style.display = mediaControllerElementID+ ? "block"+ : "none";+ if (mediaControllerElementID) {+ element+ .querySelector("media-control-bar")!+ .setAttribute(+ "mediacontroller",+ mediaControllerElementID,+ );+ }+ });+ },+ });});// Pan action handlers@@ -1089,17 +1121,26 @@ const videoHTML = (url: string, disableDownload: boolean) => `// import "media-chrome";//// TODO: Update code above that searches for the video element-const hlsVideoHTML = (url: string, fileID: number) => `+const hlsVideoHTML = (url: string, mediaControllerElementID: string) => `<div class="media-controller-container">- <media-controller id="ente-mc-${fileID}">+ <media-controller id="${mediaControllerElementID}"><hls-video slot="media" src="${url}"></hls-video></media-controller>- <media-control-bar mediacontroller="ente-mc-${fileID}">- <media-play-button></media-play-button>- </media-control-bar></div>`;+/**+ * HTML for controls associated with {@link hlsVideoHTML}.+ *+ * To make these functional, the `media-control-bar` requires the+ * `mediacontroller="${mediaControllerElementID}"` attribute.+ */+const hlsVideoControlsHTML = () => `+<media-control-bar>+ <media-play-button></media-play-button>+</media-control-bar>+`;+const livePhotoVideoHTML = (videoURL: string) => `<video loop muted oncontextmenu="return false;"><source src="${videoURL}" />