0

如果用户订阅/取消订阅播放列表,有什么方法可以通知?

理想情况下,我希望能够做这样的事情:

var sp = getSpotifyApi(1);
var models = sp.require('sp://import/scripts/api/models');
var playlist = models.Playlist.fromURI("spotify:user:spotify:playlist:3Yrvm5lBgnhzTYTXx2l55x");

playlist.observe(models.EVENT.SUBSCRIBE, function() {  // <-- This "SUBSCRIBE" event don't exist...
    console.log("Playlist was subscribed/unsubscribed!");
});

/* later in code */

playlist.subscribed = true; // Outputs: Playlist was subscribed/unsubscribed!

有没有什么模式可以完成这样的事情?

最终,我想根据运行时是否订阅播放列表来更改几个不同对象的 gui 状态。但是这些对象彼此并不了解,它们是从同一 URI 创建的 Spotify 播放列表对象的唯一共同点。

4

1 回答 1

0

Change models.EVENT.SUBSCRIBE to models.EVENT.CHANGE and you'll be set. A few other things trigger this as well, so make sure you make a check before updating UI.

于 2012-01-20T19:29:57.197 回答