private void ReleasePlayer()
 {
     if (_player != null)
     {
         _debugViewHelper.Stop();
         _debugViewHelper = null;
         _playerPosition = _player.CurrentPosition;
         _player.Release();
         _player = null;
         _eventLogger.EndSession();
         _eventLogger = null;
     }
 }
 private void PreparePlayer(bool playWhenReady)
 {
     if (_player == null)
     {
         _player = new VideoPlayer(GetRendererBuilder());
         _player.AddListener(this);
         _player.SetCaptionListener(this);
         _player.SetMetadataListener(this);
         _player.SeekTo(_playerPosition);
         _playerNeedsPrepare = true;
         _mediaController.SetMediaPlayer(_player.PlayerControl);
         _mediaController.Enabled = true;
         _eventLogger = new EventLogger();
         _eventLogger.StartSession();
         _player.AddListener(_eventLogger);
         _player.SetInfoListener(_eventLogger);
         _player.SetInternalErrorListener(_eventLogger);
         _debugViewHelper = new DebugTextViewHelper(_player, _debugTextView);
         _debugViewHelper.Start();
     }
     if (_playerNeedsPrepare)
     {
         _player.Prepare();
         _playerNeedsPrepare = false;
         UpdateButtonVisibilities();
     }
     _player.Surface = _surfaceView.Holder.Surface;
     _player.PlayWhenReady = playWhenReady;
 }