Browse Source

添加麦克风设置

tags/对接微服务前^0
张剑 2 years ago
parent
commit
9dda06378c

+ 3
- 3
XHWK.WKTool/App.config View File

5
   </startup>
5
   </startup>
6
   <appSettings>
6
   <appSettings>
7
     <!--0正式 1测试-->
7
     <!--0正式 1测试-->
8
-    <add key="IsDebug" value="1" />
8
+    <add key="IsDebug" value="0" />
9
     <!--参数是否加密 0不加密 1加密-->
9
     <!--参数是否加密 0不加密 1加密-->
10
     <add key="IsParameterEncryption" value="0" />
10
     <add key="IsParameterEncryption" value="0" />
11
     <!--版本号-->
11
     <!--版本号-->
12
-    <add key="VersionCode" value="107" />
13
-    <add key="VersionName" value="3.1.13" />
12
+    <add key="VersionCode" value="108" />
13
+    <add key="VersionName" value="3.1.14" />
14
     <!--皮肤样式 0白 1蓝 2黑色 -->
14
     <!--皮肤样式 0白 1蓝 2黑色 -->
15
     <add key="SkinStyle" value="0" />
15
     <add key="SkinStyle" value="0" />
16
     <!--是否输出视频记录日志:0否-->
16
     <!--是否输出视频记录日志:0否-->

+ 9
- 0
XHWK.WKTool/DeviceWindow.xaml View File

513
                         SelectionChanged="CmbMicrophoneList_SelectionChanged"
513
                         SelectionChanged="CmbMicrophoneList_SelectionChanged"
514
                         Style="{StaticResource stlComboBox}"
514
                         Style="{StaticResource stlComboBox}"
515
                         Text="请选择" />
515
                         Text="请选择" />
516
+
517
+                    <Button
518
+                        x:Name="MicrophoneSetting"
519
+                        Width="60"
520
+                        Margin="20,0,0,0"
521
+                        Background="#3f6fff"
522
+                        Content="设置"
523
+                        FontSize="14"
524
+                        Foreground="White" />
516
                 </StackPanel>
525
                 </StackPanel>
517
 
526
 
518
                 <Grid Grid.Row="1">
527
                 <Grid Grid.Row="1">

+ 86
- 58
XHWK.WKTool/DeviceWindow.xaml.cs View File

8
 using System;
8
 using System;
9
 using System.Collections.Generic;
9
 using System.Collections.Generic;
10
 using System.Data;
10
 using System.Data;
11
+using System.Diagnostics;
11
 using System.Drawing.Imaging;
12
 using System.Drawing.Imaging;
12
 using System.IO;
13
 using System.IO;
13
 using System.Threading;
14
 using System.Threading;
15
+using System.Threading.Tasks;
14
 using System.Windows;
16
 using System.Windows;
15
 using System.Windows.Input;
17
 using System.Windows.Input;
16
 using System.Windows.Media.Imaging;
18
 using System.Windows.Media.Imaging;
32
         {
34
         {
33
             InitializeComponent();
35
             InitializeComponent();
34
 
36
 
37
+            MicrophoneSetting.Click += MicrophoneSetting_Click;
38
+
35
             cameraCheck();
39
             cameraCheck();
36
         }
40
         }
37
 
41
 
42
+        private void MicrophoneSetting_Click(object sender, RoutedEventArgs e)
43
+        {
44
+            Process.Start("mmsys.cpl");
45
+        }
46
+
38
         /// <summary>
47
         /// <summary>
39
         /// 初始化
48
         /// 初始化
40
         /// </summary>
49
         /// </summary>
48
         /// <summary>
57
         /// <summary>
49
         /// 窗体移动
58
         /// 窗体移动
50
         /// </summary>
59
         /// </summary>
51
-        /// <param name="sender"></param>
52
-        /// <param name="e"></param>
60
+        /// <param name="sender">
61
+        /// </param>
62
+        /// <param name="e">
63
+        /// </param>
53
         private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
64
         private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
