完成转录功能,中文脚本搜索,播放界面显示脚本
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useMemo, useRef } from "react";
|
||||
import { useMemo, useRef, useState } from "react";
|
||||
import { Pause, Play } from "lucide-react";
|
||||
import type { AwemeData, ImageData, Neighbors, VideoData } from "./types.ts";
|
||||
import type { AwemeData, ImageData, Neighbors, VideoData, VideoTranscript } from "./types.ts";
|
||||
import { BackgroundCanvas } from "./components/BackgroundCanvas";
|
||||
import { CommentPanel } from "./components/CommentPanel";
|
||||
import { ImageCarousel } from "./components/ImageCarousel";
|
||||
import { ImageNavigationButtons } from "./components/ImageNavigationButtons";
|
||||
import { MediaControls } from "./components/MediaControls";
|
||||
import { NavigationButtons } from "./components/NavigationButtons";
|
||||
import { TranscriptPanel } from "./components/TranscriptPanel";
|
||||
import { VideoPlayer } from "./components/VideoPlayer";
|
||||
import { useBackgroundCanvas } from "./hooks/useBackgroundCanvas";
|
||||
import { useCommentState } from "./hooks/useCommentState";
|
||||
@@ -17,21 +18,24 @@ import { useImageCarousel } from "./hooks/useImageCarousel";
|
||||
import { useNavigation } from "./hooks/useNavigation";
|
||||
import { usePlayerState } from "./hooks/usePlayerState";
|
||||
import { useVideoPlayer } from "./hooks/useVideoPlayer";
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
||||
const SEGMENT_MS = 4000;
|
||||
|
||||
interface AwemeDetailClientProps {
|
||||
data: AwemeData;
|
||||
neighbors: Neighbors;
|
||||
transcript: VideoTranscript | null;
|
||||
}
|
||||
|
||||
export default function AwemeDetailClient({ data, neighbors }: AwemeDetailClientProps) {
|
||||
export default function AwemeDetailClient({ data, neighbors, transcript }: AwemeDetailClientProps) {
|
||||
const router = useRouter();
|
||||
const isVideo = data.type === "video";
|
||||
|
||||
// 状态管理
|
||||
const playerState = usePlayerState();
|
||||
const commentState = useCommentState();
|
||||
const [transcriptOpen, setTranscriptOpen] = useState(false);
|
||||
|
||||
// 引用
|
||||
const mediaContainerRef = useRef<HTMLDivElement | null>(null);
|
||||
@@ -284,6 +288,8 @@ export default function AwemeDetailClient({ data, neighbors }: AwemeDetailClient
|
||||
segmentProgress={imageCarouselState.segProgress}
|
||||
musicUrl={isVideo ? undefined : (data as ImageData).music_url}
|
||||
audioRef={audioRef}
|
||||
hasTranscript={isVideo && !!transcript?.speech_detected}
|
||||
onShowTranscript={() => setTranscriptOpen(true)}
|
||||
onTogglePlay={togglePlay}
|
||||
onSeek={seekTo}
|
||||
onVolumeChange={playerState.setVolume}
|
||||
@@ -316,6 +322,13 @@ export default function AwemeDetailClient({ data, neighbors }: AwemeDetailClient
|
||||
awemeId={data.aweme_id}
|
||||
mounted={commentState.mounted}
|
||||
/>
|
||||
|
||||
{/* 转录面板 */}
|
||||
<TranscriptPanel
|
||||
open={transcriptOpen}
|
||||
onClose={() => setTranscriptOpen(false)}
|
||||
transcript={transcript}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user