 
     weak var panoramaView: PanoramaView?
 
+    var player: AVPlayer?
+
     private func loadPanoramaView() {
         let panoramaView = PanoramaView(frame: view.bounds, device: device)
         panoramaView.translatesAutoresizingMaskIntoConstraints = false

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

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

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

    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()
        }
    }
}
