问题
Does anyone know of a way to subscribe to events in the Spotify application? To subscribe to iTunes events, you would just add an observer to the notification center like this:
[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(changedTrack:) name:@"com.apple.iTunes.playerInfo" object:nil];
Thereby all events will be send in an NSNotification
to changedTrack:
.
I can't seem to find a similar (or any way) to do this for Spotify but I know there are applications doing this, for example applications showing the song currently being played.
回答1:
Spotify's NSDistributedNotification
name is com.spotify.client.PlaybackStateChanged
.
Subscribe to that using NSDistributedNotificationCenter
and you'll get a notification very similar to iTunes'.
来源:https://stackoverflow.com/questions/11022987/subscribe-to-spotify-events