Browse Source

设备检测 麦克风检测重做

tags/3.0.0
张剑 3 years ago
parent
commit
267ec8caa7

+ 6
- 6
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="89" />
13
-    <add key="VersionName" value="2.6.9" />
12
+    <add key="VersionCode" value="90" />
13
+    <add key="VersionName" value="2.7.0" />
14
     <!--皮肤样式 0白 1蓝 2黑色 -->
14
     <!--皮肤样式 0白 1蓝 2黑色 -->
15
     <add key="SkinStyle" value="0" />
15
     <add key="SkinStyle" value="0" />
16
     <!--是否输出视频记录日志:0否-->
16
     <!--是否输出视频记录日志:0否-->
34
     <!--是否为校外 1是 -->
34
     <!--是否为校外 1是 -->
35
     <add key="IsOutsideSchool" value="1" />
35
     <add key="IsOutsideSchool" value="1" />
36
     <!--API请求地址-->
36
     <!--API请求地址-->
37
-    <add key="APIRequestAddress" value="https://zwwx.zzfls.com.cn:9001" />
37
+    <add key="APIRequestAddress" value="https://schoolapi.xhkjedu.com" />
38
     <!--文件平台请求地址-->
38
     <!--文件平台请求地址-->
39
-    <add key="FileRequestAddress" value="https://zwwx.zzfls.com.cn:9002" />
39
+    <add key="FileRequestAddress" value="https://schoolfile.xhkjedu.com" />
40
     <!--展示文件服务器请求地址-->
40
     <!--展示文件服务器请求地址-->
41
-    <add key="SchoolfileRequestAddress" value="https://zwwx.zzfls.com.cn:9003" />
41
+    <add key="SchoolfileRequestAddress" value="https://schoolstatic.xhkjedu.com" />
42
     <!--认证请求地址-->
42
     <!--认证请求地址-->
43
     <add key="CertapiRequestAddress" value="https://scapi.xhkjedu.com" />
43
     <add key="CertapiRequestAddress" value="https://scapi.xhkjedu.com" />
44
     <!--摄像头位置 1.右上 2.左上 3.右下 4.左下-->
44
     <!--摄像头位置 1.右上 2.左上 3.右下 4.左下-->

+ 1
- 6
XHWK.WKTool/App.xaml.cs View File

321
         /// </summary>
321
         /// </summary>
322
         public static VideoClipWindow W_VideoClipWindow = null;
322
         public static VideoClipWindow W_VideoClipWindow = null;
323
 
323
 
324
-        /// <summary>
325
-        /// 设备检测
326
-        /// </summary>
327
-        public static DeviceWindow W_DeviceWindow = null;
328
-
329
         #endregion 页面
324
         #endregion 页面
330
 
325
 
331
         #endregion 全局变量
326
         #endregion 全局变量
327
+
332
         public APP()
328
         public APP()
