 
     func moveToPageAt(index:Int) {
         print("moveToPageAt", index)
+        if index < pages.count {
+            self.index = index
+            let page = pages[self.index]
+            let start = page["start"] as? Double ?? 0.0
+            //let duration = page["duration"] as? CGFloat ?? 0.0
+            guard let playerItem = videoPlayer.currentItem else {
+                return // something is wrong
+            }
+            let time = CMTime(seconds: start, preferredTimescale: 600)
+            playerItem.seek(to: time) { (success) in
+                print("seek complete", success)
+            }
+        }
     }
     func pageIndex() -> Int? {
-        return 0
+        return index
     }
     func pageCount() -> Int? {
-        return 3
+        return pages.count
     }
 }

import AVFoundation

class SwipeVideoController: UIViewController {
    fileprivate var document:[String:Any]?
    fileprivate weak var delegate:SwipeDocumentViewerDelegate?
    fileprivate var url:URL?
    fileprivate let videoPlayer = AVPlayer()
    fileprivate var videoLayer:AVPlayerLayer!

    override func viewDidLoad() {
        super.viewDidLoad()


extension SwipeVideoController: SwipeDocumentViewer {
    func documentTitle() -> String? {
        return document["title"] as? String
    }
    
    func loadDocument(_ document:[String:Any], size:CGSize, url:URL?, state:[String:Any]?, callback:@escaping (Float, NSError?)->(Void)) throws {
        self.document = document
        self.url = url
        guard let filename = document["video"] as? String,
              let pages = document["pages"] as? [[String:Any]] else {
            throw SwipeError.invalidDocument
        }
        self.pages = pages

        guard let videoURL = Bundle.main.url(forResource: filename, withExtension: nil) else {
            return
