Reputation: 113
I am using AVPlayer when i select multiple songs from my ipod library ,those selected songs are displayed in a UITableview called playlistTableView as soon as the first song plays out it doesnt continue with second song .. I want the player to continue playing songs till there are no songs left in playlistTableView .
Upvotes: 0
Views: 921
Reputation: 9600
On iOS 4.1 and later, you can use an AVQueuePlayer object to play a number of items in sequence. AVQueuePlayer is a subclass of AVPlayer. You initialize a queue player with an array of player items:
NSArray *items = <#An array of player items#>;
AVQueuePlayer *queuePlayer = [[AVQueuePlayer alloc] initWithItems:items];
You can then play the queue using play, just as you would an AVPlayer object. The queue player plays each item in turn. If you want to skip to the next item, you send the queue player an advanceToNextItem message. You can modify the queue using insertItem:afterItem:, removeItem:, and removeAllItems. When adding a new item, you should typically check whether it can be inserted into the queue, using canInsertItem:afterItem:. You pass nil as the second argument to test whether the new item can be appended to the queue:
AVPlayerItem *anItem = <#Get a player item#>;
if ([queuePlayer canInsertItem:anItem afterItem:nil])
{
[queuePlayer insertItem:anItem afterItem:nil];
}
For more information, please see the following documentation.
Upvotes: 1