-
Notifications
You must be signed in to change notification settings - Fork 34
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
[stats] Button #164
Comments
I added the Play button to context menu, and that makes it possible to play the song. To get it, navigate to:
Create a new file called Use this code: (function playContextMenu() {
function checkForSpicetify() {
if (
typeof Spicetify === 'undefined' ||
!Spicetify.Player ||
!Spicetify.ContextMenu ||
!Spicetify.URI ||
!Spicetify.showNotification ||
!Spicetify.SVGIcons
) {
console.log("Spicetify APIs not ready, retrying...");
setTimeout(checkForSpicetify, 1000);
return;
}
console.log("Spicetify APIs are ready.");
initializeExtension();
}
checkForSpicetify();
function initializeExtension() {
// Function to determine when to show the "Play" option
const shouldAddPlayOption = (uris) => {
if (!uris || uris.length !== 1) return false;
const uriObj = Spicetify.URI.fromString(uris[0]);
const validTypes = [
Spicetify.URI.Type.TRACK,
Spicetify.URI.Type.ALBUM,
Spicetify.URI.Type.PLAYLIST,
Spicetify.URI.Type.ARTIST,
Spicetify.URI.Type.SHOW,
Spicetify.URI.Type.EPISODE,
];
return validTypes.includes(uriObj.type);
};
// Function to handle playing the selected item
const playItem = async (uris) => {
if (!uris || uris.length !== 1) {
Spicetify.showNotification("Please select a single item to play.");
return;
}
const uri = uris[0];
console.log("Selected URI:", uri);
try {
await Spicetify.Player.playUri(uri);
// Spicetify.showNotification("Playing...");
console.log("Playback started for URI:", uri);
} catch (err) {
console.error("Error playing URI:", err);
Spicetify.showNotification("Failed to play the selected item.");
}
};
// Create a new menu item using Spicetify.ContextMenu.Item
const menuItem = new Spicetify.ContextMenu.Item(
"Play", // Name of the menu item
playItem, // Callback function when clicked
shouldAddPlayOption, // Function to determine when to show the item
Spicetify.SVGIcons["play"], // Icon for the menu item
false // Not disabled
);
// Register the menu item to add it to the context menu
menuItem.register();
// Attempt to adjust the menu item's position (if supported)
if (typeof menuItem.priority !== 'undefined') {
menuItem.priority = 1; // Lower number means higher priority
}
console.log("Context Menu Play extension loaded successfully.");
}
})(); In Terminal type in:
It should look like this now: To check if the Extension was indeed added, type in Terminal: , and look for |
i might need a step by step guide to doing what you said in words so i gotta applicate it im pretty stupid in this domain |
For Windows
For Linux
Troubleshooting
With this setup, you can easily play items directly from Spotify’s context menu. |
MrBiscuit921's solution is better than mine, as he's done the proper fix, so check it out: If you need more detailed steps on how he's done it, let me know. |
In general, all these buttons do not work and the music play button does not work either
[Edit] and version 1.1.0 works about 99% only the top buttons are a bit crooked and the play button does not work
The text was updated successfully, but these errors were encountered: