 
         self.addSubview(contentView)
 
-        print("commoninit")
+        print("commonInit")
     }
 
-    // MARK: Live cycle
+    // MARK: Life cycle
+    override func willMove(toSuperview newSuperview: UIView?) {
+        super.willMove(toSuperview: newSuperview)
+
+        playerView.player = player
+
+        for keyPath in observedKeyPaths {
+            self.player.addObserver(self,
+                    forKeyPath: keyPath,
+                    options: [.new, .initial],
+                    context: &playerObserveContext)
+        }
+    }
 
     override func removeFromSuperview() {
         super.removeFromSuperview()
+
+        player.pause()
 
         removeObserver()
     }



protocol MoviePlayerViewDataSource: class {
    func playerItem(in view: MoviePlayerView) -> AVPlayerItem
}

private var playerObserveContext = 0


    private func removeObserver() {
        for keyPath in observedKeyPaths {
            self.player.removeObserver(self, forKeyPath: keyPath)
        }
    }

