Skip to content

Fix PlaybackrateOption component to display full rate precision #5566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 6, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 6, 2025

The PlaybackrateOption component was using toFixed(1) which rounded decimal playback rates incorrectly. This caused precision loss where:

  • 0.75 was displayed as 0.8x (rounded up)
  • 1.25 was displayed as 1.3x (rounded up)
  • Users couldn't see the exact rates they configured

Before fix showing rounded rates

Solution

Added a formatPlaybackRate() helper function that:

  • Preserves full precision for decimal rates (0.75 → "0.75x", 1.25 → "1.25x")
  • Maintains at least one decimal place for whole numbers (2 → "2.0x")
const formatPlaybackRate = (rate: number): string => {
  const str = rate.toString();
  // If the string doesn't contain a decimal point, add ".0"
  return str.includes('.') ? str : str + '.0';
};

Results

With showPlaybackRateControl={[0.5, 0.75, 1, 1.25, 1.5, 1.75, 2]}:

Before:

  • 0.75 → "0.8x" ❌
  • 1.25 → "1.3x" ❌
  • 1.75 → "1.8x" ❌

After:

  • 0.75 → "0.75x" ✅
  • 1.25 → "1.25x" ✅
  • 1.75 → "1.75x" ✅
  • 2 → "2.0x" ✅ (maintains decimal requirement)

This is a minimal surgical change that preserves all existing behavior while fixing the precision display issue.

Fixes #5564.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copy link

vercel bot commented Aug 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
bugs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2025 10:19am
remotion ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 6, 2025 10:19am

@Copilot Copilot AI changed the title [WIP] Component "PlaybackrateOption" did not display full rate, but display with "toFixed(1)" Fix PlaybackrateOption component to display full rate precision Aug 6, 2025
@Copilot Copilot AI requested a review from JonnyBurger August 6, 2025 10:15
Copilot finished work on behalf of JonnyBurger August 6, 2025 10:15
@JonnyBurger JonnyBurger marked this pull request as ready for review August 6, 2025 10:16
@JonnyBurger JonnyBurger enabled auto-merge August 6, 2025 10:16
@JonnyBurger JonnyBurger merged commit 53329a5 into main Aug 6, 2025
12 of 13 checks passed
@JonnyBurger JonnyBurger deleted the copilot/fix-5564 branch August 6, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Component "PlaybackrateOption" did not display full rate, but display with "toFixed(1)"
2 participants