Hi i need to play a song from the itunes library. I had gone through the Apples ipod Library Access Guide and got the code.
MPMediaQuery *everything = [[MPMe
I couldn't use theMPMediaPickerController
in my scenario.
My short answer to question is to have a look at [musicplayer setNowPlayingItem:item]
here's some code below from my implementation.
// Create a new query
MPMediaQuery *query = [MPMediaQuery songsQuery];
MPMediaPropertyPredicate *mpp = [MPMediaPropertyPredicate predicateWithValue:@"a" forProperty:MPMediaItemPropertyTitle comparisonType:MPMediaPredicateComparisonContains];
[query addFilterPredicate:mpp];
// Retrieve the results and reload the table data
DATAENV.songCollections = [NSMutableArray arrayWithArray:query.collections];
//populate cell rows with
- (UITableViewCell *)tableView:(UITableView *)tView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MPMediaItem *item = [[[DATAENV.songCollections objectAtIndex:indexPath.row] items] lastObject];
titleLbl = [item valueForProperty:MPMediaItemPropertyTitle];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
MPMediaItem *item = [[[self.songCollections objectAtIndex:indexPath.row] items] lastObject];
[PLAYER setNowPlayingItem:item];
[PLAYER play];
}
Where PLAYER/ DATAENV are my singletons
#define PLAYER [[AudioController sharedAudioController_instance] musicPlayer]
#define DATAENV [DataEnvironment sharedDataEnvironment_instance]