     override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
         panoramaView?.updateInterfaceOrientation(with: coordinator)
     }
+
+    func togglePlaying() {
+        guard let player = player else {
+            return
+        }
+
+        if player.rate == 0 {
+            player.play()
+        } else {
+            player.pause()
+        }
+    }
 }


    weak var panoramaView: PanoramaView?

    private func loadPanoramaView() {
        let panoramaView = PanoramaView(frame: view.bounds, device: device)
        panoramaView.translatesAutoresizingMaskIntoConstraints = false

            panoramaView.trailingAnchor.constraint(equalTo: view.trailingAnchor)
        ])

        let doubleTapGestureRecognizer = UITapGestureRecognizer(target: panoramaView, action: #selector(PanoramaView.resetCenter))
        doubleTapGestureRecognizer.numberOfTapsRequired = 2
        panoramaView.addGestureRecognizer(doubleTapGestureRecognizer)

        let singleTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(togglePlaying))
        singleTapGestureRecognizer.require(toFail: doubleTapGestureRecognizer)
        panoramaView.addGestureRecognizer(singleTapGestureRecognizer)

        do {
            let url = Bundle.main.url(forResource: "test", withExtension: "mp4")!
            let player = AVPlayer(url: url)
            try panoramaView.load(player, format: .mono)
            player.play()
            self.player = player
        } catch {
            fatalError(error.localizedDescription)
        }
