0

AngularJS 1.6, Node.js 6.2.1, MongoDB 2.6.10

I have a playlist of music. There are approximately 200 tracks. The playlist plays one track after another while my web page is open and then starts with the first track when the last one is ended.

Now I want to have more tracks in the playlist. But there is a delay before my web page starts if I get more then 200 JSON documents (a document has many fields) from my MongoDB. In a document I have links to a track and some additional info. The more documents I get, the bigger delay I have. So I have hardcoded limit for 200 track now myDB.findRandom({}, {}, {limit: 200}, function(err, hyperlinks) {...});

It would be nice to be able to periodically expire some tracks and to load new ones while the web page is still open.

What AngularJS or Node.js tech can you advise me to refresh my playlist periodically?

Mistalis
  • 17,793
  • 13
  • 73
  • 97
srgbnd
  • 5,404
  • 9
  • 44
  • 80
  • 2
    have you tried using [`$interval`](https://docs.angularjs.org/api/ng/service/$interval) ? – svarog Dec 14 '16 at 09:35
  • @svarog No, I haven't. Here I'm asking what thing is best to use. I'll try `$interval`, thank you. – srgbnd Dec 14 '16 at 09:50
  • only you know what's "best" for you, there are a lot of possible ways to do what you ask and it really boils down to personal preference, such broad questions usually bring opinionated answers and get questions closed. – svarog Dec 14 '16 at 09:56
  • 2
    Might be worth looking into websockets as well. – GillesC Dec 14 '16 at 10:11
  • 1
    @trex One thing more to consider is that you might not need to run the task periodically. As you initially pull 200 tracks, your app can keep track how many of those was already played and trigger the next call to get the next batch only if let say less than N unplayed songs left. – szydan Dec 19 '16 at 10:57

0 Answers0