333
         {
329
         {
334
             Console.WriteLine("初始化APP");
330
             Console.WriteLine("初始化APP");
642
 
638
 
643
         #endregion 服务地址数据
639
         #endregion 服务地址数据
644
 
640
 
645
- 
646
         #region 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
641
         #region 内存处理 -创建人:赵耀 -创建时间:2020年8月12日
647
 
642
 
648
         /// <summary>
643
         /// <summary>

+ 14
- 53
XHWK.WKTool/DeviceWindow.xaml View File

6
     xmlns:gif="http://wpfanimatedgif.codeplex.com"
6
     xmlns:gif="http://wpfanimatedgif.codeplex.com"
7
     xmlns:local="clr-namespace:XHWK.WKTool"
7
     xmlns:local="clr-namespace:XHWK.WKTool"
8
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9
+    xmlns:view="clr-namespace:XHWK.WKTool.View"
9
     Title="设备检测"
10
     Title="设备检测"
10
     Width="569"
11
     Width="569"
11
     Height="367"
12
     Height="367"
195
                                     FontSize="16"
196
                                     FontSize="16"
196
                                     Text="摄像头" />
197
                                     Text="摄像头" />
197
                             </StackPanel>
198
                             </StackPanel>
198
-
199
-
200
                         </Button>
199
                         </Button>
201
                         <Button
200
                         <Button
202
                             x:Name="BtnSpeaker"
201
                             x:Name="BtnSpeaker"
419
                     </StackPanel>
418
                     </StackPanel>
420
                 </Grid>
419
                 </Grid>
421
                 <Grid Grid.Row="1">
420
                 <Grid Grid.Row="1">
422
-                    <!--<MediaElement Source="/SkinImages/Other/Dev_AcousticWave2.gif" OpacityMask="#FF000000" HorizontalAlignment="Left" Margin="10,0,0,0" LoadedBehavior="{Binding ElementName=MediaAudio,Path=LoadedBehavior}" />-->
421
+
423
                     <Grid
422
                     <Grid
424
                         Width="300"
423
                         Width="300"
425
                         Height="100"
424
                         Height="100"
511
                         DisplayMemberPath="Value"
510
                         DisplayMemberPath="Value"
512
                         FontSize="14"
511
                         FontSize="14"
513
                         SelectedValuePath="Key"
512
                         SelectedValuePath="Key"
513
+                        SelectionChanged="CmbMicrophoneList_SelectionChanged"
514
                         Style="{StaticResource stlComboBox}"
514
                         Style="{StaticResource stlComboBox}"
515
                         Text="请选择" />
515
                         Text="请选择" />
516
                 </StackPanel>
516
                 </StackPanel>
520
                         <RowDefinition Height="Auto" />
520
                         <RowDefinition Height="Auto" />
521
                         <RowDefinition Height="64" />
521
                         <RowDefinition Height="64" />
522
                     </Grid.RowDefinitions>
522
                     </Grid.RowDefinitions>
523
-                    <Grid
523
+                    <view:ZClippingBorder
524
                         x:Name="GridMicImg"
524
                         x:Name="GridMicImg"
525
                         Width="300"
525
                         Width="300"
526
-                        Height="100"
526
+                        Height="20"
527
                         Margin="30,0,0,0"
527
                         Margin="30,0,0,0"
528
                         HorizontalAlignment="Left"
528
                         HorizontalAlignment="Left"
529
                         VerticalAlignment="Top"
529
                         VerticalAlignment="Top"
530
                         Background="#FFF1F2F8"
530
                         Background="#FFF1F2F8"
531
+                        ClipToBounds="True"
532
+                        CornerRadius="10"
531
                         Visibility="Visible">
533
                         Visibility="Visible">
532
-                        <Image
533
-                            x:Name="ImgMicAcousticWave"
534
-                            gif:ImageBehavior.AnimatedSource="/SkinImages/Other/Dev_AcousticWave2.gif"
535
-                            gif:ImageBehavior.AutoStart="True"
536
-                            gif:ImageBehavior.RepeatBehavior="Forever"
537
-                            Visibility="Hidden" />
538
-                    </Grid>
539
-
540
-                    <StackPanel
541
-                        Grid.Row="1"
542
-                        Margin="30,0,0,0"
543
-                        HorizontalAlignment="Left"
544
-                        VerticalAlignment="Center"
545
-                        Orientation="Horizontal">
546
-                        <Button
547
-                            x:Name="BtnMicrophoneDetection"
548
-                            Width="100"
549
-                            Height="30"
550
-                            Margin="0"
551
-                            HorizontalAlignment="Stretch"
552
-                            VerticalAlignment="Stretch"
553
-                            Background="#3f6fff"
554
-                            Click="BtnMicrophoneDetection_Click"
555
-                            Content="回响测试"
556
-                            Cursor="Hand"
557
-                            FontSize="15"
558
-                            Foreground="White"
559
-                            IsDefault="True" />
560
-
561
-                        <TextBlock
562
-                            x:Name="TbxMicrophoneDetection"
563
-                            Margin="10,0,0,0"
564
-                            HorizontalAlignment="Left"
565
-                            VerticalAlignment="Center"
566
-                            FontSize="16"
567
-                            Foreground="#FF000000"
568
-                            Text="待检测" />
569
-                        <MediaElement
570
-                            x:Name="MediaAudioMicPlay"
571
-                            Width="0"
572
-                            LoadedBehavior="Manual"
573
-                            MediaEnded="MediaAudioMicPlay_MediaEnded"
574
-                            Stretch="Fill"
575
-                            Visibility="Hidden"
576
-                            Volume="1" />
577
-                    </StackPanel>
534
+                        <ProgressBar
535
+                            x:Name="volumeProgressBar"
536
+                            BorderThickness="0"
537
+                            Maximum="100" />
538
+                    </view:ZClippingBorder>
578
                 </Grid>
539
                 </Grid>
579
 
540
 
580
                 <Grid Grid.Row="2">
541
                 <Grid Grid.Row="2">
592
                             VerticalAlignment="Center"
553
                             VerticalAlignment="Center"
593
                             Background="#3f6fff"
554
                             Background="#3f6fff"
594
                             Click="btn_microphone_good_Click"
555
                             Click="btn_microphone_good_Click"
595
-                            Content="可以见"
556
+                            Content="可以见"
596
                             Cursor="Hand"
557
                             Cursor="Hand"
597
                             FontSize="15"
558
                             FontSize="15"
598
                             Foreground="White"
559
                             Foreground="White"
606
                             VerticalAlignment="Center"
567
                             VerticalAlignment="Center"
607
                             Background="#F1F2F3"
568
                             Background="#F1F2F3"
608
                             Click="btn_microphone_bad_Click"
569
                             Click="btn_microphone_bad_Click"
609
-                            Content="不见"
570
+                            Content="不见"
610
                             Cursor="Hand"
571
                             Cursor="Hand"
611
                             FontSize="15"
572
                             FontSize="15"
612
                             Foreground="#333333"
573
                             Foreground="#333333"

+ 64
- 98
XHWK.WKTool/DeviceWindow.xaml.cs View File

3
 
3
 
4
 using Common.system;
4
 using Common.system;
5
 
5
 
6
-using NAudio.CoreAudioApi;
6
+using NAudio.Wave;
7
 
7
 
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.Drawing.Imaging;
11
 using System.Drawing.Imaging;
12
 using System.IO;
12
 using System.IO;
13
-using System.Linq;
14
 using System.Threading;
13
 using System.Threading;
15
 using System.Windows;
14
 using System.Windows;
16
 using System.Windows.Input;
15
 using System.Windows.Input;
44
             TxbCamera.Text = "";
43
             TxbCamera.Text = "";
45
             TxbSpeaker.Text = "";
44
             TxbSpeaker.Text = "";
46
             TxbMicrophone.Text = "";
45
             TxbMicrophone.Text = "";
47
-       
48
         }
46
         }
