How to allow AVPlayer to play multiple items?

I am trying to play multiple mp3s using AVPlayer . I get the mp3 urls and then let AVPlayer play them one by one.

My first attempt is to allow a single AVPlayer play all mp3s using the replaceCurrentItemWithPlayerItem method. But there is no sound except the first song.

When I try to create AVPlayer for each individual element and each AVPlayer element plays its element, the application works the way I wanted.

My question is: is AVPlayer designed to play a single item? If I do not want to allocate a new AVPlayer for each item, I have to use AVQueuePlayer to play multiple items, right? Which method is preferred?

+4
source share
1 answer

AVQueuePlayer works great for this case. It will automatically delete the downloaded items.

+3
source

All Articles