equal
deleted
inserted
replaced
12 namespace Iri.Modernisation.Controls.View |
12 namespace Iri.Modernisation.Controls.View |
13 { |
13 { |
14 public partial class VideoViewer : UserControl |
14 public partial class VideoViewer : UserControl |
15 { |
15 { |
16 |
16 |
17 |
|
18 |
17 |
|
18 |
|
19 public System.Windows.Threading.DispatcherTimer VideoPositionTimer = new System.Windows.Threading.DispatcherTimer(); |
|
20 |
19 public String MediaSource |
21 public String MediaSource |
20 { |
22 { |
21 get |
23 get |
22 { |
24 { |
23 return (String)GetValue(SourceProperty); |
25 return (String)GetValue(SourceProperty); |
36 |
38 |
37 private bool _isPlayed = false; |
39 private bool _isPlayed = false; |
38 public VideoViewer() |
40 public VideoViewer() |
39 { |
41 { |
40 // Required to initialize variables |
42 // Required to initialize variables |
41 InitializeComponent(); |
43 InitializeComponent(); /// <summary> |
42 Commands.VideoPositionTimer.Tick += new EventHandler(VideoPositionTimer_Tick); |
44 VideoPositionTimer.Interval = new System.TimeSpan(0, 0, 0, 0, 1000); |
|
45 VideoPositionTimer.Tick += new EventHandler(VideoPositionTimer_Tick); |
43 Commands.GoToTime.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(GoToTime_Executed); |
46 Commands.GoToTime.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(GoToTime_Executed); |
44 Commands.VideoViewer.Pause.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(Pause_Executed); |
47 Commands.VideoViewer.Pause.Executed += new EventHandler<SLExtensions.Input.ExecutedEventArgs>(Pause_Executed); |
45 Commands.VideoViewer.Play.Executed +=new EventHandler<SLExtensions.Input.ExecutedEventArgs>(Play_Executed); |
48 Commands.VideoViewer.Play.Executed +=new EventHandler<SLExtensions.Input.ExecutedEventArgs>(Play_Executed); |
46 } |
49 } |
47 |
50 |
50 VideoScreen.Position = TimeSpan.FromMilliseconds((double)e.Parameter); |
53 VideoScreen.Position = TimeSpan.FromMilliseconds((double)e.Parameter); |
51 } |
54 } |
52 |
55 |
53 void VideoPositionTimer_Tick(object sender, EventArgs e) |
56 void VideoPositionTimer_Tick(object sender, EventArgs e) |
54 { |
57 { |
55 if(_isPlayed) |
58 if (_isPlayed) |
56 Commands.VideoViewer.SendPosition.Execute(VideoScreen.Position); |
59 { |
|
60 if(Tick!=null) |
|
61 { |
|
62 Tick(this, new VideoViewerEventArgs(VideoScreen.Position)); |
|
63 } |
|
64 ((VideoViewerVM)DataContext).LaunchTick(VideoScreen.Position); |
|
65 } |
|
66 //Commands.VideoViewer.SendPosition.Execute(VideoScreen.Position); |
57 } |
67 } |
58 public void ChangePosition(TimeSpan TS) |
68 public void ChangePosition(TimeSpan TS) |
59 { |
69 { |
60 VideoScreen.Position = TS; |
70 VideoScreen.Position = TS; |
61 |
71 |
62 } |
72 } |
63 void Pause_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
73 void Pause_Executed(object sender, SLExtensions.Input.ExecutedEventArgs e) |
64 { |
74 { |
65 VideoScreen.Pause(); |
75 VideoScreen.Pause(); |
66 _isPlayed = false; |
76 _isPlayed = false; |
67 Commands.VideoPositionTimer.Stop(); |
77 VideoPositionTimer.Stop(); |
68 if (Commands.VideoPositionTimer.IsEnabled) |
78 if (VideoPositionTimer.IsEnabled) |
69 { |
79 { |
70 MessageBox.Show("Click Time IS NOT STOPPED"); |
80 MessageBox.Show("Click Time IS NOT STOPPED"); |
71 } |
81 } |
72 } |
82 } |
73 |
83 |
75 { |
85 { |
76 if (e.Parameter == DataContext || e.Parameter == null) |
86 if (e.Parameter == DataContext || e.Parameter == null) |
77 { |
87 { |
78 _isPlayed = true; |
88 _isPlayed = true; |
79 VideoScreen.Play(); |
89 VideoScreen.Play(); |
80 Commands.VideoPositionTimer.Start(); |
90 VideoPositionTimer.Start(); |
81 } |
91 } |
82 } |
92 } |
83 |
93 |
84 private void VideoScreen_MediaFailed(object sender, System.Windows.ExceptionRoutedEventArgs e) |
94 private void VideoScreen_MediaFailed(object sender, System.Windows.ExceptionRoutedEventArgs e) |
85 { |
95 { |
93 |
103 |
94 private void VideoScreen_MarkerReached(object sender, System.Windows.Media.TimelineMarkerRoutedEventArgs e) |
104 private void VideoScreen_MarkerReached(object sender, System.Windows.Media.TimelineMarkerRoutedEventArgs e) |
95 { |
105 { |
96 MessageBox.Show("toto"); |
106 MessageBox.Show("toto"); |
97 } |
107 } |
|
108 public event EventHandler<VideoViewerEventArgs> Tick; |
98 } |
109 } |
|
110 public class VideoViewerEventArgs: EventArgs |
|
111 { |
|
112 |
|
113 public TimeSpan Position { get; set; } |
|
114 public VideoViewerEventArgs(TimeSpan pos) |
|
115 { |
|
116 Position = pos; |
|
117 } |
|
118 } |
99 } |
119 } |