public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { AppUIState state = (AppUIState)value; return(state == AppUIState.VideoPlaying || state == AppUIState.VideoFastForwarding || state == AppUIState.StreamPlaying); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { AppUIState state = (AppUIState)value; return(state == AppUIState.VideoLoaded || state == AppUIState.VideoPaused || state == AppUIState.VideoPlaying); }
private void ResetMediaState(AppUIState newState, VideoCapture newVideoSource = null, Mat newImage = null) { AppUIState oldState = viewModel.CurrentUIState; viewModel.CurrentUIState = newState; bool restartPlayback = viewModel.FrameTimer.IsEnabled && newVideoSource != null; viewModel.FrameTimer.Stop(); viewModel.VideoSource?.Dispose(); viewModel.VideoSource = newVideoSource; viewModel.LoadedImage?.Dispose(); viewModel.LoadedImage = newImage; imgDisplay.Image?.Dispose(); imgDisplay.Image = newImage; if (restartPlayback) { if (newState == AppUIState.StreamLoaded) { viewModel.CurrentUIState = AppUIState.StreamPlaying; } else if (oldState == AppUIState.VideoFastForwarding) { viewModel.CurrentUIState = AppUIState.VideoFastForwarding; } else { viewModel.CurrentUIState = AppUIState.VideoPlaying; } if (newState == AppUIState.StreamLoaded) { viewModel.FrameTimer.Interval = TimeSpan.FromMilliseconds(30.0); } else { viewModel.FrameTimer.Interval = TimeSpan.FromMilliseconds(((viewModel.CurrentUIState == AppUIState.VideoFastForwarding) ? 500.0 : 1000.0) / newVideoSource.GetCaptureProperty(CapProp.Fps)); } viewModel.FrameTimer.Start(); } }