From d88feda474bcd60b46c7c66da00bf90df668a6dd Mon Sep 17 00:00:00 2001
From: Pas <74743263+Pasithea0@users.noreply.github.com>
Date: Mon, 22 Dec 2025 11:46:23 -0700
Subject: [PATCH] add auto select subtitle button
---
src/assets/locales/en.json | 2 +
.../player/atoms/settings/CaptionsView.tsx | 48 ++++++++++++-------
2 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json
index 1353e26a..1fe42710 100644
--- a/src/assets/locales/en.json
+++ b/src/assets/locales/en.json
@@ -804,6 +804,8 @@
"previewLabel": "Subtitle preview:",
"offChoice": "Off",
"onChoice": "On",
+ "autoSelectChoice": "Auto select",
+ "autoSelectDifferentChoice": "Tap again to auto select different subtitle",
"SourceChoice": "Source Subtitles",
"OpenSubtitlesChoice": "External Subtitles",
"loadingExternal": "Loading external subtitles...",
diff --git a/src/components/player/atoms/settings/CaptionsView.tsx b/src/components/player/atoms/settings/CaptionsView.tsx
index fbc8d0f0..366f1931 100644
--- a/src/components/player/atoms/settings/CaptionsView.tsx
+++ b/src/components/player/atoms/settings/CaptionsView.tsx
@@ -312,8 +312,19 @@ export function CaptionsView({
const { t } = useTranslation();
const router = useOverlayRouter(id);
const selectedCaptionId = usePlayerStore((s) => s.caption.selected?.id);
- const { disable } = useCaptions();
+ const { disable, selectRandomCaptionFromLastUsedLanguage } = useCaptions();
+ const [isRandomSelecting, setIsRandomSelecting] = useState(false);
const [dragging, setDragging] = useState(false);
+
+ const handleRandomSelect = async () => {
+ if (isRandomSelecting) return; // Prevent multiple simultaneous calls
+ setIsRandomSelecting(true);
+ try {
+ await selectRandomCaptionFromLastUsedLanguage();
+ } finally {
+ setIsRandomSelecting(false);
+ }
+ };
const setCaption = usePlayerStore((s) => s.setCaption);
const videoTime = usePlayerStore((s) => s.progress.time);
const srtData = usePlayerStore((s) => s.caption.selected?.srtData);
@@ -514,6 +525,22 @@ export function CaptionsView({
{t("player.menus.subtitles.offChoice")}
+ {/* Enable subtitles option */}
+