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

How to replace songs array? #184

Closed
fiter92 opened this issue Jul 17, 2017 · 11 comments
Closed

How to replace songs array? #184

fiter92 opened this issue Jul 17, 2017 · 11 comments
Assignees
Labels
Projects

Comments

@fiter92
Copy link

fiter92 commented Jul 17, 2017

Hello!
Thanks for a good work!
I've got about 50000 songs and a lot of playlists, and I can't just initialize Amplitude.js with a ton of songs... If user listen a single playlst I could just load a new songs by ajax and use .addSong method, that's works fine. BUT that doesn't works if user changes a playlist and I have to remove all songs form the player and fill it with a new songs... Is there some way to do this?
p.s. I'm using vuejs and trying to get some reactivity

@jaydrogers
Copy link
Member

Hey @fiter92,

Thanks for using Amplitude! @danpastori is traveling right now and he'll be the best one to answer your question.

He'll be back next week and I will be sure to have him reach out to you on this question once he returns.

@danpastori
Copy link
Contributor

@fiter92 Awesome you are using Amplitude with VueJS, I've been thinking about doing a component for awhile. I love VueJS and would want Amplitude to be coupled really easily with it.

Anyways what is your use case? Do you have a library of songs on a server and you want to update a list dynamically?

@schnoddelbotz
Copy link

I'm in the same boat as @fiter92 ... I have a single-page-app that queries my song database and displays individual albums. Every time another album is shown, I'd need to re-initialise the song list.

Risking to get very off-topic here, but a public playByIndex() and stop() function would be helpful for me :)

@enemyss
Copy link

enemyss commented Dec 19, 2018

I have similar situation, right now to change array I'm re-initializing the player with new song array and before initializing I have to pause previous song otherwise it will play in background while the new ones are playing, is this viable solution? Is there any better way to do this?

@danpastori
Copy link
Contributor

@enemyss I'd do a solution like the following: Start with 10 songs, add 10 more songs. Once you add another 10 songs remove the first 10. Does that make sense? Then you wouldn't be needing to pause the song because it's being removed from the songs array. Or am I missing what you are trying to accomplish?

@enemyss
Copy link

enemyss commented Jan 3, 2019

@danpastori thanks for replying, I just tried adding new songs and removing old ones, but then the player current song is from previous song list and I have to call Amplitude.next() or press next to get to the new song and also by adding X new songs for each one I get "uncaught promise error" in console though I'm not sure how crucial is that since it seems to not affect anything. And since with songAdd/remove I have to use cycle won't it be slower than initializing new array?

@dakotahmartin
Copy link

This is what I'm doing to load a new playlist, It seems to be working fine.

let anode = Amplitude.getAnalyser();
if (anode) {
  Amplitude.pause();
  anode.context.close().then(() => {
    this.initAmplitude(songs);
  });
} else {
  this.initAmplitude(songs);
}

@danpastori
Copy link
Contributor

@dakotahmartin Thanks for providing your solution! Handling large amounts of files is something I've been wanting to research and making sure it's efficient. If there are any ideas or solutions definitely post them here, but I'll be doing some research as well and making sure I can come up with something that works effectively and efficiently!

@jayakrishnannair
Copy link

jayakrishnannair commented May 15, 2019

This is what I'm doing to load a new playlist, It seems to be working fine.
let anode = Amplitude.getAnalyser();
if (anode) {
Amplitude.pause();
anode.context.close().then(() => {
this.initAmplitude(songs);
});
} else {
this.initAmplitude(songs);
}

How does the initAmplitude() look like for you. Can I do Amplitude.songs = newSongsArrayFromServer?

@danpastori danpastori added Enhancement ⚡️ New feature and removed research labels Jul 15, 2019
@danpastori
Copy link
Contributor

This is now being tracked in our roadmap. We want to spend some time to make sure we can handle thousands of files with ease.

@danpastori danpastori added this to Needs sponsorship in Roadmap Jul 15, 2019
@rosshatokay
Copy link

Any progress on this issue, of loading new playlists? I'm currently having difficulty in removing an old array of playlists and loading a new one.

When calling Amplitude.init({}) it seems like it just overlaps the new playlist on the old one and 2 audio tracks start playing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Roadmap
Needs sponsorship
Development

No branches or pull requests

8 participants