Skip to content

Feature: Search bar for subtitles #91

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 8 commits into from
Apr 22, 2025
Merged

Feature: Search bar for subtitles #91

merged 8 commits into from
Apr 22, 2025

Conversation

KRSHH
Copy link
Contributor

@KRSHH KRSHH commented Apr 19, 2025

Added a search bar to search text in subtitles and navigate through the video easily
image

@umlx5h
Copy link
Owner

umlx5h commented Apr 19, 2025

Hi @KRSHH, Thanks PR!
I'll do a detailed review later, but I touched it a bit and found the following issues.

  • subtitles do not display on video during filtering
    • subtitles not found in searches should also be displayed
    • it should be limited to a search function for the sidebar only.
  • If subtitles are added during filtering, they will disappear later when the query is cleared
    • for example, if ASR is running, this behavior can be confirmed as it is added little by little.

I have not tried it, but it might be better to implement it on the View side using the filtering function of CollectionView.

https://wpf-tutorial.com/listview-control/listview-filtering/

I use this for search feature in the cheat sheet.

List<ListCollectionView> collectionViews = KeyBindingGroups.Select(g => (ListCollectionView)CollectionViewSource.GetDefaultView(g.KeyBindings))
.ToList();
_collectionViews = collectionViews;
foreach (ListCollectionView view in collectionViews)
{
view.Filter = (obj) =>
{
if (obj is not KeyBindingCS key)
{
return false;
}
if (string.IsNullOrWhiteSpace(SearchText))
{
return true;
}
bool match = key.Description.IndexOf(SearchText.Trim(), StringComparison.OrdinalIgnoreCase) != -1;
if (match)
{
return true;
}
return key.Shortcut.IndexOf(SearchText.Trim(), StringComparison.OrdinalIgnoreCase) != -1;
};
}
}

Or it may be easier to jump to a hit subtitle without filtering like PotPlayer.

@KRSHH
Copy link
Contributor Author

KRSHH commented Apr 19, 2025

Hi @umlx5h thanks for pointing out the issues. I have addressed them in this commit. and also, how would text highlighting look in the search section? and can you explain the "PotPlayer" feature...

@umlx5h
Copy link
Owner

umlx5h commented Apr 20, 2025

Thanks, this one is better than the old one. Please remove the old changes as they are still there.

how would text highlighting look in the search section

Do you mean the highlighting of the text in the hit subtitle? This seems difficult to implement, so you don't have to do it.

you explain the "PotPlayer" feature

PotPlayer's subtitle browser jumps back and forth instead of filtering when searching.
This method has the advantage of making it easier to see subtitles before and after the hit one, but it may be difficult to use if there are many hits.

potplayersearch

This method is probably more difficult to implement. So the one that is easier to implement is OK.


I want to achieve the following requirements by the time of release.
I can handle these myself, but it would be helpful if you could implement these if you can afford it.

  • easy clear of search query

    • by Escape key
    • by UI button
  • Activate search input by CTRL+F (if possible)

  • Represent search input with default sidebar size

    • since the search function is used by specific users at specific times, so I do not want to increase the default width for this feature
    • there are several ways to achieve this
      • dynamically show the search input
        • by popup
        • hide other toolbar buttons when activating search input
      • make the toolbar two lines and place the search input on the second line
        • the second line also can be displayed dynamically.
  • debounce of incremental search

@KRSHH
Copy link
Contributor Author

KRSHH commented Apr 20, 2025

As a user, who is trying to learn a language through videos. I usually watch 5-6 hour long documentaries or movies. And navigating thru that by hitting and scrolling would be very difficult and would take lots of time. The user sometimes might also miss the part while hitting... So that's an extra annoyance... This is my opinion from the user perspective.

KRSHH and others added 3 commits April 20, 2025 13:37
- Create a view in the secondary subtitle as well
- Filtering using displayed text
- CTRL+F as global key
- Remove old changes
- Use behaivor for getting focus of TextBox
- Some performance optimization
- Use async/await to debounce
@umlx5h umlx5h merged commit 89be7c3 into umlx5h:main Apr 22, 2025
@umlx5h
Copy link
Owner

umlx5h commented Apr 22, 2025

Hi @KRSHH, there were many codes I wanted to change, so I fixed them for my taste.
If you have any concerns, feel free to comment or reopen the PR, Thank you for your contribution!

@KRSHH
Copy link
Contributor Author

KRSHH commented Apr 25, 2025

Hey, the changes were perfectly reasonable. Thanks.

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