How to prevent track navigation controls in Spotify application (disable skip functionality)

I’m working on a Spotify app and I need to disable the skip forward and skip backward buttons. I want full control over which tracks get played.

I found some discussion about this online and it seems like the solution involves playing tracks without providing a context to the player. However when I try this approach, the navigation buttons stay active and Spotify treats my starred playlist as the current context.

Here’s my current implementation:

var spotifyAPI = getSpotifyApi(1);
var apiModels = spotifyAPI.require('sp://import/scripts/api/models');
var audioPlayer = apiModels.player;
var starredTracks = apiModels.library.starredPlaylist;

exports.initialize = initialize;

function initialize() {
    var headerElement = document.getElementById("header");
    var randomIndex = Math.floor(Math.random() * starredTracks.length);
    var selectedTrack = starredTracks.get(randomIndex);

    if (starredTracks == null) {
        headerElement.innerText = "starred playlist not found";
    } else if (selectedTrack == null) {
        headerElement.innerHTML = "unable to retrieve track from starred";
    } else {
        headerElement.innerHTML = "playing " + randomIndex + "/" + starredTracks.length + " : " + selectedTrack.name;
    }

    audioPlayer.play(selectedTrack, null);
}

I also tried loading tracks directly by URI to avoid any playlist context:

function initialize() {
    var headerElement = document.getElementById("header");
    var audioPlayer = apiModels.player;

    apiModels.Track.fromURI("spotify:track:4YfW3Z2MEvd71pv4J1rN3k", function(isolatedTrack) {
        console.log("Track loaded successfully", isolatedTrack.name);
        audioPlayer.play(isolatedTrack, null);
        headerElement.innerHTML = "now playing: " + isolatedTrack.name;
    });
}

The skip buttons appear disabled but clicking previous restarts the current track and clicking next goes to a “no track” state. Is there a proper way to completely disable track navigation in Spotify apps?

unfortunately there’s no clean way to fully disable those controls since spotify owns the ui. what you’re seeing is expected behavior - the client always shows navigation even when there’s nothing to skip to. you could try the web playback sdk instead - it gives you more control over the player state but requires premium users.

The problem is Spotify’s navigation controls are hardcoded into the client - you can’t disable them through the old app framework. I ran into this exact issue building a similar app years ago. That context parameter in your play() call doesn’t actually control the navigation buttons. They’re always there no matter what you pass as the second argument. Your best bet is setting up event listeners for track changes and immediately redirecting playback back to your track when users try to skip. Use addEventListener to catch ‘change:track’ events and force playback back to your selected track. It’s not pretty but it works - prevents navigation while keeping the buttons visible. Your fromURI approach was heading in the right direction, you just need that event handling layer to make it work.

This happens because Spotify’s Web API doesn’t let you disable those navigation controls - they’re controlled by the Spotify client, not your code. When you use track.fromURI without proper context, you get this weird behavior where the previous button just restarts the track and next goes nowhere since there’s nothing queued up. You could build a queue management system that catches track change events and redirects playback to whatever track you want. Or just create a single-track playlist on the fly for each song - gives Spotify the context it needs while keeping users stuck on that one track.