fix: clear saved track time when changing tracks in AudioPlayer and AudioPlayerContext

This commit is contained in:
2025-06-19 22:11:07 +00:00
committed by GitHub
parent fa5acd5a10
commit 3cc1e4d441
2 changed files with 13 additions and 5 deletions

View File

@@ -56,6 +56,9 @@ export const AudioPlayer: React.FC = () => {
const audioCurrent = audioRef.current;
if (currentTrack && audioCurrent && audioCurrent.src !== currentTrack.url) {
// Always clear current track time when changing tracks
localStorage.removeItem('navidrome-current-track-time');
audioCurrent.src = currentTrack.url;
// Check for saved timestamp (only restore if more than 10 seconds in)
@@ -76,12 +79,8 @@ export const AudioPlayer: React.FC = () => {
} else {
audioCurrent.addEventListener('loadeddata', restorePosition);
}
} else {
// Clear saved time if we're not restoring it
localStorage.removeItem('navidrome-current-track-time');
}
} else {
// Clear saved time if no saved time exists
// Always clear after attempting to restore
localStorage.removeItem('navidrome-current-track-time');
}