pstream is dead; long live pstream taciturnaxolotl.github.io/pstream-ng/
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add auto select subtitle button

Pas d88feda4 bd40ad05

+33 -17
+2
src/assets/locales/en.json
··· 804 804 "previewLabel": "Subtitle preview:", 805 805 "offChoice": "Off", 806 806 "onChoice": "On", 807 + "autoSelectChoice": "Auto select", 808 + "autoSelectDifferentChoice": "Tap again to auto select different subtitle", 807 809 "SourceChoice": "Source Subtitles", 808 810 "OpenSubtitlesChoice": "External Subtitles", 809 811 "loadingExternal": "Loading external subtitles...",
+31 -17
src/components/player/atoms/settings/CaptionsView.tsx
··· 312 312 const { t } = useTranslation(); 313 313 const router = useOverlayRouter(id); 314 314 const selectedCaptionId = usePlayerStore((s) => s.caption.selected?.id); 315 - const { disable } = useCaptions(); 315 + const { disable, selectRandomCaptionFromLastUsedLanguage } = useCaptions(); 316 + const [isRandomSelecting, setIsRandomSelecting] = useState(false); 316 317 const [dragging, setDragging] = useState(false); 318 + 319 + const handleRandomSelect = async () => { 320 + if (isRandomSelecting) return; // Prevent multiple simultaneous calls 321 + setIsRandomSelecting(true); 322 + try { 323 + await selectRandomCaptionFromLastUsedLanguage(); 324 + } finally { 325 + setIsRandomSelecting(false); 326 + } 327 + }; 317 328 const setCaption = usePlayerStore((s) => s.setCaption); 318 329 const videoTime = usePlayerStore((s) => s.progress.time); 319 330 const srtData = usePlayerStore((s) => s.caption.selected?.srtData); ··· 514 525 {t("player.menus.subtitles.offChoice")} 515 526 </CaptionOption> 516 527 528 + {/* Enable subtitles option */} 529 + <CaptionOption 530 + onClick={() => handleRandomSelect()} 531 + selected={!!selectedCaptionId} 532 + loading={isRandomSelecting} 533 + > 534 + <div className="flex flex-col"> 535 + {t("player.menus.subtitles.autoSelectChoice")} 536 + {selectedCaptionId && ( 537 + <span className="text-video-context-type-secondary text-xs"> 538 + {t("player.menus.subtitles.autoSelectDifferentChoice")} 539 + </span> 540 + )} 541 + </div> 542 + </CaptionOption> 543 + 517 544 {/* Custom upload option */} 518 545 <CustomCaptionOption /> 519 546 ··· 536 563 {!isLoadingExternalSubtitles && 537 564 sourceCaptions.length === 0 && 538 565 externalCaptions.length === 0 && ( 539 - <div className="p-4 rounded-xl bg-video-context-light bg-opacity-10 text-center"> 566 + <div className="p-4 pb-4 rounded-xl bg-video-context-light bg-opacity-10 text-center"> 540 567 <div className="text-video-context-type-secondary"> 541 568 {t("player.menus.subtitles.empty")} 542 569 </div> ··· 553 580 )} 554 581 555 582 {/* Language selection */} 556 - {groupedCaptions.length > 0 ? ( 583 + {groupedCaptions.length > 0 && 557 584 groupedCaptions.map( 558 585 ({ language, languageName, captions: captionsForLang }) => ( 559 586 <Menu.ChevronLink ··· 575 602 </span> 576 603 </Menu.ChevronLink> 577 604 ), 578 - ) 579 - ) : ( 580 - <div className="text-center text-video-context-type-secondary py-2"> 581 - {t("player.menus.subtitles.notFound")} 582 - </div> 583 - )} 584 - 585 - {/* Loading indicator for external subtitles while source exists */} 586 - {isLoadingExternalSubtitles && sourceCaptions.length > 0 && ( 587 - <div className="text-center text-video-context-type-secondary py-4 mt-2"> 588 - {t("player.menus.subtitles.loadingExternal") || 589 - "Loading external subtitles..."} 590 - </div> 591 - )} 605 + )} 592 606 </Menu.ScrollToActiveSection> 593 607 </FileDropHandler> 594 608 </>