49
 
47
 
50
         /// <summary>
48
         /// <summary>
65
         private void BtnDown_Click(object sender, RoutedEventArgs e)
63
         private void BtnDown_Click(object sender, RoutedEventArgs e)
66
         {
64
         {
67
             imgPlayer.Visibility = Visibility.Hidden;
65
             imgPlayer.Visibility = Visibility.Hidden;
66
+            closeCamera();
67
+            if (waveIn != null)
68
+            {
69
+                waveIn.StopRecording();
70
+            }
68
 
71
 
69
             Close();
72
             Close();
70
         }
73
         }
233
             HidePage();
236
             HidePage();
234
             GridMicrophone.Visibility = Visibility.Visible;
237
             GridMicrophone.Visibility = Visibility.Visible;
235
 
238
 
236
-            ImgMicAcousticWave.Visibility = Visibility.Hidden;
237
-            string AudioPath = FileToolsCommon.GetFileAbsolutePath("/temp/audio/");
238
-            FileToolsCommon.DeleteDirectory(AudioPath);
239
-
240
-            DataTable data = new DataTable();
241
-            List<string> MicrophoneList = APP.FFmpeg.GetMicrophoneNameList();
242
-            if (MicrophoneList.Count > 0)
239
+            ThreadPool.QueueUserWorkItem(s =>
243
             {
240
             {
241
+                DataTable data = new DataTable();
244
                 data.Columns.Add("Value");
242
                 data.Columns.Add("Value");
245
                 data.Columns.Add("Key");
243
                 data.Columns.Add("Key");
246
-                for (int i = 0; i < MicrophoneList.Count; i++)
244
+                for (int n = 0; n < WaveIn.DeviceCount; n++)
247
                 {
245
                 {
246
+                    var caps = WaveIn.GetCapabilities(n);
247
+
248
                     //创建一行
248
                     //创建一行
249
                     DataRow row = data.NewRow();
249
                     DataRow row = data.NewRow();
250
                     //将此行添加到table中
250
                     //将此行添加到table中
251
                     data.Rows.Add(row);
251
                     data.Rows.Add(row);
252
-                    data.Rows[i]["Value"] = MicrophoneList[i];
253
-                    data.Rows[i]["Key"] = i.ToString();
252
+                    data.Rows[n]["Value"] = caps.ProductName;
253
+                    data.Rows[n]["Key"] = n + "";
254
                 }
254
                 }
255
-                CmbMicrophoneList.ItemsSource = data.DefaultView;
256
-                int CameraIndex = 0;
257
-                if (MicrophoneList.Exists(x => x == APP.MicrophoneName))
255
+                Dispatcher.Invoke(() =>
258
                 {
256
                 {
259
-                    CameraIndex = MicrophoneList.FindIndex(x => x == APP.MicrophoneName);
260
-                }
261
-                CmbMicrophoneList.SelectedIndex = CameraIndex;
262
-            }
257
+                    CmbMicrophoneList.ItemsSource = data.DefaultView;
258
+                    if (WaveIn.DeviceCount > 0)
259
+                    {
260
+                        CmbMicrophoneList.SelectedIndex = 0;
261
+                    }
262
+                });
263
+            });
263
         }
264
         }
264
 
265
 
