AVPlayer.timeControlStatus and AVPlayer.rate are wrong during fast forward or backward

It seems that timeControlStatus == .paused and rate == 0 when the video is being played fast forward or backward. Is this really how it's supposed to be? If yes, is there a way of knowing if the video is effectively paused?

Replies

Can you clarify what you mean by "being played fast forward?" Have you set your AVPlayer rate to something greater than 1.0?
When setting rate = 2 or pressing the L key while playing the video at normal speed, the video gets played fast forward. Either way rate is returned as being 0, even when doing rate = 2 in code.
In what app are you "pressing the L key?"
I'm pressing L after pressing the play button in the AVPlayerView.
Hey Nickkk, to answer the question 'is there a way to know if a video is effectively paused'. I depends on what you mean by effectively paused. When the players rate is set to 0, the video is paused. That being said, the rate being set to 0 and the video being paused does not necessarily indicate that the content of the video layers frame is not changing. For example, the asset may change in the player or there may be a seek operations that changes the currently displayed frame - all while the rate is set to 0.

When a user scrubs, seeks, fast forwards, rewinds, uses trackpad or touch gestures or key bindings that would result in the AVPlayer changing times we may set the rate to 0 during the operation, but in most cases we will restore the rate thereafter.

Outside of these (and a few other operations at the control of the AVPlayer owner), checking that the AVPlayer's rate is 0 or timeControlStatus == .paused should be sufficient for determining whether the video frame is not changing.
Thanks for your help, but I don't get what you mean with this:

When a user scrubs, seeks, fast forwards, rewinds, uses trackpad or touch gestures or key bindings that would result in the AVPlayer changing times we may set the rate to 0 during the operation, but in most cases we will restore the rate thereafter.

Who is "we"? Is it AVKit or I the developer who uses AVKit? If you really mean the latter, then why would we set the rate to 0? And how would we intercept all those operations, when AVPlayerView already does it?

checking that the AVPlayer's rate is 0 or timeControlStatus == .paused should be sufficient for determining whether the video frame is not changing

As I said, timeControlStatus == .paused is true even when the user plays fast forward or backward (by pressing L twice or J after pressing the play button) and even if during this time the pause button is shown and not the play button. I would have expected that whenever the pause button is shown timeControlStatus != .paused and rate != 0. In the end I really just want to know if the play or pause button is shown, so that I can react to changes in other views and seek to another frame only if the play button is shown and the user is not expecting the video to keep playing.
  • Who is "we"? Is it AVKit or I the developer who uses AVKit? If you really mean the latter, then why would we set the rate to 0? And how would we intercept all those operations, when AVPlayerView already does it?

    We in this case is AVKit and AVFoundation, so the former. Anytime a users seeks, fast forwards/backwards/scans, uses trackpad gestures or key bindings that would result in the media changing times we will set the rate to 0 during the operation. There is no way to directly detect these operations as it stands.

    As I said, timeControlStatus == .paused is true even when the user plays fast forward or backward (by pressing L twice or J after pressing the play button) and even if during this time the pause button is shown and not the play button. I would have expected that whenever the pause button is shown timeControlStatus != .paused and rate != 0. In the end I really just want to know if the play or pause button is shown, so that I can react to changes in other views and seek to another frame only if the play button is shown and the user is not expecting the video to keep playing.

    The video is truely paused when the user fast forwards/scans backwards. When the user requests to fast forward (lets say at 10x - anything >2x), AVKit will pause the video and start periodically seeking very quickly to achieve the look of a higher playback rate - all while the rate is actually 0. (see my previous comments about the rate being 0 not necessarily meaning that the content in the video layer is not changing).

    Unfortunately there is no great way to detect the exact state of the play button during scan/track pad gesture operations at the moment. I would file a feedback request synthesizing the issue here and we will consider adjusting this behavior.

Add a Comment

(formatting in previous comment isn't taking, reposting here)

Who is "we"? Is it AVKit or I the developer who uses AVKit? If you really mean the latter, then why would we set the rate to 0? And how would we intercept all those operations, when AVPlayerView already does it?

We in this case is AVKit and AVFoundation, so the former. Anytime a users seeks, fast forwards/backwards/scans, uses trackpad gestures or key bindings that would result in the media changing times we will set the rate to 0 during the operation. There is no way to directly detect these operations as it stands.

As I said, timeControlStatus == .paused is true even when the user plays fast forward or backward (by pressing L twice or J after pressing the play button) and even if during this time the pause button is shown and not the play button. I would have expected that whenever the pause button is shown timeControlStatus != .paused and rate != 0. In the end I really just want to know if the play or pause button is shown, so that I can react to changes in other views and seek to another frame only if the play button is shown and the user is not expecting the video to keep playing.

The video is truely paused when the user fast forwards/scans backwards. When the user requests to fast forward (lets say at 10x - anything >2x), AVKit will pause the video and start periodically seeking very quickly to achieve the look of a higher playback rate - all while the rate is actually 0. (see my previous comments about the rate being 0 not necessarily meaning that the content in the video layer is not changing).

Unfortunately there is no great way to detect the exact state of the play button during scan/track pad gesture operations at the moment. I would file a feedback request synthesizing the issue here and we will consider adjusting this behavior.

  • Thanks. I already filed a feedback for that. When you say "there is no great way", does that mean that there is at least some way?

Add a Comment

Team,We are in need to differentiate manual pause and pause state caused due to seek(scrubbing uislider in avplayerviewcontroller). We need to send engagement apis on state changes for pause,seek,play. Is there any way to solve this problem. @Media Engineer @Nickkk