Skip to content

Fix remembering 1.0x playback speed - #22

Open
LeonardNJU wants to merge 1 commit into
xinggsf:masterfrom
LeonardNJU:fix/remember-normal-playback-rate
Open

LeonardNJU wants to merge 1 commit into
xinggsf:masterfrom
LeonardNJU:fix/remember-normal-playback-rate

Conversation

@LeonardNJU

Copy link
Copy Markdown

Summary

Fix the remembered playback-rate logic so returning a video to 1.0x is persisted across video/page changes.

Problem

The current ratechange handlers only write localStorage.mvPlayRate when the rate is not 1. If a user has a remembered non-default rate (for example 2.0x) and switches back to 1.0x, the stored value remains 2. The next video then starts at 2.0x again.

The existing Z shortcut also uses mvPlayRate as the last fast rate, so simply persisting 1 there would break the 1x <-> fast rate toggle.

Fix

  • Persist every valid current playback rate, including 1.0x, in mvPlayRate.
  • Keep the last non-1x rate separately in mvLastPlayRate.
  • Make the Z shortcut restore mvLastPlayRate, with the old mvPlayRate value as a migration fallback for existing users.
  • When toggling from a fast rate to 1x, preserve that fast rate before persisting 1x.

This keeps the current Z shortcut behavior while making the "Remember video playback speed" option reflect the actual current rate.

Verification

  • node --check 视频站h5.user.js
  • State-transition test covering legacy mvPlayRate=2, switching to 1x, loading the next video at 1x, and toggling back to the previous 2x rate.

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.

2 participants