|
1 using System; |
|
2 using System.IO; |
|
3 using System.Net; |
|
4 using System.Windows; |
|
5 using System.Windows.Controls; |
|
6 using System.Windows.Data; |
|
7 using System.Windows.Media; |
|
8 using System.Windows.Media.Imaging; |
|
9 using System.Windows.Media.Animation; |
|
10 using System.Windows.Navigation; |
|
11 using System.ComponentModel; |
|
12 |
|
13 namespace Control.Player.Test |
|
14 { |
|
15 public partial class UserControlPlayer |
|
16 { |
|
17 |
|
18 private bool play; |
|
19 |
|
20 public UserControlPlayer() |
|
21 { |
|
22 this.InitializeComponent(); |
|
23 |
|
24 initPlayer(); |
|
25 } |
|
26 |
|
27 void initPlayer() |
|
28 { |
|
29 //init player |
|
30 play = false; |
|
31 MediaElementVideo.Source = new Uri("Resources\\Lake.wmv", UriKind.Relative); |
|
32 MediaElementVideo.LoadedBehavior = MediaState.Manual; |
|
33 } |
|
34 |
|
35 private void ButtonPlayPause_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
|
36 { |
|
37 if (!play)//Play |
|
38 { |
|
39 play = true; |
|
40 try |
|
41 { |
|
42 MediaElementVideo.Play(); |
|
43 } |
|
44 catch (Exception ex) { } |
|
45 } |
|
46 else//Pause |
|
47 { |
|
48 play = false; |
|
49 try |
|
50 { |
|
51 MediaElementVideo.Pause(); |
|
52 } |
|
53 catch (Exception exx ) { } |
|
54 } |
|
55 |
|
56 } |
|
57 |
|
58 private void ButtonPlayPause_Click(object sender, RoutedEventArgs e) |
|
59 { |
|
60 if (!play)//Play |
|
61 { |
|
62 play = true; |
|
63 try |
|
64 { |
|
65 MediaElementVideo.Play(); |
|
66 } |
|
67 catch (Exception ex ) { } |
|
68 |
|
69 } |
|
70 else//Pause |
|
71 { |
|
72 play = false; |
|
73 try |
|
74 { |
|
75 MediaElementVideo.Pause(); |
|
76 } |
|
77 catch (Exception exx ) { } |
|
78 //ButtonPlayPause.Background = FindResource("[Skin_1]_Play_button_xaml") as Brush; |
|
79 } |
|
80 } |
|
81 |
|
82 private void ButtonFastForward_Click(object sender, RoutedEventArgs e) |
|
83 { |
|
84 if(MediaElementVideo.SpeedRatio <= 3) |
|
85 MediaElementVideo.SpeedRatio += 1; |
|
86 } |
|
87 |
|
88 private void ButtonFastForward_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
|
89 { |
|
90 if (MediaElementVideo.SpeedRatio <= 3) |
|
91 MediaElementVideo.SpeedRatio += 1; |
|
92 } |
|
93 |
|
94 private void ButtonRewind_Click(object sender, RoutedEventArgs e) |
|
95 { |
|
96 //TimeSpan ts = new TimeSpan(0, 0, 0, 0); |
|
97 if (MediaElementVideo.SpeedRatio > 1) |
|
98 { |
|
99 MediaElementVideo.SpeedRatio -= 1; |
|
100 } |
|
101 else |
|
102 { |
|
103 MediaElementVideo.Position = MediaElementVideo.Position.Add(new TimeSpan(0, 0, 0, -5)); |
|
104 } |
|
105 } |
|
106 |
|
107 private void ButtonRewind_ContactDown(object sender, Microsoft.Surface.Presentation.ContactEventArgs e) |
|
108 { |
|
109 |
|
110 //TimeSpan ts = new TimeSpan(0, 0, 0,0); |
|
111 if (MediaElementVideo.SpeedRatio > 1) |
|
112 { |
|
113 MediaElementVideo.SpeedRatio -= 1; |
|
114 } |
|
115 else |
|
116 { |
|
117 MediaElementVideo.Position = MediaElementVideo.Position.Add(new TimeSpan(0, 0, 0, -5)); |
|
118 } |
|
119 } |
|
120 } |
|
121 } |