Skip to content

Conversation

@mseh1128
Copy link
Contributor

Implementation for #735

Took forever, but was able to get multiple playback modes working at the same time. In particular, handling the interactions for "Repeat+Autopause" and "Autopause+Condensed" was tricky and required some significant (and hopefully not too hacky) changes to Player.tsx/binding.ts.

@killergerbah
Copy link
Owner

Hey thanks for doing this. I've been pretty busy but will try to read this on the weekend.

@mseh1128
Copy link
Contributor Author

Btw I was testing this some more today, and realized I forgot about Auto Pause at start of subtitles. I'm working on making this work w/ Repeat mode.

@killergerbah
Copy link
Owner

@mseh1128 On the first pass my only comment is that there seems to be a lot of duplicated code related to modifying the play mode set. Maybe this should be its own collection class? "Resolve conflicts" is the only part that is different depending on the context, but it should still be possible to extract that out from all the duplicated lines.

@mseh1128
Copy link
Contributor Author

Thanks for the review. I refactored most of the playMode related code into play-mode-manager.ts. Also, I was able to get "auto pause at start" working with Repeat and Condensed modes surprisingly easily.

Copy link
Owner

@killergerbah killergerbah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey thanks for doing that refactor. Did a second pass.

@mseh1128
Copy link
Contributor Author

Sorry for the delay. I fixed the issues from the previous code review. Thanks 🙂.

@killergerbah
Copy link
Owner

killergerbah commented Jan 18, 2026

@mseh1128 I did some more testing and found this issue where condensed mode stops working when its enabled with other modes at the same time. At the beginning, condensed mode is demonstrated working. When navigating 5 seconds back into a no-subtitle-region, the player automatically snaps back to the beginning of the ~♪ subtitle. But when auto repeat or auto pause is enabled with condensed mode at the same time, seeking back 5 seconds no longer snaps you back.

Screen.Recording.2026-01-18.at.9.52.51.AM.mov

It's probably too late but I wonder if this complexity can be dealt with by implementing multiple play modes as pure, reusable and testable logic rather than having to implement it twice in two different locations close to the UI.

@mseh1128
Copy link
Contributor Author

@mseh1128 I did some more testing and found this issue where condensed mode stops working when its enabled with other modes at the same time. At the beginning, condensed mode is demonstrated working. When navigating 5 seconds back into a no-subtitle-region, the player automatically snaps back to the beginning of the ~♪ subtitle. But when auto repeat or auto pause is enabled with condensed mode at the same time, seeking back 5 seconds no longer snaps you back.
Screen.Recording.2026-01-18.at.9.52.51.AM.mov

It's probably too late but I wonder if this complexity can be dealt with by implementing multiple play modes as pure, reusable and testable logic rather than having to implement it twice in two different locations close to the UI.

I had previously disabled the useEffect() interval for Condensed mode when auto-pause/repeat was enabled and instead handled it in handleOnWillStopShowingSubtitle(). That's why the snap back wasn't happening. I had done this b/c the useEffect() interval was interfering with the Auto-Pause functionality (i.e. the video was skipping to the next subtitle rather than auto-pausing). I'm trying a different approach this time by checking whether pendingAutoRepeatTargetTimestamp > 0 within the interval (indicating that an Auto-pause just happened) rather than just disabling the useEffect() like I had done before. This should fix the issue you were having.

Also, while testing I realized that seeking via keyboard shortcuts or the progress bar was broken due to some code I had removed before. I tried fixing this by using forwardToMedia to determine whether the action was user-initiated or not, and that seems like it's working. But I'm not sure if it is always the case that forwardToMedia should cause the pendingAutoRepeatTargetTimestamp to reset.

@mseh1128
Copy link
Contributor Author

mseh1128 commented Jan 19, 2026

I agree that implementing multiple play modes as reusable, testable logic would've been better. Especially for testing purposes. That being said, there are a few significant differences in how multiple play modes are handled in the extension vs the web app. I haven't looked much at the testing framework here, but it would be nice to have testable logic for some of the different Play Mode interactions.

}

await seek(currentTime * 1000, clock, forwardToMedia);
// When forwardToMedia is false, the message came from the video element's seeked event,
Copy link
Contributor Author

@mseh1128 mseh1128 Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the logic I had added to deal with seeks via the progress bar or keyboard shortcuts. This seems like the entrypoint for those seeks in Player.tsx, which is why I added it here. I'm not sure if this forwardToMedia check is always applicable though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. part of the code snippet got cut off. You can see it in my latest commit.

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