3
是否有適用於iPhone OS的iTunes API?我可以使用它從iTunes訪問某些信息(當前曲目等)?在iPod上從iTunes訪問當前曲目信息
我環顧四周,但我能找到的只是一些AppleScript和COM API。
是否有適用於iPhone OS的iTunes API?我可以使用它從iTunes訪問某些信息(當前曲目等)?在iPod上從iTunes訪問當前曲目信息
我環顧四周,但我能找到的只是一些AppleScript和COM API。
您需要MediaPlayer.framework添加到您的目標在Xcode和#進口的MediaPlayer/MediaPlayer.h
然後
像
@property (nonatomic, retain) MPMusicPlayerController *musicPlayer;
...
self.musicPlayer = [MPMusicPlayerController iPodMusicPlayer];
然後在viewDidLoad中,你需要爲登記事件
// Register for music player notifications
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
[notificationCenter addObserver:self
selector:@selector(handleNowPlayingItemChanged:)
name:MPMusicPlayerControllerNowPlayingItemDidChangeNotification
object:self.musicPlayer];
implements handleNowPlayingItem改變 現在
當正在播放的項目改變了你的無線本地環路獲取調用此方法
- (void)handleNowPlayingItemChanged:(id)notification {
// Ask the music player for the current song.
MPMediaItem *currentItem = self.musicPlayer.nowPlayingItem;
非常感謝米希爾通知! – 2010-04-14 10:56:06