54
         {
65
         {
55
             DragMove();
66
             DragMove();
58
         /// <summary>
69
         /// <summary>
59
         /// 关闭当前页
70
         /// 关闭当前页
60
         /// </summary>
71
         /// </summary>
61
-        /// <param name="sender"></param>
62
-        /// <param name="e"></param>
72
+        /// <param name="sender">
73
+        /// </param>
74
+        /// <param name="e">
75
+        /// </param>
63
         private void BtnDown_Click(object sender, RoutedEventArgs e)
76
         private void BtnDown_Click(object sender, RoutedEventArgs e)
64
         {
77
         {
65
             imgPlayer.Visibility = Visibility.Hidden;
78
             imgPlayer.Visibility = Visibility.Hidden;
98
         /// <summary>
111
         /// <summary>
99
         /// 检测
112
         /// 检测
100
         /// </summary>
113
         /// </summary>
101
-        /// <param name="sender"></param>
102
-        /// <param name="e"></param>
114
+        /// <param name="sender">
115
+        /// </param>
116
+        /// <param name="e">
117
+        /// </param>
103
         private void checkCamera()
118
         private void checkCamera()
104
         {
119
         {
105
             try
120
             try
159
         /// <summary>
174
         /// <summary>
160
         /// 停止
175
         /// 停止
161
         /// </summary>
176
         /// </summary>
162
-        /// <param name="sender"></param>
163
-        /// <param name="e"></param>
177
+        /// <param name="sender">
178
+        /// </param>
179
+        /// <param name="e">
180
+        /// </param>
164
         private void BtnCameraStop_Click(object sender, RoutedEventArgs e)
181
         private void BtnCameraStop_Click(object sender, RoutedEventArgs e)
165
         {
182
         {
166
             if (Camera != null)
183
             if (Camera != null)
176
         /// <summary>
193
         /// <summary>
177
         /// 扬声器
194
         /// 扬声器
178
         /// </summary>
195
         /// </summary>
179
-        /// <param name="sender"></param>
180
-        /// <param name="e"></param>
196
+        /// <param name="sender">
197
+        /// </param>
198
+        /// <param name="e">
199
+        /// </param>
181
         private void Speaker_Check()
200
         private void Speaker_Check()
182
         {
201
         {
183
             closeCamera();
202
             closeCamera();
189
         /// <summary>
208
         /// <summary>
190
         /// 检测扬声器
209
         /// 检测扬声器
191
         /// </summary>
210
         /// </summary>
192
-        /// <param name="sender"></param>
193
-        /// <param name="e"></param>
211
+        /// <param name="sender">
212
+        /// </param>
213
+        /// <param name="e">
214
+        /// </param>
194
         private void BtnSpeakerDetection_Click(object sender, RoutedEventArgs e)
215
         private void BtnSpeakerDetection_Click(object sender, RoutedEventArgs e)
195
         {
216
         {
196
             Console.WriteLine("播放");
217
             Console.WriteLine("播放");
205
         /// <summary>
226
         /// <summary>
206
         /// 音频播放 同步进度条和视频进度
227
         /// 音频播放 同步进度条和视频进度
207
         /// </summary>
228
         /// </summary>
208
-        /// <param name="sender"></param>
209
-        /// <param name="e"></param>
229
+        /// <param name="sender">
230
+        /// </param>
231
+        /// <param name="e">
232
+        /// </param>
210
         private void MediaAudio_MediaOpened(object sender, RoutedEventArgs e)
233
         private void MediaAudio_MediaOpened(object sender, RoutedEventArgs e)
211
         {
234
         {
212
             Console.WriteLine("播放中。。。");
235
             Console.WriteLine("播放中。。。");
227
         /// <summary>
250
         /// <summary>
228
         /// 麦克风
251
         /// 麦克风
229
         /// </summary>
252
         /// </summary>
230
-        /// <param name="sender"></param>
231
-        /// <param name="e"></param>
232
-        private void Microphone_Check()
253
+        /// <param name="sender">
254
+        /// </param>
255
+        /// <param name="e">
256
+        /// </param>
257
+        private async void Microphone_Check()
233
         {
258
         {
234
             MediaAudio.Stop();
259
             MediaAudio.Stop();
235
             ImgAcousticWave.Visibility = Visibility.Collapsed;
260
             ImgAcousticWave.Visibility = Visibility.Collapsed;
236
             HidePage();
261
             HidePage();
237
             GridMicrophone.Visibility = Visibility.Visible;
262
             GridMicrophone.Visibility = Visibility.Visible;
238
-
239
-            ThreadPool.QueueUserWorkItem(s =>
263
+            DataTable data = new DataTable();
264
+            data.Columns.Add("Value");
265
+            data.Columns.Add("Key");
266
+            await Task.Run(() =>
240
             {
267
             {
241
-                DataTable data = new DataTable();
242
-                data.Columns.Add("Value");
243
-                data.Columns.Add("Key");
244
                 for (int n = 0; n < WaveIn.DeviceCount; n++)
268
                 for (int n = 0; n < WaveIn.DeviceCount; n++)
245
                 {
269
                 {
246
                     var caps = WaveIn.GetCapabilities(n);
270
                     var caps = WaveIn.GetCapabilities(n);
252
                     data.Rows[n]["Value"] = caps.ProductName;
276
                     data.Rows[n]["Value"] = caps.ProductName;
253
                     data.Rows[n]["Key"] = n + "";
277
                     data.Rows[n]["Key"] = n + "";
254
                 }
278
                 }
255
-                Dispatcher.Invoke(() =>
256
-                {
257
-                    CmbMicrophoneList.ItemsSource = data.DefaultView;
258
-                    if (WaveIn.DeviceCount > 0)
259
-                    {
260
-                        CmbMicrophoneList.SelectedIndex = 0;
261
-                    }
262
-                });
263
             });
279
             });
280
+
281
+            CmbMicrophoneList.ItemsSource = data.DefaultView;
282
+            if (WaveIn.DeviceCount > 0)
283
+            {
284
+                CmbMicrophoneList.SelectedIndex = 0;
285
+            }
264
         }
286
         }
265
 
287
 
266
         private WaveInEvent waveIn = null;
288
         private WaveInEvent waveIn = null;
275
 
297
 
276
             if (CmbMicrophoneList.SelectedIndex >= 0)
298
             if (CmbMicrophoneList.SelectedIndex >= 0)
277
             {
299
             {
278
-                waveIn = new WaveInEvent();
279
-                waveIn.DeviceNumber = CmbMicrophoneList.SelectedIndex;
280
-
281
-                //开始录音,写数据
282
-                waveIn.DataAvailable += (o, e1) =>
300
+                var select_index = CmbMicrophoneList.SelectedIndex;
301
+                ThreadPool.QueueUserWorkItem((item) =>
283
                 {
302
                 {
284
-                    byte[] buf = e1.Buffer;
285
-                    float maxNumber = 0;
286
-                    for (int index = 0; index < buf.Length; index += 2)
287
-                    {
288
-                        short sample = (short)((buf[index + 1] << 8) | buf[index + 0]);
289
-                        float sample32 = sample / 32768f;
290
-                        sample32 = Math.Abs(sample32);
303
+                    waveIn = new WaveInEvent();
304
+                    waveIn.DeviceNumber = select_index;
291
 
305
 
292
-                        if (sample32 > maxNumber)
306
+                    //开始录音,写数据
307
+                    waveIn.DataAvailable += (o, e1) =>
308
+                    {
309
+                        byte[] buf = e1.Buffer;
310
+                        float maxNumber = 0;
311
+                        for (int index = 0; index < buf.Length; index += 2)
293
                         {
312
                         {
294
-                            maxNumber = sample32;
313
+                            short sample = (short)((buf[index + 1] << 8) | buf[index + 0]);
314
+                            float sample32 = sample / 32768f;
315
+                            sample32 = Math.Abs(sample32);
316
+
317
+                            if (sample32 > maxNumber)
318
+                            {
319
+                                maxNumber = sample32;
320
+                            }
295
                         }
321
                         }
296
-                    }
297
 
322
 
298
-                    Dispatcher.Invoke(() =>
299
-                    {
300
-                        volumeProgressBar.Value = maxNumber * 100;
301
-                    });
302
-                };
323
+                        Dispatcher.Invoke(() =>
324
+                        {
325
+                            volumeProgressBar.Value = maxNumber * 100;
326
+                        });
327
+                    };
303
 
328
 
304
-                //结束录音
305
-                waveIn.RecordingStopped += (s, a) =>
306
-                {
307
-                    waveIn.Dispose();
308
-                };
329
+                    //结束录音
330
+                    waveIn.RecordingStopped += (s, a) =>
331
+                    {
332
+                        waveIn.Dispose();
333
+                    };
309
 
334
 
310
-                waveIn.StartRecording();
335
+                    waveIn.StartRecording();
336
+                });
311
             }
337
             }
312
         }
338
         }
313
 
339
 
422
         /// <summary>
448
         /// <summary>
423
         /// 重新
449
         /// 重新
424
         /// </summary>
450
         /// </summary>
425
-        /// <param name="sender"></param>
426
-        /// <param name="e"></param>
451
+        /// <param name="sender">
452
+        /// </param>
453
+        /// <param name="e">
454
+        /// </param>
427
         private void BtnDetection_Click(object sender, RoutedEventArgs e)
455
         private void BtnDetection_Click(object sender, RoutedEventArgs e)
428
         {
456
         {
429
             cameraCheck();
457
             cameraCheck();

+ 1
- 0
XHWK.WKTool/MainWindow.xaml.cs View File

3223
                     );
3223
                     );
3224
 
3224
 
3225
                     waveIn = new WaveInEvent();
3225
                     waveIn = new WaveInEvent();
3226
+
3226
                     waveIn_runing = true;
3227
                     waveIn_runing = true;
3227
                     writer = new WaveFileWriter(TempAudioPathName, waveIn.WaveFormat);
3228
                     writer = new WaveFileWriter(TempAudioPathName, waveIn.WaveFormat);
3228
                     //开始录音,写数据
3229
                     //开始录音,写数据

+ 1
- 1
星火微课/星火微课-正式.iss View File

3
 
3
 
4
 #define MyAppName "星火微课"  
4
 #define MyAppName "星火微课"  
5
 #define MyAppDir "xhwk"
5
 #define MyAppDir "xhwk"
6
-#define MyAppVersion "3.1.13"
6
+#define MyAppVersion "3.1.14"
7
 #define MyAppPublisher "河南星火燎原软件科技有限公司"
7
 #define MyAppPublisher "河南星火燎原软件科技有限公司"
8
 #define MyAppURL "http://www.xhkjedu.com/"
8
 #define MyAppURL "http://www.xhkjedu.com/"
9
 #define MySourcePath "D:\Project\CSharp\xhwkclient\XHWK.WKTool\bin\x86\Debug\"
9
 #define MySourcePath "D:\Project\CSharp\xhwkclient\XHWK.WKTool\bin\x86\Debug\"

+ 1
- 1
星火微课/星火微课-测试.iss View File

3
 
3
 
4
 #define MyAppName "星火微课"  
4
 #define MyAppName "星火微课"  
5
 #define MyAppDir "xhwk"
5
 #define MyAppDir "xhwk"
6
-#define MyAppVersion "3.1.13"
6
+#define MyAppVersion "3.1.14"
7
 #define MyAppPublisher "河南星火燎原软件科技有限公司"
7
 #define MyAppPublisher "河南星火燎原软件科技有限公司"
8
 #define MyAppURL "http://www.xhkjedu.com/"
8
 #define MyAppURL "http://www.xhkjedu.com/"
9
 #define MySourcePath "D:\Project\CSharp\xhwkclient\XHWK.WKTool\bin\x86\Debug\"
9
 #define MySourcePath "D:\Project\CSharp\xhwkclient\XHWK.WKTool\bin\x86\Debug\"

Loading…
Cancel
Save