UNPKG

@droppii-org/chat-sdk

Version:

Droppii React Chat SDK

21 lines (20 loc) 1.02 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { MessageStatus } from "@openim/wasm-client-sdk"; import { Spin } from "antd"; const min = (a, b) => (a > b ? b : a); const VideoMessageItem = (props) => { const { message } = props; const imageHeight = message.videoElem.snapshotHeight; const imageWidth = message.videoElem.snapshotWidth; const minHeight = min(200, imageWidth) * (imageHeight / imageWidth) + 2; const adaptedHight = min(minHeight, imageHeight) + 10; const adaptedWidth = min(imageWidth, 200) + 10; const sourceUrl = message.videoElem.videoUrl; const isSending = message.status === MessageStatus.Sending; const minStyle = { minHeight: `${adaptedHight}px`, minWidth: `${adaptedWidth}px`, }; return (_jsx(Spin, { spinning: isSending, children: _jsx("div", { className: "relative max-w-[200px]", style: minStyle, children: _jsx("video", { className: "rounded-md", src: sourceUrl, controls: true }) }) })); }; export default VideoMessageItem;