{"id":376722,"date":"2024-05-21T21:01:11","date_gmt":"2024-05-21T21:01:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=376722"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=376722","title":{"rendered":"<span>AVPlayer seek(to:\u2026 vs seek(\u2026tolerance<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c! \u042d\u0442\u043e \u043c\u043e\u044f \u0432\u043d\u0435\u043e\u0447\u0435\u0440\u0435\u0434\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f, \u043e \u0442\u043e\u043c \u0447\u0442\u043e \u043d\u0430\u0433\u043e\u0440\u0435\u043b\u043e. \u0423 \u043c\u0435\u043d\u044f \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0433\u043e\u0434 \u043d\u0430\u043a\u043e\u043f\u0438\u043b\u043e\u0441\u044c \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e (\u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c\u00a0\ud83d\ude42 ) \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430. \u041d\u043e \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u0445\u043e\u0447\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u043d\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u041d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 seek(to: CMTime). \u041e\u0431 \u044d\u0442\u043e\u043c \u0438 \u0445\u043e\u0447\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c.<\/p>\n<p>\u041d\u043e \u043d\u0430\u0447\u043d\u0435\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/p>\n<p><strong>AVPlayer<\/strong>\u00a0\u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u043d\u0430\u043c \u0441 iOS 4. \u041e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 AVPlayerItem, AVAsset.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e7a\/98d\/5ac\/e7a98d5acb7b858549082c56ba981ccf.png\" width=\"882\" height=\"730\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e7a\/98d\/5ac\/e7a98d5acb7b858549082c56ba981ccf.png\"\/><\/figure>\n<p>\u041e\u0441\u043d\u043e\u0432\u0430 AVPlayer\u200a\u2014\u200aAVFoundation, CoreAudio \u0438 CoreVideo.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ea4\/d5e\/3db\/ea4d5e3db6657de0f9492612dad3983a.png\" width=\"1164\" height=\"480\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ea4\/d5e\/3db\/ea4d5e3db6657de0f9492612dad3983a.png\"\/><\/figure>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u044f \u043d\u0430\u043f\u0438\u0448\u0443 \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u0438 \u043f\u0440\u043e \u0441\u0432\u043e\u0439 \u0442\u0440\u0438\u043c\u043c\u0435\u0440, \u043d\u0443 \u0430 \u043f\u043e\u043a\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0438\u0434\u0435\u043e\u043f\u043b\u0435\u0435\u0440\u0430, \u0442\u0440\u0438\u043c\u043c\u0435\u0440\u0430 \u0438 \u0442\u0434.<\/p>\n<p><a href=\"https:\/\/medium.com\/zrealm-ios-dev\/avplayer-%E5%AF%A6%E8%B8%90%E6%9C%AC%E5%9C%B0-cache-%E5%8A%9F%E8%83%BD%E5%A4%A7%E5%85%A8-6ce488898003\" rel=\"noopener noreferrer nofollow\"><strong>AVPlayer \u5be6\u8e10\u672c\u5730 Cache \u529f\u80fd\u5927\u5168<\/strong><em>AVPlayer\/AVQueuePlayer with AVURLAsset \u5be6\u4f5c AVAssetResourceLoaderDelegate<\/em>medium.com<\/a><\/p>\n<p><a href=\"https:\/\/img.ly\/blog\/trim-and-crop-video-in-swift\/\" rel=\"noopener noreferrer nofollow\"><strong>How to Trim and Crop Video in Swift | IMG.LY Blog<\/strong><em>Learn how to use Swift and AVKit to crop a video clip and trim a video timeline with our step-by-step tutorial.<\/em>img.ly<\/a><\/p>\n<p>\u041d\u043e \u043a \u043d\u0435\u0441\u0447\u0430\u0442\u044c\u044e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e, \u043b\u0438\u0431\u043e \u0442\u0435\u043c\u0430 \u043f\u043e\u0434\u0437\u0430\u0440\u0436\u0430\u0432\u0435\u043b\u0430, \u043b\u0438\u0431\u043e \u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c AVAsset\u200a\u2014\u200a\u043d\u0435 \u043b\u0435\u0433\u043a\u043e\u0435 \u0434\u0435\u043b\u043e.<\/p>\n<p>\u041d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0442\u0440\u0438\u043c\u043c\u0435\u0440 \u0432\u0438\u0434\u0435\u043e. \u0412\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u043b \u043f\u0440\u043e\u0435\u043a\u0442 Andreas Verhoeven.\u00a0<\/p>\n<p><a href=\"https:\/\/github.com\/AndreasVerhoeven\/VideoTrimmerControl\" rel=\"noopener noreferrer nofollow\"><strong>GitHub &#8212; AndreasVerhoeven\/VideoTrimmerControl: A VideoTrimmer Control for iOS<\/strong><em>A VideoTrimmer Control for iOS. Contribute to AndreasVerhoeven\/VideoTrimmerControl development by creating an account\u2026<\/em>github.com<\/a><\/p>\n<p>\u0412 \u043c\u043e\u0435\u043c \u0442\u0440\u0438\u043c\u043c\u0435\u0440\u0435\u200a\u2014\u200a\u0432\u0438\u0448\u0435\u043d\u043a\u043e\u0439 \u043d\u0430 \u0442\u043e\u0440\u0442\u0435 \u0441\u0442\u0430\u043b\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0442\u0440\u0438\u043c\u043c\u0430 \u043d\u0435 \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u043f\u043e\u0438\u043d\u0442\u0430\u0445 \u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 \u0434\u043b\u0438\u043d\u044b \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u0432\u0438\u0434\u0435\u043e.\u00a0<\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434\u200a\u2014\u200a\u0434\u043b\u0438\u043d\u0430 \u0432\u044c\u044e \u0440\u0430\u0432\u043d\u044f\u0435\u0442\u0441\u044f 100 % \u0432\u0438\u0434\u0435\u043e. \u0418 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u043a\u0440\u0430\u0435\u0432 \u043c\u044b \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u043c \u0432\u0438\u0434\u0435\u043e. \u041b\u043e\u0433\u0438\u043a\u0430 \u0436\u0435\u043b\u0435\u0437\u043d\u0430\u044f\u200a\u2014\u200a\u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u043d\u043e, \u043d\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0431\u044b\u043b\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043a\u0440\u0430\u044f\u043c\u0438 \u043e\u0431\u0440\u0435\u0437\u043a\u0430 34 \u043f\u043e\u0438\u043d\u0442\u0430 \u0438 \u0432 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u0438 74 \u043f\u043e\u0438\u043d\u0442\u0430\u200a\u2014\u200a\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u043d\u043e\u0435 \u0432\u0438\u0434\u0435\u043e, \u0430 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u0440\u044c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 1 \u0441\u0435\u043a \u0434\u043e 5 \u0441\u0435\u043a. \u0421\u043a\u0430\u0437\u0430\u043d\u043e, \u0441\u0434\u0435\u043b\u0430\u043d\u043e.<\/p>\n<p>\u041f\u0440\u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0430 \u043f\u0440\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0438 \u043b\u0435\u0432\u043e\u0433\u043e \u0438 \u043f\u0440\u0430\u0432\u043e\u0433\u043e \u043a\u0440\u0430\u044f \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0435\u043e, \u043a\u0430\u0434\u0440\u044b \u0432 \u043e\u043a\u043d\u0435 \u043f\u043b\u0435\u0435\u0440\u0430, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0441 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c \u0432 1 \u0441\u0435\u043a.\u200a\u2014\u200a\u043d\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u043e, \u043d\u0430\u0434\u043e \u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0443\u0442\u043e\u0447\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u0434\u0440\u0430 \u0432 \u043e\u043a\u043d\u0435 \u043f\u043b\u0435\u0435\u0440\u0430, \u043f\u0440\u0438 \u043e\u0431\u0440\u0435\u0437\u043a\u0435 \u0432\u0438\u0434\u0435\u043e, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043c\u0435\u0442\u043e\u0434 seek(to: CMTime)<\/p>\n<pre><code>player?.seek(to: time)<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0443\u0442 \u043c\u044b \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 AVPlayer\u200a\u2014\u200a seek(to: CMTime) \u0438 \u0435\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0438.<\/p>\n<pre><code>open func seek(to time: CMTime) open func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime)  \/\/\/ group of methods with @available(iOS 5.0, *)  open func seek(to time: CMTime, completionHandler: @escaping (Bool) -> Void) open func seek(to time: CMTime) async -> Bool open func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime, completionHandler: @escaping (Bool) -> Void) open func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime) async -> Bool<\/code><\/pre>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0440\u0435\u043c\u044f CMTime\u00a0<\/p>\n<pre><code>let seconds: Double = 103.5867 let time = CMTime(seconds: seconds, preferredTimescale: 1000)<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 CMTime \u043e\u0442 \u0441\u0435\u043a\u0443\u043d\u0434, \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043c\u0438\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0443 CMTime seconds.<\/p>\n<pre><code>let seconds = time.seconds \/\/ 103.5867<\/code><\/pre>\n<p>\u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c CMTime \u0432\u044b\u0432\u0435\u0434\u0435\u0442\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a. \u0422\u0443\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441 value \u0438 timescale\u200a\u2014\u200a\u043d\u043e \u0435\u0433\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.<\/p>\n<pre><code>(lldb) po time \u25bf CMTime   - value : 48237   - timescale : 30000   \u25bf flags : CMTimeFlags     - rawValue : 1   - epoch : 0<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e time (CMTime) \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043d\u0430\u043c \u043c\u0438\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u043f\u043b\u0435\u0435\u0440.<\/p>\n<pre><code>player.seek(to: time)<\/code><\/pre>\n<p>\u0434\u0430\u043b\u0435\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u043c\u00a0<\/p>\n<pre><code>await player.seek(to: time)<\/code><\/pre>\n<p>\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0444\u0435\u0435\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435<\/p>\n<pre><code>\/** @method seekToTime:completionHandler: @abstract Moves the playback cursor and invokes the specified block when the seek operation has either been completed or been interrupted. @param time @param completionHandler @discussion Use this method to seek to a specified time for the current player item and to be notified when the seek operation is complete. The completion handler for any prior seek request that is still in process will be invoked immediately with the finished parameter set to NO. If the new request completes without being interrupted by another seek request or by any other operation the specified completion handler will be invoked with the finished parameter set to YES. If no item is attached, the completion handler will be invoked immediately with the finished parameter set to NO. *\/<\/code><\/pre>\n<p>\u0434\u0430\u043b\u0435\u0435<\/p>\n<pre><code>player.seek(to: time) { ... }<\/code><\/pre>\n<p>\u0442\u0443\u0442 \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0432\u0441\u0435 \u0432\u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u043d\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u200a\u2014\u200a\u043f\u043b\u0435\u0435\u0440 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043a\u0430\u0434\u0440 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0431\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043a\u043e\u0432. ?<\/p>\n<p>\u0434\u0430\u043b\u0435\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u201cseekToTime:toleranceBefore:toleranceAfter:\u201d<\/p>\n<pre><code>\/** @method seekToTime:toleranceBefore:toleranceAfter: @abstract Moves the playback cursor within a specified time bound. @param time @param toleranceBefore @param toleranceAfter @discussion Use this method to seek to a specified time for the current player item. The time seeked to will be within the range [time-toleranceBefore, time+toleranceAfter] and may differ from the specified time for efficiency. Pass kCMTimeZero for both toleranceBefore and toleranceAfter to request sample accurate seeking which may incur additional decoding delay. Messaging this method with beforeTolerance:kCMTimePositiveInfinity and afterTolerance:kCMTimePositiveInfinity is the same as messaging seekToTime: directly. *\/ open func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime)<\/code><\/pre>\n<p>\u0432 \u0433\u043b\u0430\u0437\u0430 \u0431\u0440\u043e\u0441\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u043e\u0432\u0430:<\/p>\n<ul>\n<li>\n<p>\u201c<strong>and may differ from the specified time for efficiency<\/strong>\u201d<\/p>\n<\/li>\n<li>\n<p>\u201c<strong>which may incur additional decoding delay<\/strong>\u201d<\/p>\n<\/li>\n<li>\n<p>\u201c<strong>kCMTimePositiveInfinity is the same as messaging seekToTime: directly<\/strong>\u201d<\/p>\n<\/li>\n<\/ul>\n<p>\u043f\u043e\u0441\u043b\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u201cseekToTime:\u201d<\/p>\n<pre><code>\/** @method seekToTime: @abstract Moves the playback cursor. @param time @discussion Use this method to seek to a specified time for the current player item. The time seeked to may differ from the specified time for efficiency. For sample accurate seeking see seekToTime:toleranceBefore:toleranceAfter:. *\/<\/code><\/pre>\n<p>\u0438 \u0442\u0443\u0442 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u200a\u2014\u200a\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043b\u0435\u0435\u0440 ( AVPlayer)\u200a\u2014\u200a\u0441\u0430\u043c \u0440\u0435\u0448\u0430\u0435\u0442 \u043d\u0430 \u043a\u0430\u043a\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043f\u043b\u0435\u0435\u0440 \u201c<strong>may differ from the specified time for efficiency<\/strong>\u201d ? \u0438 \u201c<strong>For sample accurate seeking see seekToTime:toleranceBefore:toleranceAfter:<\/strong>\u201d<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c,\u00a0<\/p>\n<pre><code>player.seek(to: time, toleranceBefore: .zero, toleranceAfter: .zero)<\/code><\/pre>\n<p>\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043f\u043b\u0435\u0435\u0440 \u043f\u043e \u043c\u0438\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u043c. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u0441\u0442\u0430\u0432\u0438\u043c \u0431\u0430\u043d \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u201cseekToTime\u201d \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u201c<strong>seekToTime:toleranceBefore:toleranceAfter:<\/strong>\u201d.<\/p>\n<p><strong>\u0412\u044b\u0432\u043e\u0434\u044b:<\/strong><\/p>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u201cseekToTime\u201d \u0432 \u043f\u043b\u0435\u0435\u0440\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443,<\/p>\n<p>\u043f\u043e\u0447\u0435\u043c\u0443 \u201cseekToTime\u201d \u0440\u0435\u0448\u0438\u043b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u043f\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e Apple,<\/p>\n<p>\u0434\u0430\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u201c<strong>seekToTime:toleranceBefore:toleranceAfter:<\/strong>\u201d. ?<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/815999\/\"> https:\/\/habr.com\/ru\/articles\/815999\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c! \u042d\u0442\u043e \u043c\u043e\u044f \u0432\u043d\u0435\u043e\u0447\u0435\u0440\u0435\u0434\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f, \u043e \u0442\u043e\u043c \u0447\u0442\u043e \u043d\u0430\u0433\u043e\u0440\u0435\u043b\u043e. \u0423 \u043c\u0435\u043d\u044f \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0433\u043e\u0434 \u043d\u0430\u043a\u043e\u043f\u0438\u043b\u043e\u0441\u044c \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0433\u043e (\u0438 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c\u00a0\ud83d\ude42 ) \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430. \u041d\u043e \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u0445\u043e\u0447\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u043d\u0435 \u043e\u0447\u0435\u0440\u0435\u0434\u0438. \u041d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 seek(to: CMTime). \u041e\u0431 \u044d\u0442\u043e\u043c \u0438 \u0445\u043e\u0447\u0443 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c.<\/p>\n<p>\u041d\u043e \u043d\u0430\u0447\u043d\u0435\u043c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/p>\n<p><strong>AVPlayer<\/strong>\u00a0\u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u043d\u0430\u043c \u0441 iOS 4. \u041e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 AVPlayerItem, AVAsset.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041e\u0441\u043d\u043e\u0432\u0430 AVPlayer\u200a\u2014\u200aAVFoundation, CoreAudio \u0438 CoreVideo.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c \u044f \u043d\u0430\u043f\u0438\u0448\u0443 \u043f\u043e\u0437\u0434\u043d\u0435\u0435 \u0438 \u043f\u0440\u043e \u0441\u0432\u043e\u0439 \u0442\u0440\u0438\u043c\u043c\u0435\u0440, \u043d\u0443 \u0430 \u043f\u043e\u043a\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0442\u0430\u0442\u044c\u0438 \u043f\u0440\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u0438\u0434\u0435\u043e\u043f\u043b\u0435\u0435\u0440\u0430, \u0442\u0440\u0438\u043c\u043c\u0435\u0440\u0430 \u0438 \u0442\u0434.<\/p>\n<p><a href=\"https:\/\/medium.com\/zrealm-ios-dev\/avplayer-%E5%AF%A6%E8%B8%90%E6%9C%AC%E5%9C%B0-cache-%E5%8A%9F%E8%83%BD%E5%A4%A7%E5%85%A8-6ce488898003\" rel=\"noopener noreferrer nofollow\"><strong>AVPlayer \u5be6\u8e10\u672c\u5730 Cache \u529f\u80fd\u5927\u5168<\/strong><em>AVPlayer\/AVQueuePlayer with AVURLAsset \u5be6\u4f5c AVAssetResourceLoaderDelegate<\/em>medium.com<\/a><\/p>\n<p><a href=\"https:\/\/img.ly\/blog\/trim-and-crop-video-in-swift\/\" rel=\"noopener noreferrer nofollow\"><strong>How to Trim and Crop Video in Swift | IMG.LY Blog<\/strong><em>Learn how to use Swift and AVKit to crop a video clip and trim a video timeline with our step-by-step tutorial.<\/em>img.ly<\/a><\/p>\n<p>\u041d\u043e \u043a \u043d\u0435\u0441\u0447\u0430\u0442\u044c\u044e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e, \u043b\u0438\u0431\u043e \u0442\u0435\u043c\u0430 \u043f\u043e\u0434\u0437\u0430\u0440\u0436\u0430\u0432\u0435\u043b\u0430, \u043b\u0438\u0431\u043e \u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c AVAsset\u200a\u2014\u200a\u043d\u0435 \u043b\u0435\u0433\u043a\u043e\u0435 \u0434\u0435\u043b\u043e.<\/p>\n<p>\u041d\u0435 \u0442\u0430\u043a \u0434\u0430\u0432\u043d\u043e \u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0442\u0440\u0438\u043c\u043c\u0435\u0440 \u0432\u0438\u0434\u0435\u043e. \u0412\u0434\u043e\u0445\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u043e\u0441\u043b\u0443\u0436\u0438\u043b \u043f\u0440\u043e\u0435\u043a\u0442 Andreas Verhoeven.\u00a0<\/p>\n<p><a href=\"https:\/\/github.com\/AndreasVerhoeven\/VideoTrimmerControl\" rel=\"noopener noreferrer nofollow\"><strong>GitHub &#8212; AndreasVerhoeven\/VideoTrimmerControl: A VideoTrimmer Control for iOS<\/strong><em>A VideoTrimmer Control for iOS. Contribute to AndreasVerhoeven\/VideoTrimmerControl development by creating an account\u2026<\/em>github.com<\/a><\/p>\n<p>\u0412 \u043c\u043e\u0435\u043c \u0442\u0440\u0438\u043c\u043c\u0435\u0440\u0435\u200a\u2014\u200a\u0432\u0438\u0448\u0435\u043d\u043a\u043e\u0439 \u043d\u0430 \u0442\u043e\u0440\u0442\u0435 \u0441\u0442\u0430\u043b\u0430 \u043b\u043e\u0433\u0438\u043a\u0430 \u0442\u0440\u0438\u043c\u043c\u0430 \u043d\u0435 \u0437\u0430\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u043d\u0430 \u043f\u043e\u0438\u043d\u0442\u0430\u0445 \u0438 \u043f\u0438\u043a\u0441\u0435\u043b\u044f\u0445 \u0434\u043b\u0438\u043d\u044b \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u0432\u0438\u0434\u0435\u043e.\u00a0<\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u0434\u0445\u043e\u0434\u200a\u2014\u200a\u0434\u043b\u0438\u043d\u0430 \u0432\u044c\u044e \u0440\u0430\u0432\u043d\u044f\u0435\u0442\u0441\u044f 100 % \u0432\u0438\u0434\u0435\u043e. \u0418 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u043a\u0440\u0430\u0435\u0432 \u043c\u044b \u043e\u0431\u0440\u0435\u0437\u0430\u0435\u043c \u0432\u0438\u0434\u0435\u043e. \u041b\u043e\u0433\u0438\u043a\u0430 \u0436\u0435\u043b\u0435\u0437\u043d\u0430\u044f\u200a\u2014\u200a\u0432\u0441\u0435 \u043a\u043b\u0430\u0441\u0441\u043d\u043e, \u043d\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0431\u044b\u043b\u0430 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u043a\u0440\u0430\u044f\u043c\u0438 \u043e\u0431\u0440\u0435\u0437\u043a\u0430 34 \u043f\u043e\u0438\u043d\u0442\u0430 \u0438 \u0432 \u0441\u043e\u0432\u043e\u043a\u0443\u043f\u043d\u043e\u0441\u0442\u0438 74 \u043f\u043e\u0438\u043d\u0442\u0430\u200a\u2014\u200a\u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u043d\u043e\u0435 \u0432\u0438\u0434\u0435\u043e, \u0430 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0430\u0440\u044c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 1 \u0441\u0435\u043a \u0434\u043e 5 \u0441\u0435\u043a. \u0421\u043a\u0430\u0437\u0430\u043d\u043e, \u0441\u0434\u0435\u043b\u0430\u043d\u043e.<\/p>\n<p>\u041f\u0440\u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0430 \u043f\u0440\u0438 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u0438 \u043b\u0435\u0432\u043e\u0433\u043e \u0438 \u043f\u0440\u0430\u0432\u043e\u0433\u043e \u043a\u0440\u0430\u044f \u043e\u0431\u0440\u0435\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0435\u043e, \u043a\u0430\u0434\u0440\u044b \u0432 \u043e\u043a\u043d\u0435 \u043f\u043b\u0435\u0435\u0440\u0430, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0442\u0441\u044f \u0441 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c \u0432 1 \u0441\u0435\u043a.\u200a\u2014\u200a\u043d\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u043e, \u043d\u0430\u0434\u043e \u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0443\u0442\u043e\u0447\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u0430\u0434\u0440\u0430 \u0432 \u043e\u043a\u043d\u0435 \u043f\u043b\u0435\u0435\u0440\u0430, \u043f\u0440\u0438 \u043e\u0431\u0440\u0435\u0437\u043a\u0435 \u0432\u0438\u0434\u0435\u043e, \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043c\u0435\u0442\u043e\u0434 seek(to: CMTime)<\/p>\n<pre><code>player?.seek(to: time)<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0443\u0442 \u043c\u044b \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 AVPlayer\u200a\u2014\u200a seek(to: CMTime) \u0438 \u0435\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u0438.<\/p>\n<pre><code>open func seek(to time: CMTime) open func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime)  \/\/\/ group of methods with @available(iOS 5.0, *)  open func seek(to time: CMTime, completionHandler: @escaping (Bool) -> Void) open func seek(to time: CMTime) async -> Bool open func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime, completionHandler: @escaping (Bool) -> Void) open func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime) async -> Bool<\/code><\/pre>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0440\u0435\u043c\u044f CMTime\u00a0<\/p>\n<pre><code>let seconds: Double = 103.5867 let time = CMTime(seconds: seconds, preferredTimescale: 1000)<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 CMTime \u043e\u0442 \u0441\u0435\u043a\u0443\u043d\u0434, \u0442\u0430\u043a\u0436\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u043c\u0438\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u044b. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e \u0447\u0442\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u0443 CMTime seconds.<\/p>\n<pre><code>let seconds = time.seconds \/\/ 103.5867<\/code><\/pre>\n<p>\u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c CMTime \u0432\u044b\u0432\u0435\u0434\u0435\u0442\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a. \u0422\u0443\u0442 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441 value \u0438 timescale\u200a\u2014\u200a\u043d\u043e \u0435\u0433\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c.<\/p>\n<pre><code>(lldb) po time \u25bf CMTime   - value : 48237   - timescale : 30000   \u25bf flags : CMTimeFlags     - rawValue : 1   - epoch : 0<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e time (CMTime) \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043d\u0430\u043c \u043c\u0438\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0432 \u043f\u043b\u0435\u0435\u0440.<\/p>\n<pre><code>player.seek(to: time)<\/code><\/pre>\n<p>\u0434\u0430\u043b\u0435\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u043c\u00a0<\/p>\n<pre><code>await player.seek(to: time)<\/code><\/pre>\n<p>\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0444\u0435\u0435\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435<\/p>\n<pre><code>\/** @method seekToTime:completionHandler: @abstract Moves the playback cursor and invokes the specified block when the seek operation has either been completed or been interrupted. @param time @param completionHandler @discussion Use this method to seek to a specified time for the current player item and to be notified when the seek operation is complete. The completion handler for any prior seek request that is still in process will be invoked immediately with the finished parameter set to NO. If the new request completes without being interrupted by another seek request or by any other operation the specified completion handler will be invoked with the finished parameter set to YES. If no item is attached, the completion handler will be invoked immediately with the finished parameter set to NO. *\/<\/code><\/pre>\n<p>\u0434\u0430\u043b\u0435\u0435<\/p>\n<pre><code>player.seek(to: time) { ... }<\/code><\/pre>\n<p>\u0442\u0443\u0442 \u0441 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0432\u0441\u0435 \u0432\u043f\u043e\u0440\u044f\u0434\u043a\u0435. \u043d\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u200a\u2014\u200a\u043f\u043b\u0435\u0435\u0440 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043a\u0430\u0434\u0440 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443 \u0431\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043a\u043e\u0432. ?<\/p>\n<p>\u0434\u0430\u043b\u0435\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u201cseekToTime:toleranceBefore:toleranceAfter:\u201d<\/p>\n<pre><code>\/** @method seekToTime:toleranceBefore:toleranceAfter: @abstract Moves the playback cursor within a specified time bound. @param time @param toleranceBefore @param toleranceAfter @discussion Use this method to seek to a specified time for the current player item. The time seeked to will be within the range [time-toleranceBefore, time+toleranceAfter] and may differ from the specified time for efficiency. Pass kCMTimeZero for both toleranceBefore and toleranceAfter to request sample accurate seeking which may incur additional decoding delay. Messaging this method with beforeTolerance:kCMTimePositiveInfinity and afterTolerance:kCMTimePositiveInfinity is the same as messaging seekToTime: directly. *\/ open func seek(to time: CMTime, toleranceBefore: CMTime, toleranceAfter: CMTime)<\/code><\/pre>\n<p>\u0432 \u0433\u043b\u0430\u0437\u0430 \u0431\u0440\u043e\u0441\u0430\u044e\u0442\u0441\u044f \u0441\u043b\u043e\u0432\u0430:<\/p>\n<ul>\n<li>\n<p>\u201c<strong>and may differ from the specified time for efficiency<\/strong>\u201d<\/p>\n<\/li>\n<li>\n<p>\u201c<strong>which may incur additional decoding delay<\/strong>\u201d<\/p>\n<\/li>\n<li>\n<p>\u201c<strong>kCMTimePositiveInfinity is the same as messaging seekToTime: directly<\/strong>\u201d<\/p>\n<\/li>\n<\/ul>\n<p>\u043f\u043e\u0441\u043b\u0435 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u201cseekToTime:\u201d<\/p>\n<pre><code>\/** @method seekToTime: @abstract Moves the playback cursor. @param time @discussion Use this method to seek to a specified time for the current player item. The time seeked to may differ from the specified time for efficiency. For sample accurate seeking see seekToTime:toleranceBefore:toleranceAfter:. *\/<\/code><\/pre>\n<p>\u0438 \u0442\u0443\u0442 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f\u200a\u2014\u200a\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043b\u0435\u0435\u0440 ( AVPlayer)\u200a\u2014\u200a\u0441\u0430\u043c \u0440\u0435\u0448\u0430\u0435\u0442 \u043d\u0430 \u043a\u0430\u043a\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u043f\u043b\u0435\u0435\u0440 \u201c<strong>may differ from the specified time for efficiency<\/strong>\u201d ? \u0438 \u201c<strong>For sample accurate seeking see seekToTime:toleranceBefore:toleranceAfter:<\/strong>\u201d<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c,\u00a0<\/p>\n<pre><code>player.seek(to: time, toleranceBefore: .zero, toleranceAfter: .zero)<\/code><\/pre>\n<p>\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442 \u043f\u043b\u0435\u0435\u0440 \u043f\u043e \u043c\u0438\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u043c. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043c\u044b \u0441\u0442\u0430\u0432\u0438\u043c \u0431\u0430\u043d \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u201cseekToTime\u201d \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u201c<strong>seekToTime:toleranceBefore:toleranceAfter:<\/strong>\u201d.<\/p>\n<p><strong>\u0412\u044b\u0432\u043e\u0434\u044b:<\/strong><\/p>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u201cseekToTime\u201d \u0432 \u043f\u043b\u0435\u0435\u0440\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443,<\/p>\n<p>\u043f\u043e\u0447\u0435\u043c\u0443 \u201cseekToTime\u201d \u0440\u0435\u0448\u0438\u043b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0432\u0438\u0434\u0435\u043e \u043f\u043e\u0441\u0435\u043a\u0443\u043d\u0434\u043d\u043e \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e Apple,<\/p>\n<p>\u0434\u0430\u043b\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u201c<strong>seekToTime:toleranceBefore:toleranceAfter:<\/strong>\u201d. ?<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/815999\/\"> https:\/\/habr.com\/ru\/articles\/815999\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-376722","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/376722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=376722"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/376722\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=376722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=376722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=376722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}