Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7769749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:14:06+00:00 2026-06-01T16:14:06+00:00

I am making an application for Spotify. With this application I have a simple

  • 0

I am making an application for Spotify. With this application I have a simple ‘Subscribe’ function which allows me to add a playlist of the album from the current track the user is listening to. Everything works fine. I have this bug though.
After listening to more then 1 song, when I press the subscribe button it will append a playlist for every song listened to.

For example: I listened to 3 songs of the album, then I press subscribed: It will append 3 playlists, for every song one.
Then: If I then listen to a song from a different album, when Subscribe is pressed it will append a playlist for the new song AND for the previous 3 songs. This keeps occuring until I reloaded the application.

It seems it remembers every song listened to after loading the application.

This is my code:

function subscribe(){

//Cache important information
var playerTrackInfo = player.track;
var track = playerTrackInfo.data;
var albumUri = track.album.uri;
var albumTitle = track.album.name;
var artistFromAlbum = track.album.artist.name;

//Click event on button
$(".subscribe button").on("click", function(playlist){
    console.log("I work!"); //Checks if button click works

    //Creates new playlist "Albumtitle - Artistname"
    var playlist = new models.Playlist(albumTitle+" - "+artistFromAlbum);

    //Fills in playlist with album from current playing track
    models.Album.fromURI(albumUri, function(album){
        $(album.tracks).each(function(i) {
            playlist.add(album.tracks[i]);
        });
    });

    playlist.subscribed = true;

    playlist.observe(models.EVENT.CHANGE, function() {
        console.log("Playlist was subscribed!");
    });
});

}

I need a way to prevent this problem. I’ve tried a lot of different methods and searched the web endlessly, but so far no luck. Any help or pointing into the right direction will be awesome!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:14:08+00:00Added an answer on June 1, 2026 at 4:14 pm

    I have solved the problem.

    There were 2 things that caused the bug. This were the solutions:

    1. I had all the vars placed inside click event.

    2. I had a eventListener somewhere else in the code which made it also bug. That eventlistener detected if they player state has changed, if true it will refresh the init. However, it apparently stacked the vars inside my subscribe(). After taking it out this out the eventListener and replacing the vars, it finally works how it supposed to work.

      function subscribe(){
      
       //Click event on button within div with class 'subscribe'
       $(".subscribe button").on("click", function(playlist){
      console.log("I work!"); //Checks if button click works
      
      //Cache important information
      var playerTrackInfo = player.track;
      var track = playerTrackInfo.data;
      var albumUri = track.album.uri;
      
      //Creates new playlist "Albumtitle - Artistname"
      var albumTitle = track.album.name;
      var artistFromAlbum = track.album.artist.name;
      var playlist = new models.Playlist(albumTitle +" - "+ artistFromAlbum);
      
      //Fills in playlist with album from current playing track
      models.Album.fromURI(albumUri, function(album){
          $(album.tracks).each(function(i) {
              playlist.add(album.tracks[i]);
          });
      });
      
      playlist.subscribed = true;
      
      playlist.observe(models.EVENT.CHANGE, function() {
          console.log("Playlist was subscribed!");
      });
      

      });
      }

    Thanks for helping people!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making an application (iPhone app) which gets information (jokes) from an RSS
Im making an application which uses few languages. I would like to have possibility
I am making an application which is using birthday from contacts of device.I am
I am making an application in which i have to make connnect to linkedin
im making an application where i have to load my database from html file
I have been making application in which i click on image and new window
i am making application in c#. In that implication i have string which contain
At school we are busy making a Spotify application. I am currently making an
I am making an application with Java Swing and i have a problem. I
I am making an application that involves controlling Safari from Applescript. Is there a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.