Exemplo n.º 1
0
        public override void ViewDidUnload()
        {
            base.ViewDidUnload();

            _timer?.SetEventHandler(null);
            _timer?.Cancel();

            /*
             * If the timer is suspended, calling cancel without resuming
             * triggers a crash. This is documented here https://forums.developer.apple.com/thread/15902
             */
            if (!timerRunning ?? false)
            {
                _timer?.Resume();
            }

            _timer?.Dispose();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            nonObservablePropertiesUpdateTimer.SetEventHandler(UpdateNonObservableProperties);
            nonObservablePropertiesUpdateTimer.SetTimer(DispatchTime.Now, 1000000, 0);
            nonObservablePropertiesUpdateTimer.Resume();

            var options = NSKeyValueObservingOptions.Initial | NSKeyValueObservingOptions.New;

            rateToken = Player.AddObserver("rate", options, RateChanged);
            timeControlStatusToken      = Player.AddObserver("timeControlStatus", options, timeControlStatusChanged);
            reasonForWaitingToPlayToken = Player.AddObserver("reasonForWaitingToPlay", options, ReasonForWaitingToPlayChanged);
            playbackLikelyToKeepUpToken = Player.AddObserver("currentItem.playbackLikelyToKeepUp", options, PlaybackLikelyToKeepUpChanged);
            loadedTimeRangesToken       = Player.AddObserver("currentItem.loadedTimeRanges", options, LoadedTimeRangesChanged);
            playbackBufferFullToken     = Player.AddObserver("currentItem.playbackBufferFull", options, PlaybackBufferFullChanged);
            playbackBufferEmptyToken    = Player.AddObserver("currentItem.playbackBufferEmpty", options, PlaybackBufferEmptyChanged);
        }