Skip to content

armgit / ente

Public Imported from GitHub
0

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

refractor(memories):share-remove-mute

Aswin Asokdd5dac01b18d
diff --git a/web/apps/memories/src/components/LaneMemoryViewer.tsx b/web/apps/memories/src/components/LaneMemoryViewer.tsx
index d075f4a7c7..95b8144971 100644
--- a/web/apps/memories/src/components/LaneMemoryViewer.tsx
+++ b/web/apps/memories/src/components/LaneMemoryViewer.tsx
@@ -4,8 +4,6 @@
* playback timing, scrubbing, captions, and decorative backgrounds. It is
* rendered by `pages/index.tsx` for the `"lane"` variant.
*/
-import VolumeOffRoundedIcon from "@mui/icons-material/VolumeOffRounded";
-import VolumeUpRoundedIcon from "@mui/icons-material/VolumeUpRounded";
import { styled, Typography } from "@mui/material";
import log from "ente-base/log";
import { downloadManager } from "ente-gallery/services/download";
@@ -101,7 +99,6 @@ export function LaneMemoryViewer({
onSeek,
}: LaneMemoryViewerProps) {
const [paused, setPaused] = useState(false);
- const [muted, setMuted] = useState(false);
const [fileLoaded, setFileLoaded] = useState(false);
const [videoDurationKnown, setVideoDurationKnown] = useState(false);
const [viewport, setViewport] = useState({ width: 1280, height: 720 });
@@ -437,7 +434,7 @@ export function LaneMemoryViewer({
return;
}
- activeVideo.muted = muted;
+ activeVideo.muted = false;
void activeVideo.play().catch((error: unknown) => {
log.warn(
"Failed to start lane memory video playback from user gesture",
@@ -445,20 +442,12 @@ export function LaneMemoryViewer({
);
handleVideoPlaybackBlocked();
});
- }, [handleVideoPlaybackBlocked, muted, onSeek]);
+ }, [handleVideoPlaybackBlocked, onSeek]);
const pauseLanePlayback = useCallback(() => {
setPaused(true);
}, []);
- const handleAudioToggle = useCallback(
- (event: ReactMouseEvent<HTMLButtonElement>) => {
- event.stopPropagation();
- setMuted((previous) => !previous);
- },
- [],
- );
-
const handlePlaybackToggle = useCallback(
(event: ReactMouseEvent<HTMLButtonElement>) => {
event.stopPropagation();
@@ -639,10 +628,6 @@ export function LaneMemoryViewer({
[commitDisplayIndex, files.length, onSeek, trackScrubValue],
);
- useEffect(() => {
- setMuted(false);
- }, [displayIndex]);
-
const showPlaybackOverlay = paused && !isScrubbing;
const playbackOverlayLabel = finishedLanePlaybackRef.current
? "Restart memory lane"
@@ -769,7 +754,6 @@ export function LaneMemoryViewer({
isDisplayCard ? (
<VideoPlayer
file={file}
- muted={muted}
paused={paused}
mediaRef={
activeVideoElementRef
@@ -842,26 +826,6 @@ export function LaneMemoryViewer({
</LaneStackSlice>
);
})}
- {isVideo && (
- <LaneTopRightAudioOverlay>
- <LaneAudioControl
- type="button"
- onClick={handleAudioToggle}
- aria-label={
- muted
- ? "Unmute video"
- : "Mute video"
- }
- data-memory-control="true"
- >
- {muted ? (
- <VolumeOffRoundedIcon fontSize="small" />
- ) : (
- <VolumeUpRoundedIcon fontSize="small" />
- )}
- </LaneAudioControl>
- </LaneTopRightAudioOverlay>
- )}
{showPlaybackOverlay && (
<LaneCornerPlaybackOverlay>
<LaneCornerPlaybackControl
@@ -1315,57 +1279,6 @@ const LaneCaption = styled("div")({
},
});
-const LaneTopRightAudioOverlay = styled("div")({
- position: "absolute",
- top: 0,
- right: 0,
- zIndex: 4,
- display: "flex",
- alignItems: "flex-start",
- justifyContent: "flex-end",
- padding: "20px",
- pointerEvents: "none",
- "@media (max-width: 900px)": { padding: "18px" },
- [`@media (max-width: ${MOBILE_LAYOUT_BREAKPOINT_PX}px)`]: {
- padding: "14px",
- },
-});
-
-const LaneAudioControl = styled("button")({
- width: "42px",
- height: "42px",
- borderRadius: "999px",
- border: 0,
- cursor: "pointer",
- padding: 0,
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- color: "white",
- backgroundColor: "rgba(18, 18, 18, 0.68)",
- boxShadow: "0 18px 40px rgba(0, 0, 0, 0.34)",
- backdropFilter: "blur(10px)",
- WebkitBackdropFilter: "blur(10px)",
- transition:
- "transform 150ms ease, background-color 150ms ease, box-shadow 150ms ease",
- pointerEvents: "auto",
- "&:hover": {
- backgroundColor: "rgba(18, 18, 18, 0.76)",
- transform: "scale(1.03)",
- },
- "&:active": { transform: "scale(0.98)" },
- "& .MuiSvgIcon-root": { fontSize: "22px" },
- "@media (max-width: 900px)": {
- width: "40px",
- height: "40px",
- },
- [`@media (max-width: ${MOBILE_LAYOUT_BREAKPOINT_PX}px)`]: {
- width: "36px",
- height: "36px",
- "& .MuiSvgIcon-root": { fontSize: "20px" },
- },
-});
-
const LaneCornerPlaybackOverlay = styled("div")({
position: "absolute",
inset: 0,
diff --git a/web/apps/memories/src/components/MemoryViewer.tsx b/web/apps/memories/src/components/MemoryViewer.tsx
index 0acfc3d66a..fd0b145ef4 100644
--- a/web/apps/memories/src/components/MemoryViewer.tsx
+++ b/web/apps/memories/src/components/MemoryViewer.tsx
@@ -6,8 +6,6 @@
* variant.
*/
import { keyframes } from "@emotion/react";
-import VolumeOffRoundedIcon from "@mui/icons-material/VolumeOffRounded";
-import VolumeUpRoundedIcon from "@mui/icons-material/VolumeUpRounded";
import { styled, Typography } from "@mui/material";
import log from "ente-base/log";
import { downloadManager } from "ente-gallery/services/download";
@@ -130,7 +128,6 @@ export function MemoryViewer({
}: MemoryViewerProps) {
const currentFile = files[currentIndex]!;
const [paused, setPaused] = useState(false);
- const [muted, setMuted] = useState(false);
const [fileLoaded, setFileLoaded] = useState(false);
const [videoDurationKnown, setVideoDurationKnown] = useState(false);
const [progressDuration, setProgressDuration] = useState(
@@ -157,7 +154,6 @@ export function MemoryViewer({
useEffect(() => {
setPaused(false);
- setMuted(false);
setFinishedPlayback(false);
setFileLoaded(false);
setVideoDurationKnown(false);
@@ -223,7 +219,7 @@ export function MemoryViewer({
video.currentTime = 0;
}
- video.muted = muted;
+ video.muted = false;
void video.play().catch((error: unknown) => {
log.warn(
"Failed to start memory video playback from user gesture",
@@ -232,7 +228,7 @@ export function MemoryViewer({
handleVideoPlaybackBlocked();
});
},
- [handleVideoPlaybackBlocked, muted],
+ [handleVideoPlaybackBlocked],
);
const handleMediaAspectRatio = useCallback(
@@ -344,14 +340,6 @@ export function MemoryViewer({
[finishedPlayback, handleRestartPlayback, isVideo, resumeCurrentVideoPlayback],
);
- const handleAudioToggle = useCallback(
- (event: ReactMouseEvent<HTMLButtonElement>) => {
- event.stopPropagation();
- setMuted((previous) => !previous);
- },
- [],
- );
-
const handleViewerClick = useCallback(
(event: ReactMouseEvent<HTMLDivElement>) => {
if (isInteractiveTapTarget(event.target)) {
@@ -508,7 +496,6 @@ export function MemoryViewer({
onEnded={handleAdvanceOrFinish}
onPlaybackBlocked={handleVideoPlaybackBlocked}
mediaRef={activeVideoElementRef}
- muted={muted}
paused={paused}
fillFrame
objectFit="contain"
@@ -636,24 +623,6 @@ export function MemoryViewer({
onClick={handleMediaFrameClick}
>
{mediaLayers}
- {isVideo && (
- <TopRightMediaAudioOverlay>
- <MediaAudioControl
- type="button"
- onClick={handleAudioToggle}
- aria-label={
- muted ? "Unmute video" : "Mute video"
- }
- data-memory-control="true"
- >
- {muted ? (
- <VolumeOffRoundedIcon fontSize="small" />
- ) : (
- <VolumeUpRoundedIcon fontSize="small" />
- )}
- </MediaAudioControl>
- </TopRightMediaAudioOverlay>
- )}
{showPlaybackOverlay && (
<CenteredPlaybackOverlay>
<CenteredPlaybackControl
@@ -848,57 +817,6 @@ const MediaSwitchLayer = styled("div", {
pointerEvents: "none",
}));
-const TopRightMediaAudioOverlay = styled("div")({
- position: "absolute",
- top: "18px",
- right: "18px",
- zIndex: 4,
- display: "flex",
- alignItems: "center",
- justifyContent: "flex-end",
- pointerEvents: "none",
- "@media (max-width: 900px)": { top: "16px", right: "16px" },
- [`@media (max-width: ${MOBILE_LAYOUT_BREAKPOINT_PX}px)`]: {
- top: "12px",
- right: "12px",
- },
-});
-
-const MediaAudioControl = styled("button")({
- width: "42px",
- height: "42px",
- borderRadius: "999px",
- border: 0,
- cursor: "pointer",
- padding: 0,
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- color: "white",
- backgroundColor: "rgba(18, 18, 18, 0.68)",
- boxShadow: "0 18px 40px rgba(0, 0, 0, 0.34)",
- backdropFilter: "blur(10px)",
- WebkitBackdropFilter: "blur(10px)",
- transition:
- "transform 150ms ease, background-color 150ms ease, box-shadow 150ms ease",
- pointerEvents: "auto",
- "&:hover": {
- backgroundColor: "rgba(18, 18, 18, 0.76)",
- transform: "scale(1.03)",
- },
- "&:active": { transform: "scale(0.98)" },
- "& .MuiSvgIcon-root": { fontSize: "22px" },
- "@media (max-width: 900px)": {
- width: "40px",
- height: "40px",
- },
- [`@media (max-width: ${MOBILE_LAYOUT_BREAKPOINT_PX}px)`]: {
- width: "36px",
- height: "36px",
- "& .MuiSvgIcon-root": { fontSize: "20px" },
- },
-});
-
const CenteredPlaybackOverlay = styled("div")({
position: "absolute",
inset: 0,