ModernAVPlayer icon indicating copy to clipboard operation
ModernAVPlayer copied to clipboard

Precise seek missing

Open yaroslavlvov opened this issue 4 years ago • 3 comments

Sometimes there are cases where you need precise seeking which is called like this

player.seek(to: CMTime(seconds: 100, preferredTimescale: CMTimeScale(NSEC_PER_SEC)), toleranceBefore: .zero, toleranceAfter: .zero)

Screenshot 2020-12-23 at 14 30 44

currently seeking is not precise which is fine in most cases, however it would be nice to have precise seek

proposed solution extend current seek methods with another one with additional parameter isPrecise or isAccurate to not introduce breaking changes, example:

existing:
public func seek(position: Double) {
        context.seek(position: position, isPrecise: false)
}

new:
public func seek(position: Double, isPrecise: Bool) {
        context.seek(position: position, isPrecise: isPrecise)
}

would you approve this type of PR if I do? @raphrel

yaroslavlvov avatar Dec 23 '20 12:12 yaroslavlvov

sure, I'm always open for PR ! thanks

raphrel avatar Jan 07 '21 20:01 raphrel

what do you think of this instead:

public func seek(position: Double, tolerance: CMTime) {
        context.seek(position: position, tolerance: tolerance)
}

raphrel avatar Jan 07 '21 21:01 raphrel

If you want to go with CMTime parameters in api, I would rather replicate apple's api with toleranceBefore and toleranceAfter, but to simplify api and abstract more from AVFoundation isAccurate parameters looks better to me being clear to understand(can be explained in docs in addition)

yaroslavlvov avatar Jan 08 '21 02:01 yaroslavlvov