client/src/Iri.Modernisation.Controls/View/VideoViewer/VideoViewer.xaml.cs
changeset 25 a9c815025a1b
parent 24 c031f1132dde
child 26 44a2dc869e28
--- a/client/src/Iri.Modernisation.Controls/View/VideoViewer/VideoViewer.xaml.cs	Wed Dec 16 17:14:38 2009 +0100
+++ b/client/src/Iri.Modernisation.Controls/View/VideoViewer/VideoViewer.xaml.cs	Fri Dec 18 16:45:30 2009 +0100
@@ -41,6 +41,8 @@
 		{
 			// Required to initialize variables
 			InitializeComponent();   /// <summary>
+            VideoScreen.MediaEnded += new RoutedEventHandler(VideoScreen_MediaEnded);
+            VideoScreen.MediaOpened += new RoutedEventHandler(VideoScreen_MediaOpened);
             VideoPositionTimer.Interval = new System.TimeSpan(0, 0, 0, 0, 1000); 
             VideoPositionTimer.Tick += new EventHandler(VideoPositionTimer_Tick);
             Commands.GoToTime.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(GoToTime_Executed);
@@ -48,12 +50,27 @@
             Commands.VideoViewer.Play.Executed +=new EventHandler<SLExtensions.Input.ExecutedEventArgs>(Play_Executed);
 		}
 
-        void GoToTime_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
+        void VideoScreen_MediaOpened(object sender, RoutedEventArgs e)
+        {
+            VideoScreen.Play();
+            VideoPositionTimer.Start();
+            
+        }
+
+        void VideoScreen_MediaEnded(object sender, RoutedEventArgs e)
+        {
+            VideoPositionTimer.Stop();
+        }
+
+        private void GoToTime_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
         {
             if (e.Source == DataContext && e.Source != null)
             {
-                VideoScreen.Pause();
+                
+                VideoPositionTimer.Start();
+               
                VideoScreen.Position = new TimeSpan(((TimeSpan)e.Parameter).Ticks);
+               
               
             }
         }
@@ -77,12 +94,15 @@
         }
         void Pause_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e)
         {
-            VideoScreen.Pause();
-            _isPlayed = false;
-            VideoPositionTimer.Stop();
-            if (VideoPositionTimer.IsEnabled)
+            if(e.Source == DataContext || e.Parameter == DataContext)
             {
-                MessageBox.Show("Click Time IS NOT STOPPED");
+                VideoScreen.Pause();
+                _isPlayed = false;
+                VideoPositionTimer.Stop();
+                if (VideoPositionTimer.IsEnabled)
+                {
+                    MessageBox.Show("Click Time IS NOT STOPPED");
+                }
             }
         }
 
@@ -101,10 +121,7 @@
 			MessageBox.Show(e.ErrorException.ToString());
 		}
 
-		private void VideoScreen_CurrentStateChanged(object sender, System.Windows.RoutedEventArgs e)
-		{
-            
-		}
+		
 
 		private void VideoScreen_MarkerReached(object sender, System.Windows.Media.TimelineMarkerRoutedEventArgs e)
 		{