Reputation: 11
it is since a lot of time that I´m experiencing a weird seek slider behavior when seeking forward or backwards on streamed movies using MPMoviePlayerController. The symptoms are:
. You begin the seek gesture on slider and the slider button follows the finger. . When slider is released, it jumps back to the gesture starting point and slingers to the point where the gesture was finished. . Then playback continues from the selected movie time.
This is of course visually annoying, although the functionality is OK. This is even worst on iOS 7.
Thanks for the welcome help.
Upvotes: 0
Views: 604
Reputation: 3146
Perhaps a bit late to answer this, but since I stumbled upon this on a Google search, maybe this will be of help to someone else.
I ran into this behavior with AVPlayer and found the reason to be because of a time observer that kept running during scrubbing. The time observer was in charge of updating the scrubber position based on what the current playback time was. So, once the gesture finished moving the slider, the time observer would move the slider knob back to where it thought playback was before the scrubbing action updated the play clock.
My solution was to temporarily remove this time observer right when scrubbing began, and recreate it once scrubbing ended.
When scrubbing begins:
if (scrubberTimeObserver) {
[player removeTimeObserver:scrubberTimeObserver];
scrubberTimeObserver = nil;
}
Note the you will want to know the name of your time observer so you make sure you're removing the correct one.
When scrubbing ends:
scrubberTimeObserver = [player addPeriodicTimeObserverForInterval:CMTimeMakeWithSeconds(interval, NSEC_PER_SEC)
queue:dispatch_get_main_queue()
usingBlock:^(CMTime time) {
[weakSelf syncScrubber];
}
];
Upvotes: 2