Merge pull request #51 from Troray/fix/source-switch-chrome-safari

Fix/修复Chromium内核浏览器无法正常换源的问题
This commit is contained in:
Kuek Hao Yang
2026-01-25 09:55:23 +08:00
committed by GitHub
3 changed files with 6 additions and 3 deletions
+1 -2
View File
@@ -217,8 +217,7 @@ function PlayerContent() {
}
setCurrentSourceId(newSource.source);
router.replace(`/player?${params.toString()}`, { scroll: false });
// Trigger refetch
window.location.reload();
// Data will be refetched automatically via useEffect in useVideoPlayer hook
}}
/>
)}
+1 -1
View File
@@ -195,7 +195,7 @@ export function VideoPlayer({
/>
) : (
<CustomVideoPlayer
key={`${useProxy ? 'proxy' : 'direct'}-${retryCount}`} // Only remount when switching modes or retrying, NOT when changing episodes
key={`${useProxy ? 'proxy' : 'direct'}-${retryCount}-${source}`} // Remount when switching sources, modes, or retrying
src={finalPlayUrl}
onError={handleVideoError}
onTimeUpdate={handleTimeUpdate}
+4
View File
@@ -169,6 +169,10 @@ export function useVideoPlayer(
useEffect(() => {
if (videoId && source) {
// Reset state when source changes to ensure clean fetch
setVideoData(null);
setCurrentEpisode(0);
setPlayUrl('');
fetchVideoDetails();
}
}, [videoId, source, fetchVideoDetails]);