I am trying to play Media Item that selected from UITableView in iOS.
I am using MediaQuery and i loaded songs list from iPod Library in my UITableView.
But i don’t know how to play that selected songs from UITableView.
I know really basic simple AudioPlayer with following code.
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: @"sample"
ofType: @"mp3"];
NSURL *fileURL = [[[NSURL alloc] initFileURLWithPath: soundFilePath] autorelease];
self.player = [[[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error: nil]
autorelease];
That is used of ContentOfURL that already located in resource.There is no need to retrieve songs from iPod Library.
Here is my CellForRowAtIndexPath Method Codes
MPMediaItemCollection *songs = [self.arrayOfSongs objectAtIndex:indexPath.row];
cell.textLabel.text = [songs.items[0] valueForProperty:MPMediaItemPropertyTitle];
Now i am trying to play that retrieved songs from iPod Library with MediaQuery and that selected from UITableView
So How can i retrieve the URL and play the song from iPod Library that selected from UITableView?
Thanks for your reading.
You need to implement your
didSelectRowAtIndexPathlike the following code: