Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots 📖

feat(player): mark the steps that are spoken

Luis Ortizffd495689206
diff --git a/src/core/export/video-export.ts b/src/core/export/video-export.ts
index 6a65b93..09ba1f5 100644
--- a/src/core/export/video-export.ts
+++ b/src/core/export/video-export.ts
@@ -22,7 +22,7 @@ import {
VOICE_LEAD_SEC,
voiceTimeline,
} from '@/core/export/video-support';
-import { COVER_SEGMENT } from '@/core/export/voiceover/script';
+import { COVER_SEGMENT, stepNarration } from '@/core/export/voiceover/script';
import { actionSteps, calloutAccent, isBlock } from '@/core/guides/blocks';
import type { BlockType, Guide, Screenshot, Step } from '@/core/guides/types';
import type { Ctx } from '@/core/screenshot/draw';
@@ -704,6 +704,7 @@ export interface VideoChapter {
kind: StepKind;
start: number;
end: number;
+ spoken: boolean;
}
export function stepKind(step: Step): StepKind {
@@ -736,6 +737,7 @@ export function videoChapters(frames: Step[], cover: boolean, fps = FPS, timelin
kind: stepKind(step),
start: offset + starts[index] / fps,
end: index === frames.length - 1 ? last : offset + starts[index + 1] / fps,
+ spoken: stepNarration(step).length > 0,
}));
}
diff --git a/src/locales/de.yml b/src/locales/de.yml
index aa673f3..26f81b1 100644
--- a/src/locales/de.yml
+++ b/src/locales/de.yml
@@ -372,6 +372,7 @@ videoPlayer:
speed: "Wiedergabegeschwindigkeit"
mute: "Stummschalten"
unmute: "Ton einschalten"
+ spoken: "Vertonter Schritt"
exportMenu:
docx: "DOCX"
diff --git a/src/locales/en.yml b/src/locales/en.yml
index ca0553e..97e89eb 100644
--- a/src/locales/en.yml
+++ b/src/locales/en.yml
@@ -441,6 +441,7 @@ videoPlayer:
speed: "Playback speed"
mute: "Mute"
unmute: "Unmute"
+ spoken: "Narrated step"
exportMenu:
docx: DOCX
diff --git a/src/locales/es.yml b/src/locales/es.yml
index 9ea1235..79dcc39 100644
--- a/src/locales/es.yml
+++ b/src/locales/es.yml
@@ -441,6 +441,7 @@ videoPlayer:
speed: "Velocidad de reproducción"
mute: "Silenciar"
unmute: "Activar sonido"
+ spoken: "Paso narrado"
exportMenu:
docx: DOCX
diff --git a/src/locales/fr.yml b/src/locales/fr.yml
index a89f115..4b0d3bf 100644
--- a/src/locales/fr.yml
+++ b/src/locales/fr.yml
@@ -441,6 +441,7 @@ videoPlayer:
speed: "Vitesse de lecture"
mute: "Couper le son"
unmute: "Activer le son"
+ spoken: "Étape narrée"
exportMenu:
docx: DOCX
diff --git a/src/locales/pt-BR.yml b/src/locales/pt-BR.yml
index 6af28e2..7220d33 100644
--- a/src/locales/pt-BR.yml
+++ b/src/locales/pt-BR.yml
@@ -441,6 +441,7 @@ videoPlayer:
speed: "Velocidade de reprodução"
mute: "Silenciar"
unmute: "Ativar som"
+ spoken: "Passo narrado"
exportMenu:
docx: DOCX
diff --git a/src/locales/zh-CN.yml b/src/locales/zh-CN.yml
index cbc2edc..2aa5a3c 100644
--- a/src/locales/zh-CN.yml
+++ b/src/locales/zh-CN.yml
@@ -441,6 +441,7 @@ videoPlayer:
speed: "播放速度"
mute: "静音"
unmute: "取消静音"
+ spoken: "已配音的步骤"
exportMenu:
docx: DOCX
diff --git a/src/ui/fullview/VideoStepPlayer.tsx b/src/ui/fullview/VideoStepPlayer.tsx
index 08e7f55..f3a1b31 100644
--- a/src/ui/fullview/VideoStepPlayer.tsx
+++ b/src/ui/fullview/VideoStepPlayer.tsx
@@ -42,13 +42,33 @@ function activeIndex(chapters: VideoChapter[], time: number): number {
return -1;
}
+const WAVE_BARS = [3, 7, 4, 8, 5];
+
+function SpokenMark({ talking }: { talking: boolean }) {
+ return (
+ <span role="img" aria-label={i18n.t('videoPlayer.spoken')} className="mt-1 flex shrink-0 items-center gap-[2px]">
+ {WAVE_BARS.map((height, i) => (
+ <span
+ key={height}
+ className={`w-[2px] rounded-[1px] ${talking ? 'animate-talk bg-lavender' : 'bg-lavender/70'}`}
+ style={{ height: `${height}px`, animationDelay: talking ? `${i * 90}ms` : undefined }}
+ />
+ ))}
+ </span>
+ );
+}
+
function StepList({
chapters,
index,
+ narrated,
+ playing,
onJump,
}: {
chapters: VideoChapter[];
index: number;
+ narrated: boolean;
+ playing: boolean;
onJump: (n: number) => void;
}) {
const list = useRef<HTMLElement>(null);
@@ -73,6 +93,7 @@ function StepList({
>
<span className={`mt-1.5 size-1.5 shrink-0 rounded-full ${KIND_DOT[chapter.kind]}`} />
<span className="min-w-0 flex-1 text-[10.5px] leading-snug text-white/80">{chapter.title}</span>
+ {narrated && chapter.spoken && <SpokenMark talking={playing && i === index} />}
<span className="pt-0.5 font-mono text-[9px] tabular-nums text-white/40">{formatClock(chapter.start)}</span>
</button>
))}
@@ -80,7 +101,7 @@ function StepList({
);
}
-function PlayerBody({ chapters }: { chapters: VideoChapter[] }) {
+function PlayerBody({ chapters, narrated }: { chapters: VideoChapter[]; narrated: boolean }) {
const remote = useMediaRemote();
const time = useMediaState('currentTime');
const duration = useMediaState('duration');
@@ -170,7 +191,7 @@ export default function VideoStepPlayer({ src, type, chapters, narrated = false
className="flex size-full"
style={{ backgroundColor: FRAME_FILL }}
>
- <PlayerBody chapters={chapters} />
+ <PlayerBody chapters={chapters} narrated={narrated} />
</MediaPlayer>
);
}
diff --git a/src/ui/global.css b/src/ui/global.css
index da58704..64e86f3 100644
--- a/src/ui/global.css
+++ b/src/ui/global.css
@@ -77,3 +77,19 @@ input[type="checkbox"]:not(:disabled) {
@utility animate-blink {
animation: blink 0.7s step-end infinite;
}
+
+@keyframes talk {
+ 0%, 100% { transform: scaleY(0.35); }
+ 50% { transform: scaleY(1); }
+}
+
+@utility animate-talk {
+ animation: talk 0.72s ease-in-out infinite;
+ transform-origin: center;
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .animate-talk {
+ animation: none;
+ }
+}