265
-        /// <summary>
266
-        /// 检测麦克风
267
-        /// </summary>
268
-        /// <param name="sender"></param>
269
-        /// <param name="e"></param>
270
-        private void BtnMicrophoneDetection_Click(object sender, RoutedEventArgs e)
266
+        private WaveInEvent waveIn = null;
267
+
268
+        private void CmbMicrophoneList_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
271
         {
269
         {
272
-            ImgMicAcousticWave.Visibility = Visibility.Hidden;
273
-            //GridMicImg.Visibility = Visibility.Hidden;
274
-            string AudioPath = FileToolsCommon.GetFileAbsolutePath("/temp/audio/");
275
-            FileToolsCommon.CreateDirectory(AudioPath);
276
-            string audioMicrophonePath = AudioPath + "adoM" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".mp3";
277
-            TbxMicrophoneDetection.Text = "录制中...";
278
-            BtnMicrophoneDetection.Content = "正在录制";
279
-            BtnMicrophoneDetection.IsEnabled = false;
280
-            new Thread(new ThreadStart(new Action(() =>
270
+            if (waveIn != null)
281
             {
271
             {
282
-                #region 检测麦克风
272
+                waveIn.StopRecording();
273
+            }
274
+            volumeProgressBar.Value = 0;
283
 
275
 
284
-                bool Record = APP.FFmpeg.StartRecordAudio(audioMicrophonePath, APP.MicrophoneName, false);
285
-                for (int i = 5; i > 0; i--)
286
-                {
287
-                    Dispatcher.Invoke(() =>
288
-                    {
289
-                        TbxMicrophoneDetection.Text = "请说话(" + i + "s)";
290
-                    });
291
-                    Thread.Sleep(1000);
292
-                }
293
-                if (Record)
276
+            if (CmbMicrophoneList.SelectedIndex >= 0)
277
+            {
278
+                waveIn = new WaveInEvent();
279
+                waveIn.DeviceNumber = CmbMicrophoneList.SelectedIndex;
280
+
281
+                //开始录音,写数据
282
+                waveIn.DataAvailable += (o, e1) =>
294
                 {
283
                 {
295
-                    if (FileToolsCommon.IsExistFile(audioMicrophonePath))
284
+                    byte[] buf = e1.Buffer;
285
+                    float maxNumber = 0;
286
+                    for (int index = 0; index < buf.Length; index += 2)
296
                     {
287
                     {
297
-                        Dispatcher.Invoke(() =>
298
-                        {
299
-                            TbxMicrophoneDetection.Text = "录制成功";
300
-
301
-                            MediaAudioMicPlay.Source = new Uri(audioMicrophonePath);
288
+                        short sample = (short)((buf[index + 1] << 8) | buf[index + 0]);
289
+                        float sample32 = sample / 32768f;
290
+                        sample32 = Math.Abs(sample32);
302
 
291
 
303
-                            ImgMicAcousticWave.Visibility = Visibility.Visible;
304
-                            MediaAudioMicPlay.Play();
305
-
306
-                            BtnMicrophoneDetection.Content = "回响中";
307
-                        });
308
-                    }
309
-                    else
310
-                    {
311
-                        //无法录制麦克风
312
-                        Dispatcher.Invoke(() =>
292
+                        if (sample32 > maxNumber)
313
                         {
293
                         {
314
-                            TbxMicrophoneDetection.Text = "不可用";
315
-
316
-                            FileToolsCommon.SetConfigValue("IsRecordingMicrophone", "0");
317
-                            //GridMicImg.Visibility = Visibility.Hidden;
318
-                        });
294
+                            maxNumber = sample32;
295
+                        }
319
                     }
296
                     }
320
-                }
321
-                else
322
-                {
323
-                    //无法录制麦克风
297
+
324
                     Dispatcher.Invoke(() =>
298
                     Dispatcher.Invoke(() =>
325
                     {
299
                     {
326
-                        TbxMicrophoneDetection.Text = "不可用";
327
-
328
-                        FileToolsCommon.SetConfigValue("IsRecordingMicrophone", "0");
329
-                        //GridMicImg.Visibility = Visibility.Hidden;
300
+                        volumeProgressBar.Value = maxNumber * 100;
330
                     });
301
                     });
331
-                }
332
-                APP.FFmpeg.StopRecordAudio(1);
333
-
334
-                #endregion 检测麦克风
302
+                };
335
 
303
 
336
-                Dispatcher.Invoke(() =>
304
+                //结束录音
305
+                waveIn.RecordingStopped += (s, a) =>
337
                 {
306
                 {
338
-                    BtnMicrophoneDetection.Content = "重新测试";
339
-                    BtnMicrophoneDetection.IsEnabled = true;
340
-                });
341
-            }))).Start();
342
-        }
307
+                    waveIn.Dispose();
308
+                };
343
 
309
 
344
-        /// <summary>
345
-        /// 播放结束
346
-        /// </summary>
347
-        /// <param name="sender"></param>
348
-        /// <param name="e"></param>
349
-        private void MediaAudioMicPlay_MediaEnded(object sender, RoutedEventArgs e)
350
-        {
351
-            MediaAudioMicPlay.Stop();
352
-            MediaAudioMicPlay.Position = TimeSpan.Zero;
353
-
354
-            ImgMicAcousticWave.Visibility = Visibility.Hidden;
355
-            BtnMicrophoneDetection.Content = "重新测试";
356
-            BtnMicrophoneDetection.IsEnabled = true;
310
+                waveIn.StartRecording();
311
+            }
357
         }
312
         }
