How can we play a playlist in AVPlayer continuously

Hi Friends I am using AVPlayer, but in it I want to play the .mov file continuously repeating. So I want to use seekToTime, but can't get the right idea, so please tell me how to do this?

+3
source share
2 answers
player.actionAtItemEnd = AVPlayerActionAtItemEndNone;

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:[player currentItem]];

    - (void)playerItemDidReachEnd:(NSNotification *)notification{

AVPlayerItem *p = [notification object];

[p seekToTime:kCMTimeZero];
} 
+4
source

For iOS 10+ you can use AVPlayerLooper

Apple documentation example:

let asset = // AVAsset with its 'duration' property value loaded
let playerItem = AVPlayerItem(asset: asset)

// Create a new player looper with the queue player and template item
playerLooper = AVPlayerLooper(player: queuePlayer, templateItem:playerItem)

// Begin looping playback
queuePlayer.play()
-2
source

All Articles