🎥 Make videos programmatically with React
Elements: Simplify waveform progress display
Igor Samokhovetsa0b059c960b7
diff --git a/packages/docs/elements/audio/waveform-progress/audio-waveform-progress.tsx b/packages/docs/elements/audio/waveform-progress/audio-waveform-progress.tsxindex ad6c3eb6c8..f3b6222176 100644--- a/packages/docs/elements/audio/waveform-progress/audio-waveform-progress.tsx+++ b/packages/docs/elements/audio/waveform-progress/audio-waveform-progress.tsx@@ -25,9 +25,6 @@ type AudioWaveformProgressProps = InteractiveBaseProps &readonly barGap?: number;readonly numberOfBars?: number;readonly playedColor?: string;- readonly showPlayhead?: boolean;- readonly showTimestamps?: boolean;- readonly timestampColor?: string;readonly unplayedColor?: string;};@@ -49,11 +46,6 @@ const audioWaveformProgressSchema = {default: '#cbd5e1',description: 'Unplayed color',},- timestampColor: {- type: 'color',- default: '#475569',- description: 'Timestamp color',- },numberOfBars: {type: 'number',min: 12,@@ -83,18 +75,6 @@ const audioWaveformProgressSchema = {description: 'Amplitude',hiddenFromList: false,},- showPlayhead: {- type: 'boolean',- default: true,- description: 'Show playhead',- keyframable: false,- },- showTimestamps: {- type: 'boolean',- default: true,- description: 'Show elapsed and total time',- keyframable: false,- },...Interactive.transformSchema,} as const satisfies InteractivitySchema;@@ -105,9 +85,6 @@ const AudioWaveformProgressContent: React.FC<{readonly durationInFrames: number;readonly numberOfBars: number;readonly playedColor: string;- readonly showPlayhead: boolean;- readonly showTimestamps: boolean;- readonly timestampColor: string;readonly unplayedColor: string;}> = ({amplitude,@@ -116,9 +93,6 @@ const AudioWaveformProgressContent: React.FC<{durationInFrames,numberOfBars,playedColor,- showPlayhead,- showTimestamps,- timestampColor,unplayedColor,}) => {const frame = useCurrentFrame();@@ -152,15 +126,6 @@ const AudioWaveformProgressContent: React.FC<{0,Math.min(1, frame / Math.max(1, durationInFrames - 1)),);- const elapsedWholeSeconds = Math.min(- Math.floor(durationInSeconds),- Math.floor(progress * durationInSeconds),- );- const totalWholeSeconds = Math.floor(durationInSeconds);- const elapsedMinutes = Math.floor(elapsedWholeSeconds / 60);- const elapsedSeconds = elapsedWholeSeconds % 60;- const totalMinutes = Math.floor(totalWholeSeconds / 60);- const totalSeconds = totalWholeSeconds % 60;const resolvedBarGap = Math.max(0, Math.min(8, barGap));const barWidth =(884 - resolvedBarGap * (roundedNumberOfBars - 1)) / roundedNumberOfBars;@@ -198,35 +163,10 @@ const AudioWaveformProgressContent: React.FC<{rx={Math.min(barWidth / 2, barHeight / 2)}width={barWidth}x={8 + index * (barWidth + resolvedBarGap)}- y={122 - barHeight / 2}+ y={150 - barHeight / 2}/>);})}- {showPlayhead ? (- <line- x1={8 + progress * 884}- x2={8 + progress * 884}- y1={7}- y2={237}- stroke={playedColor}- strokeLinecap="round"- strokeWidth={3}- />- ) : null}- {showTimestamps ? (- <text- x={892}- y={286}- fill={timestampColor}- fontFamily="Arial, sans-serif"- fontSize={32}- fontWeight={500}- textAnchor="end"- >- {elapsedMinutes}:{elapsedSeconds.toString().padStart(2, '0')} /{' '}- {totalMinutes}:{totalSeconds.toString().padStart(2, '0')}- </text>- ) : null}</svg></>);@@ -248,10 +188,7 @@ const AudioWaveformProgressInner = forwardRef<name,numberOfBars = 64,playedColor = '#0b84f3',- showPlayhead = true,- showTimestamps = true,style,- timestampColor = '#475569',unplayedColor = '#cbd5e1',...sequenceProps},@@ -287,9 +224,6 @@ const AudioWaveformProgressInner = forwardRef<durationInFrames={durationInFrames}numberOfBars={numberOfBars}playedColor={playedColor}- showPlayhead={showPlayhead}- showTimestamps={showTimestamps}- timestampColor={timestampColor}unplayedColor={unplayedColor}/></div>diff --git a/packages/docs/elements/audio/waveform-progress/index.mdx b/packages/docs/elements/audio/waveform-progress/index.mdxindex b083e0a3f0..473e1c6d93 100644--- a/packages/docs/elements/audio/waveform-progress/index.mdx+++ b/packages/docs/elements/audio/waveform-progress/index.mdx@@ -1,6 +1,6 @@---title: Audio Waveform Progress-description: A full-clip audio waveform with played progress, a playhead, and timestamps.+description: A full-clip audio waveform with played progress.image: https://remotion.media/elements/audio-waveform-progress-preview.png---diff --git a/packages/docs/src/components/Elements/element-definitions.ts b/packages/docs/src/components/Elements/element-definitions.tsindex 22edbadde6..f3d2e7c6f4 100644--- a/packages/docs/src/components/Elements/element-definitions.ts+++ b/packages/docs/src/components/Elements/element-definitions.ts@@ -109,8 +109,7 @@ const elementImplementations = {'audio/waveform-progress': {component: AudioWaveformProgress,contributors: [{username: 'samohovets', contribution: 'Author'}],- description:- 'A full-clip audio waveform with played progress, a playhead, and timestamps.',+ description: 'A full-clip audio waveform with played progress.',dependencies: [{name: '@remotion/media', version: null},{name: '@remotion/media-utils', version: null},