358
 
313
 
359
         #endregion 麦克风
314
         #endregion 麦克风
443
 
398
 
444
         private void btn_microphone_good_Click(object sender, RoutedEventArgs e)
399
         private void btn_microphone_good_Click(object sender, RoutedEventArgs e)
445
         {
400
         {
401
+            if (waveIn != null)
402
+            {
403
+                waveIn.StopRecording();
404
+            }
405
+
446
             microphoneGood = true;
406
             microphoneGood = true;
447
             result_show();
407
             result_show();
408
+            CmbMicrophoneList.SelectedIndex = -1;
448
         }
409
         }
449
 
410
 
450
         private void btn_microphone_bad_Click(object sender, RoutedEventArgs e)
411
         private void btn_microphone_bad_Click(object sender, RoutedEventArgs e)
451
         {
412
         {
413
+            if (waveIn != null)
414
+            {
415
+                waveIn.StopRecording();
416
+            }
452
             microphoneGood = false;
417
             microphoneGood = false;
453
             result_show();
418
             result_show();
419
+            CmbMicrophoneList.SelectedIndex = -1;
454
         }
420
         }
455
 
421
 
456
         /// <summary>
422
         /// <summary>

+ 94
- 0
XHWK.WKTool/View/ZClippingBorder.cs View File

1
+using System;
2
+using System.Windows;
3
+using System.Windows.Controls;
4
+using System.Windows.Media;
5
+
6
+namespace XHWK.WKTool.View
7
+{
8
+    public class ZClippingBorder : Border
9
+    {
10
+        private object _oldClip;
11
+
12
+        protected override void OnRender(DrawingContext dc)
13
+        {
14
+            OnApplyChildClip();
15
+            base.OnRender(dc);
16
+        }
17
+
18
+        public override UIElement Child
19
+        {
20
+            get => base.Child;
21
+            set
22
+            {
23
+                if (Child != value)
24
+                {
25
+                    if (Child != null)
26
+                    {
27
+                        Child.SetValue(ClipProperty, _oldClip);
28
+                    }
29
+
30
+                    if (value != null)
31
+                    {
32
+                        _oldClip = value.ReadLocalValue(ClipProperty);
33
+                    }
34
+                    else
35
+                    {
36
+                        // If we dont set it to null we could leak a Geometry object
37
+                        _oldClip = null;
38
+                    }
39
+
40
+                    base.Child = value;
41
+                }
42
+            }
43
+        }
44
+
45
+        protected virtual void OnApplyChildClip()
46
+        {
47
+            UIElement child = Child;
48
+            if (child != null)
49
+            {
50
+                double top = Math.Max(CornerRadius.TopLeft, CornerRadius.TopRight);
51
+                double bottom = Math.Max(CornerRadius.BottomLeft, CornerRadius.BottomRight);
52
+                double max = Math.Max(top, bottom);
53
+                Size size = RenderSize;
54
+                double width = size.Width - (BorderThickness.Left + BorderThickness.Right);
55
+                double height = size.Height - (BorderThickness.Top + BorderThickness.Bottom);
56
+                Geometry result = new RectangleGeometry(new Rect(0, 0, width, height), max, max);
57
+                double halfWidth = width / 2;
58
+                double halfHeight = height / 2;
59
+
60
+                if (CornerRadius.TopLeft == 0)
61
+                {
62
+                    result = new CombinedGeometry(
63
+                        GeometryCombineMode.Union,
64
+                        result,
65
+                        new RectangleGeometry(new Rect(0, 0, halfWidth, halfHeight))
66
+                    );
67
+                }
68
+
69
+                if (CornerRadius.TopRight == 0)
70
+                {
71
+                    result = new CombinedGeometry(GeometryCombineMode.Union, result, new RectangleGeometry
72
+                (new Rect(halfWidth, 0, halfWidth, halfHeight)));
73
+                }
74
+
75
+                if (CornerRadius.BottomLeft == 0)
76
+                {
77
+                    result = new CombinedGeometry
78
+                  (GeometryCombineMode.Union, result, new RectangleGeometry
79
+                  (new Rect(0, halfHeight, halfWidth, halfHeight)));
80
+                }
81
+                if (CornerRadius.BottomRight == 0)
82
+                {
83
+                    result = new CombinedGeometry
84
+                  (
85
+                GeometryCombineMode.Union,
86
+                result,
87
+                new RectangleGeometry(new Rect(halfWidth, halfHeight, halfWidth, halfHeight))
88
+                );
89
+                }
90
+                child.Clip = result;
91
+            }
92
+        }
93
+    }
94
+}

