Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seek to a certain position in AVPlayer right after the asset was loaded

Tags:

This works: I have an AVPlayer which plays a video right after it was loaded. And this works fine.

This doesn't:

Instead of starting the video at the beginning, I want to play it at a given position. So I wait until the asset is ready for Play using KVO:

BOOL isReadyToSeek = (self.playerItem.status == AVPlayerStatusReadyToPlay) 

And then seek to the given time

[playerItem seekToTime:timeInTheMiddleOfTheVideo completionHandler:myHandler]; 

But the player will always start at the beginning of the video on the initial seek.

Update I tried a dispatch_after with a few seconds but that does not work either. It works after playback but never initially.

When I observe self.player.currentItem.duration I keep getting 0 as the value and timescale.