         currentPageIndex = index
         
         if currentPageIndex != previousCurrentPage {
-            didStartViewingPageAtIndex(index)
-        }
-    }
-
-    public func scrollViewWillBeginDragging(scrollView: UIScrollView) {
+            didStartViewingPageAtIndex(index: index)
+        }
+    }
+
+    public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
         // Hide controls when dragging begins
         setControlsHidden(true, animated: true, permanent: false)
     }
 
-    public func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
+    public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
         // Update nav when page changes
         updateNavigation()
     }

    }

    func frameForPlayButton(playButton: UIButton, atIndex index: Int) -> CGRect {
        let pageFrame = frameForPageAtIndex(index)
        return CGRectMake(
            CGFloat(floorf(Float(CGRectGetMidX(pageFrame) - playButton.frame.size.width / 2.0))),
            CGFloat(floorf(Float(CGRectGetMidY(pageFrame) - playButton.frame.size.height / 2.0))),

    }

    func loadAdjacentPhotosIfNecessary(photo: Photo) {
        let page = pageDisplayingPhoto(photo: photo)
        if let p = page {
            // If page is current page then initiate loading of previous and next pages
            let pageIndex = p.index
