Subscribe to Spotify events

依然范特西╮ 提交于 2019-12-13 02:22:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!