我的应用就像iPhone中的默认iPod播放器一样。
- >它将获得iPod音乐播放器的所有播放列表,艺术家,专辑和歌曲。 - >它在低于ios 5.0的情况下运行良好,但是当达到5.0或更高时,我会得到错误的播放状态(有时)。请帮我。
- >当我从歌曲列表中选择歌曲时,这是我的代码,mediaItemCollection包含songslist,indexofcurrentObject是歌曲编号
- (void)updatePlayerQueueWithMediaCollection:(MPMediaItemCollection *)mediaItemCollection currentIndex:(int)indexOfCurrentObject
{
[musicPlayer stop];
if (userMediaItemCollection)
{
userMediaItemCollection=nil;
}
musicPlayer.nowPlayingItem=nil;
userMediaItemCollection=[MPMediaItemCollection collectionWithItems:[mediaItemCollection items]];
[musicPlayer setQueueWithItemCollection:userMediaItemCollection];
[musicPlayer setNowPlayingItem:[[userMediaItemCollection items]objectAtIndex:indexOfCurrentObject]];
[self enablePrevAndNextButtons];
[musicPlayer play];
}
-(void)playbackStateDidChanged:(NSNotification *)notification
{
if (musicPlayer.playbackState!=MPMusicPlaybackStatePlaying)
{
[playPauseButton setBackgroundImage:[UIImage imageNamed:@"play_iPad.png"] forState:UIControlStateNormal];
}
else if(musicPlayer.playbackState==MPMusicPlaybackStatePlaying)
{
[playPauseButton setBackgroundImage:[UIImage imageNamed:@"pause_iPad.png"] forState:UIControlStateNormal];
}
}