+ 3
- 28
XHWK.WKTool/XHMicroLessonSystemWindow.xaml.cs View File

126
 
126
 
127
         #endregion 上传
127
         #endregion 上传
128
 
128
 
129
-
130
         /// <summary>
129
         /// <summary>
131
         /// 键盘钩子
130
         /// 键盘钩子
132
         /// </summary>
131
         /// </summary>
147
             new Aspose.Slides.License().SetLicense(new MemoryStream(license));
146
             new Aspose.Slides.License().SetLicense(new MemoryStream(license));
148
             InitializeComponent();
147
             InitializeComponent();
149
 
148
 
150
-
151
             #region 调整文字大小
149
             #region 调整文字大小
152
 
150
 
153
             APP.PageContextData.WordSize20 = 20.00;
151
             APP.PageContextData.WordSize20 = 20.00;
2185
                 GridMain.Visibility = Visibility.Visible;
2183
                 GridMain.Visibility = Visibility.Visible;
2186
                 GridM.IsEnabled = true;
2184
                 GridM.IsEnabled = true;
2187
                 GridRecordingTitle.Visibility = Visibility.Visible;
2185
                 GridRecordingTitle.Visibility = Visibility.Visible;
2188
-
2189
             }
2186
             }
2190
             else
2187
             else
2191
             {
2188
             {
2193
                 GridMyVideo.Visibility = Visibility.Visible;
2190
                 GridMyVideo.Visibility = Visibility.Visible;
2194
                 LoadUploadInitData();
2191
                 LoadUploadInitData();
2195
             }
2192
             }
2196
-
2197
         }
2193
         }
2198
 
2194
 
2199
         /// <summary>
2195
         /// <summary>
2208
             //加载视频列表
2204
             //加载视频列表
2209
             LoadingVideoList();
2205
             LoadingVideoList();
2210
 
2206
 
2211
-
2212
             Currpage = 0;
2207
             Currpage = 0;
2213
             PageNum = 0;
2208
             PageNum = 0;
2214
 
2209
 
2278
             }
2273
             }
2279
         }
2274
         }
2280
 
2275
 
2281
-
2282
-
2283
-
2284
         /// <summary>
2276
         /// <summary>
2285
         /// 搜索集合匹配的索引
2277
         /// 搜索集合匹配的索引
2286
         /// </summary>
2278
         /// </summary>
2561
         /// <param name="e"></param>
2553
         /// <param name="e"></param>
2562
         private void BtnDevice_Click(object sender, RoutedEventArgs e)
2554
         private void BtnDevice_Click(object sender, RoutedEventArgs e)
2563
         {
2555
         {
2564
-            if (APP.W_DeviceWindow == null)
2565
-            {
2566
-                APP.W_DeviceWindow = new DeviceWindow();
2567
-                APP.W_DeviceWindow.Owner = this;
2568
-            }
2569
             rbnTurnOff.IsChecked = true;
2556
             rbnTurnOff.IsChecked = true;
2570
             RbnTurnOff_Click(null, null);
2557
             RbnTurnOff_Click(null, null);
2571
-            APP.W_DeviceWindow.Initialize();
2572
-            APP.W_DeviceWindow.ShowDialog();
2558
+            DeviceWindow deviceWin = new DeviceWindow();
2559
+            deviceWin.Show();
2573
         }
2560
         }
2574
 
2561
 
2575
         #endregion 设备检测
2562
         #endregion 设备检测
2583
         /// <param name="e"></param>
2570
         /// <param name="e"></param>
2584
         private void BtnScreenRecording_Click(object sender, RoutedEventArgs e)
2571
         private void BtnScreenRecording_Click(object sender, RoutedEventArgs e)
