feat(video): cross-platform inline player + polished overlay controls
- MessageInlineVideo (new): custom-controlled inline video that disables
the iOS Safari / Chromium native overlays entirely and reimplements
the essentials: tap-to-play, centered play affordance while paused,
bottom bar with play/pause + current time + drag-to-scrub progress
bar + remaining time + fullscreen. Pointer events with pointer
capture cover both mouse and touch scrubbing, including dragging
past the bar's bounds. The element listens to 'seeked' as well as
'timeupdate' so external currentTime writes paint the bar even when
the video is paused, and the goFullscreen callback synchronously
syncs React state on close so the inline progress reflects the user's
fullscreen playhead with no perceptible delay.
- VideoBubble: replace the inline <video controls> with
MessageInlineVideo and thread postId through openVideo so the
fullscreen overlay can attach the download pill to the right post.
- VideoPlayer overlay: replace its <video controls> with
MessageInlineVideo size='lg', removing the iOS native arrows / PiP /
mute / overflow controls. The overlay supplies its own large
download pill and a beefier close button.
- AttachmentDownloadPill: new 'size' prop ('sm' default 30 px, 'lg'
44 px with 22 px icon and text-[14px]) for overlay surfaces where
the affordance can breathe and should feel touch-friendly.
- ImageLightbox: drop the inline LightboxDownloadButton and use the
shared AttachmentDownloadPill size='lg' instead, with a matching
larger close button. Unused imports cleaned up.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { LoaderCircle, Play, X } from "lucide-react";
|
||||
import { DownloadCloudIcon } from "../../icons/DownloadCloudIcon";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import { useI18n } from "../../../i18n";
|
||||
import type { Attachment, Post } from "../../../types/post";
|
||||
import { AttachmentDownloadPill } from "../AttachmentDownloadPill";
|
||||
import { MessageInlineVideo } from "../MessageInlineVideo";
|
||||
import { useVideoPlayer } from "../overlays/VideoPlayer";
|
||||
import { autolink } from "../utils/autolink";
|
||||
import { CollapsibleText } from "../CollapsibleText";
|
||||
@@ -56,7 +57,6 @@ function VideoAttachmentCard({
|
||||
}) {
|
||||
const { openVideo } = useVideoPlayer();
|
||||
const [playing, setPlaying] = useState(false);
|
||||
const videoRef = useRef<HTMLVideoElement>(null);
|
||||
const posterUrl = attachment.posterUrl ?? attachment.thumbnailUrl;
|
||||
const duration = formatDuration(attachment.durationSec);
|
||||
const previewVideoUrl = attachment.url.includes("#")
|
||||
@@ -73,26 +73,11 @@ function VideoAttachmentCard({
|
||||
style={compact ? undefined : { aspectRatio: videoRatio(attachment) }}
|
||||
>
|
||||
{playing && !compact ? (
|
||||
<>
|
||||
<video
|
||||
ref={videoRef}
|
||||
src={attachment.url}
|
||||
poster={attachment.posterUrl}
|
||||
controls
|
||||
controlsList="nodownload noplaybackrate noremoteplayback"
|
||||
disablePictureInPicture
|
||||
playsInline
|
||||
autoPlay
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
className="ark-message-video absolute inset-0 h-full w-full"
|
||||
/>
|
||||
<AttachmentDownloadPill
|
||||
postId={postId}
|
||||
attachment={attachment}
|
||||
leadingLabel={duration}
|
||||
className="absolute left-2 top-2 z-20"
|
||||
/>
|
||||
</>
|
||||
<MessageInlineVideo
|
||||
postId={postId}
|
||||
attachment={attachment}
|
||||
leadingLabel={duration}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
{posterUrl ? (
|
||||
@@ -141,7 +126,7 @@ function VideoAttachmentCard({
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
if (compact) openVideo(attachment, 0);
|
||||
if (compact) openVideo(attachment, 0, undefined, postId);
|
||||
else setPlaying(true);
|
||||
}}
|
||||
className="absolute inset-0 flex items-center justify-center"
|
||||
@@ -370,7 +355,7 @@ export function VideoBubble({ post }: { post: Post }) {
|
||||
onClose={() => setListOpen(false)}
|
||||
onPick={(att) => {
|
||||
setListOpen(false);
|
||||
openVideo(att, 0);
|
||||
openVideo(att, 0, undefined, post.id);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
Reference in New Issue
Block a user