I am writing a Music player Component with favorites songs from SoundCloud using their API
I want automatically play the next favorite song once the previous is finished.
The idea is to create a new property to represent an array of all my favorites to pass the nextFavorite
This is my player controller
sortedFavorites: Ember.computed.alias('favorites’),
and
actions: {
selectFavorite: function(favorite, index, play) {
if (!this.get('externalPlay')) {
index = index + 1;
nextFavorite = this.get('sortedFavorites').nextObject(index, favorite);
self.set('nextFavorite', nextFavorite);
}
return SC.stream(favoritePath, {
onfinish: function() {
self.set('isPlaying', false);
if (self.get('nextFavorite') != null) {
return self.send('selectFavorite', self.get('nextFavorite'), index);
}
}
}
}
}
}
When i create a new property the alias for “favorites” , it is undefined
In case i create an alias for a single favorite i can access to my single favorite although it’s not what i need to do
so how can the sortedFavorites be an array of all my favorites in order to access to the nextObject (favorite)?
Aucun commentaire:
Enregistrer un commentaire