()
| 36 | import { formatTime } from "./utils"; |
| 37 | |
| 38 | export function PlayerContent() { |
| 39 | const { |
| 40 | project, |
| 41 | editorInstance, |
| 42 | setDialog, |
| 43 | totalDuration, |
| 44 | editorState, |
| 45 | setEditorState, |
| 46 | zoomOutLimit, |
| 47 | setProject, |
| 48 | previewResolutionBase, |
| 49 | previewQuality, |
| 50 | setPreviewQuality, |
| 51 | } = useEditorContext(); |
| 52 | |
| 53 | const previewOptions = [ |
| 54 | { label: "Full", value: "full" as EditorPreviewQuality }, |
| 55 | { label: "Half", value: "half" as EditorPreviewQuality }, |
| 56 | { label: "Quarter", value: "quarter" as EditorPreviewQuality }, |
| 57 | ]; |
| 58 | |
| 59 | const zoomHint = () => |
| 60 | ostype() === "windows" |
| 61 | ? "Hold Ctrl and scroll, or press Ctrl +/- to zoom" |
| 62 | : "Pinch, or press Cmd +/- to zoom"; |
| 63 | |
| 64 | // Load captions on mount |
| 65 | onMount(async () => { |
| 66 | if (editorInstance?.path) { |
| 67 | await captionsStore.loadCaptions(editorInstance.path); |
| 68 | |
| 69 | if (editorInstance && project) { |
| 70 | const updatedProject = { ...project }; |
| 71 | let projectDidChange = false; |
| 72 | const captionSegments = captionsStore.state.segments; |
| 73 | const hasStoredCaptions = captionSegments.length > 0; |
| 74 | |
| 75 | if (!updatedProject.captions && hasStoredCaptions) { |
| 76 | updatedProject.captions = { |
| 77 | segments: captionSegments.map((segment) => ({ |
| 78 | id: segment.id, |
| 79 | start: segment.start, |
| 80 | end: segment.end, |
| 81 | text: segment.text, |
| 82 | })), |
| 83 | settings: { ...captionsStore.state.settings }, |
| 84 | sourceTimed: true, |
| 85 | }; |
| 86 | projectDidChange = true; |
| 87 | } |
| 88 | |
| 89 | if ( |
| 90 | hasStoredCaptions && |
| 91 | (updatedProject.timeline?.captionSegments?.length ?? 0) === 0 |
| 92 | ) { |
| 93 | updatedProject.timeline = { |
| 94 | ...(updatedProject.timeline ?? { |
| 95 | segments: [ |
nothing calls this directly
no test coverage detected