       return
     }
 
-    NSNotificationCenter.defaultCenter().addObserver(
-      self,
-      selector: #selector(handlePlayerItemDidPlayToEndTime(_:)),
-      name: AVPlayerItemDidPlayToEndTimeNotification,
-      object: playerItem
-    )
+    for notification in playerItemNotifications {
+      NSNotificationCenter.defaultCenter().addObserver(
+        self,
+        selector: .handlePlayerItemNotification,
+        name: notification,
+        object: playerItem
+      )
+    }
 
     player = AVPlayer(playerItem: playerItem)
     player?.play()
   }
 
 }
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+
+private extension Selector {
+  static let handlePlayerItemNotification = #selector(VideoPlayerController.handlePlayerItemNotification(_:))
+}

  }

  deinit {
    NSNotificationCenter.defaultCenter().removeObserver(
      self,
      name: AVPlayerItemDidPlayToEndTimeNotification,
      object: nil
    )
  }

  // MARK: - UIViewController


  // MARK: - NSNotification Callbacks

  @objc private func handlePlayerItemNotification(notification: NSNotification) {
    switch notification.name {
    case AVPlayerItemDidPlayToEndTimeNotification:
      dismiss()
    default:
      break
    }
  }

  // MARK: - Private Methods
