Skip to content
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

feat: persist caption settings in localStorage on track mode change (code100x#1493) #1503

Conversation

IkramBagban
Copy link
Contributor

#1493)

PR Fixes:

  • 1 Added functionality to persist subtitle/caption settings to localStorage
  • 2 Monitored track mode changes and saved the current mode ('showing' or 'hidden')
  • 3 On player initialization, retrieved and applied the saved caption setting from localStorage
  • 4 Added cleanup for event listeners to prevent memory leaks

Resolves #1493

Checklist before requesting a review

  • [✓] I have performed a self-review of my code
  • [✓] I assure there is no similar/duplicate pull request regarding same issue

@@ -92,6 +92,52 @@ export const VideoPlayer: FunctionComponent<VideoPlayerProps> = ({
return pipButtonContainer;
};

// Fetch previously saved captions setting from localStorage
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you remove this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i added this comment to help other people understand these line of codes. anyways i'll remove it

@@ -92,6 +92,52 @@ export const VideoPlayer: FunctionComponent<VideoPlayerProps> = ({
return pipButtonContainer;
};

// Fetch previously saved captions setting from localStorage
useEffect(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why have 2 useEffects with same dependencies array? Can you add the below login in here only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes sure

@IkramBagban
Copy link
Contributor Author

hey @devsargam Please check now

@devsargam devsargam merged commit dcb5fca into code100x:main Dec 3, 2024
1 check failed
@devsargam
Copy link
Collaborator

Thank you sir

hkirat pushed a commit that referenced this pull request Dec 5, 2024
…1493) (#1503)

* feat: persist caption settings in localStorage on track mode change (#1493)

* refactor: combine both the with same dependancy
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.

feature: Save Caption Settings Between Video Plays
2 participants