     }
 
     init!(movieURL: NSURL) {
+        playerItem = AVPlayerItem(URL: movieURL)
+        player = AVPlayer(playerItem: playerItem)
+        playerView.player = player
+        imageGenerator = AVAssetImageGenerator(asset: playerItem.asset) ※ {
+            $0.requestedTimeToleranceBefore = kCMTimeZero
+            $0.requestedTimeToleranceAfter = kCMTimeZero
+        }
         super.init(nibName: nil, bundle: nil)
-        playerView.player = AVPlayer(URL: movieURL)
     }
 
     required init?(coder: NSCoder) {



class MovieDocumentViewController: NSViewController {
    private let playerView: AVPlayerView = AVPlayerView() ※ { v in
        v.controlsStyle = .Floating
        v.showsFrameSteppingButtons = true

        }

        guard image.TIFFRepresentation?.writeToFile(tmpImagePath, atomically: true) == true else { return }
        guard let session = AVAssetExportSession(asset: playerItem.asset, presetName: AVAssetExportPresetPassthrough) else { return }
        session.outputFileType = "com.apple.quicktime-movie"
        session.outputURL = NSURL(fileURLWithPath: tmpMoviePath)
        session.timeRange = CMTimeRange(start: player.currentTime(), duration: CMTime(value: 3*600, timescale: 600))
