From f2a2a6bea072f43755d15042156aaec9a100d40d Mon Sep 17 00:00:00 2001 From: Jaret Burkett Date: Tue, 15 Sep 2026 05:32:13 -0600 Subject: [PATCH] Make audio files in dataset be thumbnails until clicked and opened inn the viewer --- ui/src/components/DatasetImageCard.tsx | 40 +++++++++++++++----------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/ui/src/components/DatasetImageCard.tsx b/ui/src/components/DatasetImageCard.tsx index c03ce0a..28facd3 100644 --- a/ui/src/components/DatasetImageCard.tsx +++ b/ui/src/components/DatasetImageCard.tsx @@ -1,9 +1,8 @@ import React, { useEffect, useState, ReactNode, KeyboardEvent, useRef } from 'react'; -import { FaTrashAlt, FaPlay } from 'react-icons/fa'; +import { FaTrashAlt, FaPlay, FaMusic } from 'react-icons/fa'; import { openConfirm } from './ConfirmModal'; import classNames from 'classnames'; import { apiClient } from '@/utils/api'; -import AudioPlayer from './AudioPlayer'; import { isVideo, isAudio, encodeFilePathForUrl } from '@/utils/basic'; import useCaptionBatch, { setCachedCaption } from '@/hooks/useCaptionBatch'; @@ -35,7 +34,7 @@ const DatasetImageCard: React.FC = ({ captionExt = 'txt', }) => { const [loaded, setLoaded] = useState(false); - const [showAudioPlayer, setShowAudioPlayer] = useState(true); + const [artFailed, setArtFailed] = useState(false); const [pollTick, setPollTick] = useState(0); const [blobUrl, setBlobUrl] = useState(null); const [streamVideo, setStreamVideo] = useState(false); @@ -224,24 +223,31 @@ const DatasetImageCard: React.FC = ({ muted /> )} - {isItAudio && !showAudioPlayer && ( + {isItAudio && (
setShowAudioPlayer(true)} + className={classNames('w-full h-full flex items-center justify-center bg-gray-900', { + 'cursor-zoom-in': !!onImageClick, + })} + onClick={onImageClick} > - {alt} { - (e.target as HTMLImageElement).style.display = 'none'; - }} - /> + {isVisible && !artFailed ? ( + {alt} setArtFailed(true)} + /> + ) : ( + + )} +
+ {imageUrl.replace(/^.*[\\/]/, '')} +
+
+ +
)} - {isItAudio && showAudioPlayer && ( - - )} {!isItAudio && blobUrl && (