AVPlayer seekToTime methods stopped working on iOS 9

888 Views Asked by At

I have been working on a Video Player which is streaming a video asset using HLS. Once I started debugging it on iOS 9, I noticed that the scrub feature stopped working properly. However, it still works on iOS 8 devices.

Looking more into the problem I narrowed that the issue must be in the seekToTime method calls.

The scrub flow is the following:

  • when scrub starts, the video is paused using AVPlayer pause instance method
  • when the scrub ends seek the time using AVPlayer seekToTime: instance method
  • After that play the video using AVPlayer play instance method

I tried some other options for changing the current playhead such as seekToTime:completionHandler:, but still the same result.

On iOS 9 release notes (https://developer.apple.com/library/prerelease/ios/releasenotes/General/RN-iOSSDK-9.0/), I saw that they made some changes to the AVFoundation, so I wonder if there are any known issues related to this with the iOS 9 release?

2

There are 2 best solutions below

0
On

I just came across this issue and thanks to your link, I found the solution. This is from the release note:

In iOS 9, these operations interrupt only when AVPlayer object’s playback rate is changed to a non-zero value through the rate property or play method.

which means we have to set

player.rate = 1

before calling seekToTime

0
On

do not use player.pause before seekToTime player.rate has nothing to do with that issue