2585
         {
2572
         {
2586
-
2587
             ThreadPool.QueueUserWorkItem(o =>
2573
             ThreadPool.QueueUserWorkItem(o =>
2588
             {
2574
             {
2589
                 bool microphoneGood = ZAudioRecordHelper.IsDeviceGood(ZAudioRecordHelper.RecordType.microphone);
2575
                 bool microphoneGood = ZAudioRecordHelper.IsDeviceGood(ZAudioRecordHelper.RecordType.microphone);
2605
 
2591
 
2606
                     Record();
2592
                     Record();
2607
 
2593
 
2608
-
2609
                     k_hook.Stop();
2594
                     k_hook.Stop();
2610
                     if (APP.W_ScreenRecordingToolbarWindow == null)
2595
                     if (APP.W_ScreenRecordingToolbarWindow == null)
2611
                     {
2596
                     {
2632
                     Hide();
2617
                     Hide();
2633
                 });
2618
                 });
2634
             });
2619
             });
2635
-
2636
-
2637
-
2638
         }
2620
         }
2639
 
2621
 
2640
         /// <summary>
2622
         /// <summary>
2686
         /// 视频保存路径名
2668
         /// 视频保存路径名
2687
         /// </summary>
2669
         /// </summary>
2688
         private string VideoSavePathName;
2670
         private string VideoSavePathName;
2671
+
2689
         /// <summary>
2672
         /// <summary>
2690
         /// 截图定时器
2673
         /// 截图定时器
2691
         /// </summary>
2674
         /// </summary>
2740
 
2723
 
2741
             #endregion 防止连击
2724
             #endregion 防止连击
2742
 
2725
 
2743
-
2744
             if (APP.PageContextData.currpage == 0)
2726
             if (APP.PageContextData.currpage == 0)
2745
             {
2727
             {
2746
                 MessageWindow.Show("请先导入文档或截图!");
2728
                 MessageWindow.Show("请先导入文档或截图!");
2749
 
2731
 
2750
             if (RecordType == 0)
2732
             if (RecordType == 0)
2751
             {
2733
             {
2752
-
2753
                 ThreadPool.QueueUserWorkItem(o =>
2734
                 ThreadPool.QueueUserWorkItem(o =>
2754
                 {
2735
                 {
2755
-
2756
                     bool microphoneGood = ZAudioRecordHelper.IsDeviceGood(ZAudioRecordHelper.RecordType.microphone);
2736
                     bool microphoneGood = ZAudioRecordHelper.IsDeviceGood(ZAudioRecordHelper.RecordType.microphone);
2757
 
2737
 
2758
                     Dispatcher.Invoke(() =>
2738
                     Dispatcher.Invoke(() =>
2759
                     {
2739
                     {
2760
-
2761
                         if (!microphoneGood)
2740
                         if (!microphoneGood)
2762
                         {
2741
                         {
2763
                             MessageWindow.Show("麦克风不可用");
2742
                             MessageWindow.Show("麦克风不可用");
2818
                             StartRecord();
2797
                             StartRecord();
2819
                         }))).Start();
2798
                         }))).Start();
2820
                     });
2799
                     });
2821
-
2822
                 });
2800
                 });
2823
-
2824
-
2825
             }
2801
             }
2826
             else if (RecordType == 1)
2802
             else if (RecordType == 1)
