/// <summary> /// Initializes a new instance of the <see cref="ReactiveCommand"/> class. /// </summary> /// <param name="canExecute">if set to <c>true</c> [can execute].</param> public ReactiveCommand(bool canExecute = false) { _canExecuteSource = new BehaviorSubject <bool>(canExecute); _canExecuteSource .Zip(_canExecuteSource.Skip(1), (x, y) => x != y) .Where(x => x && CanExecuteChanged != null) .Subscribe(_ => CanExecuteChanged(this, EventArgs.Empty)); _executeSource = new Subject <EventPattern <EventCommandEventArgs> >(); }
/// <summary> /// Initializes a new instance of the <see cref="ReactiveCommand"/> class. /// </summary> /// <param name="canExecute">if set to <c>true</c> [can execute].</param> public ReactiveCommand(bool canExecute = false) { _canExecuteSource = new BehaviorSubject<bool>(canExecute); _canExecuteSource .Zip(_canExecuteSource.Skip(1), (x, y) => x != y) .Where(x => x && CanExecuteChanged != null) .Subscribe(_ => CanExecuteChanged(this, EventArgs.Empty)); _executeSource = new Subject<EventPattern<EventCommandEventArgs>>(); }
public void InitPlayer() { TimeControlStatus = new BehaviorSubject <AVPlayerTimeControlStatus>(AVPlayerTimeControlStatus.WaitingToPlayAtSpecifiedRate); ReasonForWaitingToPlay = new BehaviorSubject <string>("AVPlayerWaitingWithNoItemToPlayReason"); ThePlayer?.Dispose(); ThePlayer = new AVPlayer(); ThePlayer.AddObserver(this, "status", NSKeyValueObservingOptions.New, IntPtr.Zero); ThePlayer.AddObserver(this, "error", NSKeyValueObservingOptions.New, IntPtr.Zero); ThePlayer.AddObserver(this, "timeControlStatus", NSKeyValueObservingOptions.New, IntPtr.Zero); ThePlayer.AddObserver(this, "reasonForWaitingToPlay", NSKeyValueObservingOptions.New, IntPtr.Zero); ReasonForWaitingToPlay.Subscribe(status => { Debug.WriteLine("Reason: " + status); }); TimeControlStatus.Subscribe(status => { Debug.WriteLine("TimeControlStatus: " + status); }); PlayerStates = TimeControlStatus.Zip(ReasonForWaitingToPlay, (status, reason) => { switch (status) { case AVPlayerTimeControlStatus.Paused: if (reason == "AVPlayerWaitingWithNoItemToPlayReason") { return(PlayerState.Idle); } if ((ThePlayer.CurrentTime.Value != 0) && (ThePlayer.CurrentTime.Value == ThePlayer.CurrentItem.Duration.Value)) { return(PlayerState.Ended); } return(PlayerState.Paused); case AVPlayerTimeControlStatus.WaitingToPlayAtSpecifiedRate: if (reason == "AVPlayerWaitingWithNoItemToPlayReason") { return(PlayerState.Idle); } return(PlayerState.Buffering); case AVPlayerTimeControlStatus.Playing: return(PlayerState.Playing); default: throw new ArgumentOutOfRangeException(nameof(status), status, null); } }); PlayerStates .Subscribe(change => { Debug.WriteLine("------------------------Status: " + change.ToString()); }); }