mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-27 11:24:43 +00:00
fix(search): preview matched video chunks on hover (#540)
* fix(search): preview matched video chunks on hover * fix(search): show chunk covers before hover * fix(search): reuse sprites for whole-video matches
This commit is contained in:
@@ -308,7 +308,9 @@ export function FileCard({
|
||||
|
||||
// A preview (poster thumbnail and/or sprite) can be available before transcoding finishes,
|
||||
// since the poster/sprite are generated and persisted ahead of the proxy transcodes.
|
||||
const hasPreview = Boolean(displayItem.preview?.thumbnailUrl || displayItem.preview?.spriteUrl)
|
||||
const hasPreview = Boolean(
|
||||
item.matchedSprite || displayItem.preview?.thumbnailUrl || displayItem.preview?.spriteUrl,
|
||||
)
|
||||
const isFailed = displayItem.status === 'failed'
|
||||
const isLocalUploader = Boolean(fileUploadState)
|
||||
const isUploadFailed = fileUploadState?.status === 'failed'
|
||||
@@ -520,9 +522,10 @@ export function FileCard({
|
||||
<FilePreview
|
||||
item={displayItem}
|
||||
showDuration={!isProcessing && !isFailed}
|
||||
matchedSprite={item.matchedSprite}
|
||||
matchDuration={
|
||||
displayItem.startTime != null && displayItem.endTime != null
|
||||
? { startTime: displayItem.startTime, endTime: displayItem.endTime }
|
||||
item.startTime != null && item.endTime != null
|
||||
? { startTime: item.startTime, endTime: item.endTime }
|
||||
: null
|
||||
}
|
||||
/>
|
||||
@@ -569,8 +572,8 @@ export function FileCard({
|
||||
item={displayItem}
|
||||
showDuration
|
||||
matchDuration={
|
||||
displayItem.startTime != null && displayItem.endTime != null
|
||||
? { startTime: displayItem.startTime, endTime: displayItem.endTime }
|
||||
item.startTime != null && item.endTime != null
|
||||
? { startTime: item.startTime, endTime: item.endTime }
|
||||
: null
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { File, Folder, AudioLines } from 'lucide-react'
|
||||
import type { MatchedSprite } from '@shumai/dtos'
|
||||
import { SpriteScrubber } from '../sprite-scrubber'
|
||||
import { formatTime } from '../viewers/video/utils'
|
||||
|
||||
@@ -20,13 +21,19 @@ type FilePreviewItem = {
|
||||
interface FilePreviewProps {
|
||||
item: FilePreviewItem
|
||||
showDuration?: boolean
|
||||
matchedSprite?: MatchedSprite
|
||||
matchDuration?: {
|
||||
startTime?: number | null
|
||||
endTime?: number | null
|
||||
} | null
|
||||
}
|
||||
|
||||
export const FilePreview = ({ item, showDuration = false, matchDuration }: FilePreviewProps) => {
|
||||
export const FilePreview = ({
|
||||
item,
|
||||
showDuration = false,
|
||||
matchedSprite,
|
||||
matchDuration,
|
||||
}: FilePreviewProps) => {
|
||||
const proxyType = item.preview?.proxyType || item.proxyType
|
||||
const isVideo = proxyType === 'video'
|
||||
const isAudio = proxyType === 'audio'
|
||||
@@ -56,21 +63,27 @@ export const FilePreview = ({ item, showDuration = false, matchDuration }: FileP
|
||||
</span>
|
||||
) : null
|
||||
|
||||
const isMediaWithSprite =
|
||||
(isVideo || isPdf || is3D) &&
|
||||
item.preview?.spriteUrl &&
|
||||
item.preview.thumbnailUrl &&
|
||||
item.preview.originalWidth &&
|
||||
item.preview.originalHeight
|
||||
const chunkSprite = hasMatchedChunk ? matchedSprite : undefined
|
||||
const canShowFullSprite =
|
||||
hasMatchedChunk ||
|
||||
((isVideo || isPdf || is3D) &&
|
||||
item.preview?.thumbnailUrl &&
|
||||
item.preview.originalWidth &&
|
||||
item.preview.originalHeight)
|
||||
const fullSpriteUrl = canShowFullSprite ? item.preview?.spriteUrl : undefined
|
||||
const spriteUrl = chunkSprite?.url || fullSpriteUrl
|
||||
|
||||
if (isMediaWithSprite && item.preview) {
|
||||
if (spriteUrl) {
|
||||
return (
|
||||
<>
|
||||
<SpriteScrubber
|
||||
spriteUrl={item.preview.spriteUrl!}
|
||||
thumbnailUrl={item.preview.thumbnailUrl!}
|
||||
videoWidth={item.preview.originalWidth!}
|
||||
videoHeight={item.preview.originalHeight!}
|
||||
spriteUrl={spriteUrl}
|
||||
spriteLayout={chunkSprite}
|
||||
showFirstFrame={Boolean(chunkSprite)}
|
||||
fallbackSpriteUrl={chunkSprite && fullSpriteUrl ? fullSpriteUrl : undefined}
|
||||
thumbnailUrl={item.preview?.thumbnailUrl}
|
||||
videoWidth={item.preview?.originalWidth}
|
||||
videoHeight={item.preview?.originalHeight}
|
||||
reverse={is3D}
|
||||
/>
|
||||
{overlay}
|
||||
|
||||
Reference in New Issue
Block a user