Beispiel #1
0
        private void TryDisposePlayer()
        {
            if (_player != null)
            {
                try
                {
                    _videoLayer.RemoveObserver(this, new NSString("videoRect"), _videoLayer.Handle);
                    _videoLayer.RemoveFromSuperLayer();

                    _player.CurrentItem?.RemoveObserver(this, new NSString("loadedTimeRanges"), _player.Handle);
                    _player.CurrentItem?.RemoveObserver(this, new NSString("status"), _player.Handle);
                    _player.CurrentItem?.RemoveObserver(this, new NSString("duration"), _player.Handle);
                    _player.RemoveObserver(this, new NSString("rate"), RateObservationContext.Handle);
                    _player.RemoveTimeObserver(_periodicTimeObserverObject);
                    _player.RemoveAllItems();
                }
                finally
                {
                    _itemFailedToPlayToEndTimeNotification?.Dispose();
                    _playbackStalledNotification?.Dispose();
                    _didPlayToEndTimeNotification?.Dispose();

                    _videoLayer?.Dispose();

                    _player?.CurrentItem?.Dispose();
                    _player?.Dispose();
                    _player = null;
                }
            }
        }
Beispiel #2
0
 public override void ViewDidDisappear(bool animated)
 {
     base.ViewDidDisappear(animated);
     if (player != null)
     {
         player.Pause();
         playerLooper.Dispose();
         player.Dispose();
     }
 }
Beispiel #3
0
        public override void ViewDidDisappear(bool animated)
        {
            base.ViewDidDisappear(animated);

            // Kill media and tidy up
            if (_avplayer != null)
            {
                _avplayer.Pause();
                _avplayer.Dispose();
                _avplayer = null;
            }

            if (_avplayerController != null)
            {
                _avplayerController.RemoveFromParentViewController();
                _avplayerController.View.RemoveFromSuperview();
                _avplayerController.Dispose();
                _avplayerController = null;
            }
        }