Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Player Progress Incorrect #3256

Closed
2 tasks done
silora opened this issue Dec 25, 2024 · 3 comments
Closed
2 tasks done

Player Progress Incorrect #3256

silora opened this issue Dec 25, 2024 · 3 comments
Labels
πŸ› bug Something isn't working πŸ”΅ extension

Comments

@silora
Copy link

silora commented Dec 25, 2024

πŸ” Have you checked Spicetify.app page for your issue?

  • I have checked the FAQ

πŸ” Is there already an issue for your problem?

  • I have checked older issues, open and closed

β„Ή Environment / Computer Info

- Spotify version: Spotify Windows 1.2.53.438.g246d60c9
- Spicetify version: Spicetify v2.38.7

πŸ“ Description

The progress information seems to be out of sync by ~1s when the last song finishes and the next song continues to play. But when manually skipping to the next song, this does not happen. Also, if the player is paused then start playing again it will be corrected. Here is an extension script I used to reproduce this bug:

(function test() {
	console.log("Testing");
	lastPaused = 0;
	Spicetify.Player.addEventListener("songchange", ({ data }) => {
		console.log("=======Song changed========");
		wrong_beginning = Spicetify.Player.data.timestamp - Spicetify.Player.data.positionAsOfTimestamp;
		console.log("Timestamp of the song's beginning", wrong_beginning);
		setTimeout(async () => { 
			console.log("Restarting player by pause and play");
			Spicetify.Player.pause();
			Spicetify.Player.play();
			await new Promise(resolve => setTimeout(resolve, 500));
			correct_beginning = Spicetify.Player.data.timestamp - Spicetify.Player.data.positionAsOfTimestamp;
			console.log("Timestamp of the song's beginning now (fixed)", correct_beginning);
			console.log("Difference", correct_beginning - wrong_beginning);
			console.log("  ");
		}, 1000);
	});

	Spicetify.Player.addEventListener("onplaypause", ({ data }) => {
		if (Spicetify.Player.data.isPaused) {
			lastPaused = Date.now();
		} else {
			if (lastPaused > 0){
				console.log("<Paused for", Date.now() - lastPaused, ">");
				lastPaused = 0;
			}
		}
	});
})();

It also seems that the "songchange" event callback is called earlier than when the song actually started.

I don't know much js so I'm not sure if this is an actual bug, and if not I would love to know how to get the desired result!

πŸ“Έ Screenshots

Here's the console output when the last song finishes and the next song continues to play:
image

Here's the console output when manually skipping to the next song:
image

@silora silora added the πŸ› bug Something isn't working label Dec 25, 2024
@rxri
Copy link
Member

rxri commented Dec 25, 2024

It can be out of sync so if you want the most up to date info use PlayerAPI and calculate timestamps with other piece of data

@rxri rxri closed this as not planned Won't fix, can't repro, duplicate, stale Dec 25, 2024
@rxri
Copy link
Member

rxri commented Dec 25, 2024

At the end of the day we relay on Spotify’s events so if they’re too slow then so will ours.

@silora
Copy link
Author

silora commented Dec 26, 2024

I understand, thx for the comments!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
πŸ› bug Something isn't working πŸ”΅ extension
Projects
None yet
Development

No branches or pull requests

2 participants