开发者

How can we make playlist repeateable continuously in AVPlayer

开发者 https://www.devze.com 2023-03-02 09:01 出处:网络
hi Friends I am using AVPlayer but in it I want to play .mov file continuously r开发者_开发问答epeatable.So I want to use seekToTime but cant get proper idea so please any one tell me how? player.acti

hi Friends I am using AVPlayer but in it I want to play .mov file continuously r开发者_开发问答epeatable.So I want to use seekToTime but cant get proper idea so please any one tell me how?


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];
} 


For iOS 10+ you can use AVPlayerLooper

Sample from Apple documentation:

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()
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号