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
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…