Note that there are some explanatory texts on larger screens.

plurals
  1. PODisable next previous buttons in spotify
    text
    copied!<p>I want to be able to disable the Next and the previous buttons in spotify. I know it's possible because the soundrop app has managed to do it.</p> <p>I have searched around a bit, and from my understanding, I am supposed to play a track with the context as null or a context containing only 1 track. I have been testing around with all the possible solutions I can think of, but none of them seems to work. Most of them actually result in the track being played with context as null, but the Next/Previous buttons are always enabled.</p> <p>If I press the next button, the player ends up not playing any track, and both buttons are disabled...</p> <p>Below is the code from my test application.</p> <pre><code>var sp = getSpotifyApi(1); var models = sp.require('sp://import/scripts/api/models'); var views = sp.require('sp://import/scripts/api/views'); models.player.observe(models.EVENT.CHANGE, function (o) { console.log(['Player Change', o, models.player.context]); }) $('#play1').click(function () { models.Track.fromURI("spotify:track:5A1fNC7Fdb0yyh3UA6T1ef", function (track) { console.log(["play1", track.name]); models.player.play(track, null); }); }); $('#play2').click(function () { models.Track.fromURI("spotify:track:5A1fNC7Fdb0yyh3UA6T1ef", function (track) { console.log(["play2", track.name]); var p = new views.Player(); p.play(track, null); }); }); $('#play3').click(function () { models.Track.fromURI("spotify:track:5A1fNC7Fdb0yyh3UA6T1ef", function (track) { console.log(["play3", track.name]); var pl = new models.Playlist(); pl.add(track); models.player.play(track, pl); }); }); $('#play4').click(function () { console.log(["play4"]); models.player.play("spotify:track:5A1fNC7Fdb0yyh3UA6T1ef", null); }); $('#play5').click(function () { models.Track.fromURI("spotify:track:5A1fNC7Fdb0yyh3UA6T1ef", function (track) { models.player.playTrack(track); }); }); $('#play6').click(function () { models.Track.fromURI("spotify:track:5A1fNC7Fdb0yyh3UA6T1ef", function (track) { console.log(["play6", track.name]); var pl = new models.Playlist(); pl.add(track); models.player.playTrackWithContext(track, pl, 0); }); }); $('#play7').click(function () { var l = new models.Link("spotify:track:5A1fNC7Fdb0yyh3UA6T1ef"); sp.trackPlayer.setContextCanSkipNext(l, false); console.log(["play7", models.player, sp.trackPlayer],l); models.player.play(l, null); }); </code></pre> <p>Result from #play1:</p> <pre><code>["play1", "Jag är här nu"] ["Player Change", Object, null] </code></pre> <p>Result from #play2:</p> <pre><code>["play2", "Jag är här nu"] ["Player Change", Object, null] </code></pre> <p>Result from #play3:</p> <pre><code>["play3", "Jag är här nu"] ["Player Change", Object, "spotify:internal:temp_playlist:spotify:app:myapplication@687556942764"] </code></pre> <p>Result from #play4:</p> <pre><code>["play4"] ["Player Change", Object, null] </code></pre> <p>Result from #play5:</p> <pre><code>["play5", "Jag är här nu"] ["Player Change", Object, null] </code></pre> <p>Result from #play6:</p> <pre><code>["play6", "Jag är här nu"] ["Player Change", Object, "spotify:internal:temp_playlist:spotify:app:myapplication@217702072872"] </code></pre> <p>Result from #play7:</p> <pre><code>sp.trackPlayer.setContextCanSkipNext(l, false); </code></pre> <p>The above line generates an exception with the message "Failed to convert param 0 to link"</p> <p>Thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload