Skip to content

Commit

Permalink
feat: added remember quality selection
Browse files Browse the repository at this point in the history
The last quality chosen is now persistent across the app
  • Loading branch information
aymanmostafa11 committed Oct 21, 2024
1 parent 1a1f99b commit 66f8e43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/renderer/components/player/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,9 @@ const VideoPlayer: React.FC<{
hls.attachMedia(videoRef.current);
hls.on(Hls.Events.MANIFEST_PARSED, () => {
if (videoRef.current) {
hls.currentLevel = hls.levels.length - 1;
const savedQuality = STORE.get('last_quality');
hls.currentLevel = savedQuality !== undefined ? savedQuality as number : hls.levels.length - 1;

playVideoAndSetTime();
setHlsData(hls);
}
Expand Down
1 change: 1 addition & 0 deletions src/renderer/components/player/VideoSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const VideoSettings = forwardRef<HTMLDivElement, SettingsProps>(
const handleQualityChange = (index: number) => {
if (hlsData) {
hlsData.currentLevel = index;
STORE.set("last_quality", index);
}
};

Expand Down

0 comments on commit 66f8e43

Please sign in to comment.