My app just works like Default iPod player in iPhone.
-> It will get all Playlists , artists, albums and songs from iPod music player. -> It works fine in less than ios 5.0, But when comes to 5.0 or more i am getting wrong playback states (some times). Please help me.
-> This is my code when i select song from songlists, mediaItemCollection contains songslist and indexofcurrentObject is song number
- (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];
}
}