private void OnUpdatePosition(object sender, object e) { if (VideoPlayer != null) { if (OldPosition != VideoPlayer.Position) { TimePunchIntroPlayerUWPKernel.Get().EventAggregator.PublishMessage(new VideoPositionChangedEvent(VideoPlayer.Position)); OldPosition = VideoPlayer.Position; } } }
public MainPage() { InitializeComponent(); TimePunchIntroPlayerUWPKernel.Get().EventAggregator.Subscribe(this); PositionUpdateTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) }; PositionUpdateTimer.Tick += OnUpdatePosition; }
//Events that get called by the users action #region UserperformedEvents public void Handle(SeekToPlayerPositionEvent message) { try { var timeSpan = TimeSpan.FromMilliseconds(message.Position); VideoPlayer.Position = timeSpan; } catch (Exception e) { TimePunchIntroPlayerUWPKernel.Get().EventAggregator.PublishMessage(new MessageBoxException(e.Message)); } }
private bool disposedValue = false; // To detect redundant calls private void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { TimePunchIntroPlayerUWPKernel.Get().EventAggregator.Unsubscribe(this); PositionUpdateTimer.Stop(); } disposedValue = true; } }
private void VideoPlayer_MediaOpened(object sender, RoutedEventArgs e) { if (!VideoPlayer.NaturalDuration.HasTimeSpan) { return; } if (VideoPlayer.CanSeek) { var timeSpan = TimeSpan.FromMilliseconds(currentPosition); VideoPlayer.Position = timeSpan; VideoPlayer.Play(); } TimePunchIntroPlayerUWPKernel.Get().EventAggregator.PublishMessage(new MediaOpenedEvent()); VideoPositionDefiner.Maximum = VideoPlayer.NaturalDuration.TimeSpan.TotalMilliseconds; }
public AboutViewModel() : base(TimePunchIntroPlayerUWPKernel.Get().EventAggregator) { }
private void VideoPlayer_MediaFailed(object sender, ExceptionRoutedEventArgs e) { TimePunchIntroPlayerUWPKernel.Get().EventAggregator.PublishMessage(new MediaFailedEvent()); }