internal ImageAnimationController(Image image, ObjectAnimationUsingKeyFrames animation, bool autoStart) { _image = image; _animation = animation; _animation.Completed += AnimationCompleted; _clock = _animation.CreateClock(); _clockController = _clock.Controller; _sourceDescriptor.AddValueChanged(image, ImageSourceChanged); // ReSharper disable once PossibleNullReferenceException _clockController.Pause(); _image.ApplyAnimationClock(Image.SourceProperty, _clock); if (autoStart) _clockController.Resume(); }
private void Reset() { Duration = 0; CurrentTime = 0; _clock = null; _controller = null; IsMediaLoaded = false; IsPlaying = false; IsPaused = false; _timeline.Source = null; }
private void MediaOpened(object sender, RoutedEventArgs e) { if (MediaPlayerElement.Clock != null && MediaPlayerElement.Clock.Controller != null) { _clock = MediaPlayerElement.Clock; _controller = MediaPlayerElement.Clock.Controller; IsMediaLoaded = true; _controller.Stop(); if (_clock.NaturalDuration.HasTimeSpan) { Duration = _clock.NaturalDuration.TimeSpan.TotalMilliseconds/1000; } } else { Reset(); } }