Automatically dismiss AV Player

Hello:
I am trying to have my AVPlayer to automatically dismiss when Video completes.

The code is giving me some problems with errors. Here is the code and errors. Hope some one can point me to a way to correct the errors:

Code Block
    @IBOutlet weak var playerView: AVPlayerView!
     override func viewDidLoad() {
         super.viewDidLoad()
         guard let path = Bundle.main.path(forResource: "chosePrize", ofType:"mp4") else {
              debugPrint("Not found")
              return
         }
             let playerURL = AVPlayer(url: URL(fileURLWithPath: path))
               playerView.player = playerURL
        NotificationCenter.defaultCenter.addObserver(self, selector: Selector(("playerDidFinishPlaying:")),
        name: NSNotification.Name(name: AVPlayerDidPlayToEndTime, object: nil), //Use of unresolved identifier 'AVPlayerDidPlayToEndTime'
        playerView.player?.play()
    func donePlaying(notification:NSNotification)
// Expected ')' in expression list
{
            print("video ended")
           }
         // Do view setup here.
    }
}