2827
             {
2803
             {
3023
         {
2999
         {
3024
             try
3000
             try
3025
             {
3001
             {
3026
-
3027
                 //保存图片
3002
                 //保存图片
3028
 
3003
 
3029
                 try
3004
                 try

+ 1
- 0
XHWK.WKTool/XHWK.WKTool.csproj View File

334
     <Compile Include="VideoClipWindow.xaml.cs">
334
     <Compile Include="VideoClipWindow.xaml.cs">
335
       <DependentUpon>VideoClipWindow.xaml</DependentUpon>
335
       <DependentUpon>VideoClipWindow.xaml</DependentUpon>
336
     </Compile>
336
     </Compile>
337
+    <Compile Include="View\ZClippingBorder.cs" />
337
     <Compile Include="Welcome.xaml.cs">
338
     <Compile Include="Welcome.xaml.cs">
338
       <DependentUpon>Welcome.xaml</DependentUpon>
339
       <DependentUpon>Welcome.xaml</DependentUpon>
339
     </Compile>
340
     </Compile>

+ 7
- 6
XHWK.WKTool/system/FFMpeg.cs View File

434
             ErrMessage = null;
434
             ErrMessage = null;
435
             string Extension = FileToolsCommon.GetIOExtension(VideoSavePath);//扩展名
435
             string Extension = FileToolsCommon.GetIOExtension(VideoSavePath);//扩展名
436
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
436
             Process[] KillProcessArray = Process.GetProcessesByName("ffmpeg");
437
-       
437
+
438
             foreach (Process KillProcess in KillProcessArray)
438
             foreach (Process KillProcess in KillProcessArray)
439
             {
439
             {
440
                 KillProcess.Kill();
440
                 KillProcess.Kill();
801
                 myProcess = new Process();
801
                 myProcess = new Process();
802
                 LogPath = CreateffmpegLog();
802
                 LogPath = CreateffmpegLog();
803
                 myProcess.StartInfo.FileName = ffmpegPath;   //ffmpeg.exe的绝对路径
803
                 myProcess.StartInfo.FileName = ffmpegPath;   //ffmpeg.exe的绝对路径
804
-                                                                                                                 //myProcess.StartInfo.Arguments = "-i \"" + VideoPath + "\" -ss 1 -vframes 1 -r 1 -ac 1 -ab 2 -s " + thubWidth + "*" + thubHeight + " -f image2 \"" + ImagePath + "\"";
804
+                                                             //myProcess.StartInfo.Arguments = "-i \"" + VideoPath + "\" -ss 1 -vframes 1 -r 1 -ac 1 -ab 2 -s " + thubWidth + "*" + thubHeight + " -f image2 \"" + ImagePath + "\"";
805
                 myProcess.StartInfo.Arguments = "-i \"" + VideoPath + "\" -ss 1 -vframes 1 -r 1 -ac 1 -ab 2" + WHStr + " -f image2 \"" + ImagePath + "\"";
805
                 myProcess.StartInfo.Arguments = "-i \"" + VideoPath + "\" -ss 1 -vframes 1 -r 1 -ac 1 -ab 2" + WHStr + " -f image2 \"" + ImagePath + "\"";
806
 
806
 
807
                 if (OutputVideoLog)
807
                 if (OutputVideoLog)
920
             }
920
             }
921
         }
921
         }
922
 
922
 
923
-
924
-        public bool VideoAudioMerge(string VideoPathName, string mp3path,string VideoSavePathName, int Width, int Height)
923
+        public bool VideoAudioMerge(string VideoPathName, string mp3path, string VideoSavePathName, int Width, int Height)
925
         {
924
         {
926
             while (myProcess != null)
925
             while (myProcess != null)
927
             {
926
             {
939
                 myProcess.StartInfo.FileName = ffmpegPath;   //ffmpeg.exe的绝对路径
938
                 myProcess.StartInfo.FileName = ffmpegPath;   //ffmpeg.exe的绝对路径
940
 
939
 
941
                 string ffmpegstr = "-i " + VideoPathName + " -i " + mp3path + " -acodec copy -vcodec libx264 " + "-s " + Width + "*" + Height + " " + VideoSavePathName;
940
                 string ffmpegstr = "-i " + VideoPathName + " -i " + mp3path + " -acodec copy -vcodec libx264 " + "-s " + Width + "*" + Height + " " + VideoSavePathName;
942
-                Console.WriteLine("ffmpegstr:"+ ffmpegstr);
941
+                Console.WriteLine("ffmpegstr:" + ffmpegstr);
943
                 myProcess.StartInfo.Arguments = ffmpegstr;
942
                 myProcess.StartInfo.Arguments = ffmpegstr;
944
 
943
 
945
                 if (OutputVideoLog)
944
                 if (OutputVideoLog)
1351
             return devices;
1350
             return devices;
1352
         }
1351
         }
1353
 
1352
 
1354
- 
1355
         #endregion 获取麦克风
1353
         #endregion 获取麦克风
1356
 
1354
 
1357
         #region 录音
1355
         #region 录音
1447
                 waveIn.DataAvailable += (s, a) =>
1445
                 waveIn.DataAvailable += (s, a) =>
1448
                 {
1446
                 {
1449
                     writer.Write(a.Buffer, 0, a.BytesRecorded);
1447
                     writer.Write(a.Buffer, 0, a.BytesRecorded);
1448
+                    short s1 = BitConverter.ToInt16(a.Buffer, 0);//这样采样比较少,反正是int16型的
1449
+                    int s2 = Math.Abs(s1 / 50);
1450
+                    Console.WriteLine("声音大小:" + s2);
1450
                 };
1451
                 };
1451
 
1452
 
1452
                 //结束录音
1453
                 //结束录音

+ 1
- 1
打包脚本/Inno Setup星火微课.iss View File

3
 
3
 
4
 #define MyAppName "星火微课"  
4
 #define MyAppName "星火微课"  
5
 #define MyAppDir "xhwk"
5
 #define MyAppDir "xhwk"
6
-#define MyAppVersion "2.6.9"
6
+#define MyAppVersion "2.7.0"
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\C#\xhwkclient\XHWK.WKTool\bin\x86\Debug\"
9
 #define MySourcePath "D:\Project\C#\xhwkclient\XHWK.WKTool\bin\x86\Debug\"

Loading…
Cancel
Save