Skip to content

Commit 9bbd2bd

Browse files
committed
fixed shell execute for .NET core in demo apps
1 parent 278b551 commit 9bbd2bd

File tree

7 files changed

+41
-11
lines changed

7 files changed

+41
-11
lines changed

Docs/RawSourceWaveStream.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Note that WAV files can contain compressed audio, so as long as you know the cor
6363

6464
## Converting G.729 audio into a PCM WAV
6565

66-
Suppose we have a .g729 file containing raw audio compressed with G.729. G.729 isn't actually a built-in `WaveFormat` in NAudio (some other common ones like mu and a-law are). But we can use `WaveFormat.CreateCustomFormat` or even derive from `WaveFormat` to define the correct format.
66+
Suppose we have a `.g729` file containing raw audio compressed with G.729. G.729 isn't actually a built-in `WaveFormat` in NAudio (some other common ones like mu and a-law are). But we can use `WaveFormat.CreateCustomFormat` or even derive from `WaveFormat` to define the correct format.
6767

6868
Now in the previous example we saw how we could create a WAV file that contains the G.729 audio still encoded. But if we wanted it to be PCM, we'd need to use `WaveFormatConversionStream.CreatePcmStream` to look for an ACM codec that understands the incoming `WaveFormat` and can turn it into PCM.
6969

@@ -89,7 +89,7 @@ using(var converter = WaveFormatConversionStream.CreatePcmStream(reader))
8989
}
9090
```
9191

92-
If it was a format that NAUdio has built-in support for like G.711 a-law, then we'd do it like this:
92+
If it was a format that NAudio has built-in support for like G.711 a-law, then we'd do it like this:
9393

9494
```c#
9595
var inFile = @"c:\users\mheath\desktop\alaw.bin";

NAudioDemo/AcmDemo/AcmPanel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Windows.Forms;
44
using NAudio.Wave;
55
using NAudio.Wave.Compression;
6+
using NAudioDemo.Utils;
67

78
namespace NAudioDemo.AcmDemo
89
{
@@ -95,7 +96,7 @@ private void EncodeFile()
9596
}
9697
if (checkBoxAutoLaunchConvertedFile.Checked)
9798
{
98-
System.Diagnostics.Process.Start(outputFileName);
99+
ProcessHelper.ShellExecute(outputFileName);
99100
}
100101
}
101102
}
@@ -122,7 +123,7 @@ private void DecodeFile()
122123
}
123124
if (checkBoxAutoLaunchConvertedFile.Checked)
124125
{
125-
System.Diagnostics.Process.Start(outputFileName);
126+
ProcessHelper.ShellExecute(outputFileName);
126127
}
127128
}
128129
}

NAudioDemo/AsioRecordingDemo/AsioRecordingPanel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Linq;
55
using System.Windows.Forms;
66
using NAudio.Wave;
7+
using NAudioDemo.Utils;
78

89
namespace NAudioDemo.AsioRecordingDemo
910
{
@@ -146,7 +147,7 @@ private void OnButtonPlayClick(object sender, EventArgs e)
146147
{
147148
if (listBoxRecordings.SelectedItem != null)
148149
{
149-
Process.Start((string)listBoxRecordings.SelectedItem);
150+
ProcessHelper.ShellExecute((string)listBoxRecordings.SelectedItem);
150151
}
151152
}
152153

NAudioDemo/RecordingDemo/RecordingPanel.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Windows.Forms;
66
using NAudio.CoreAudioApi;
77
using NAudio.Wave;
8+
using NAudioDemo.Utils;
89

910
namespace NAudioDemo.RecordingDemo
1011
{
@@ -213,7 +214,7 @@ private void OnButtonPlayClick(object sender, EventArgs e)
213214
{
214215
if (listBoxRecordings.SelectedItem != null)
215216
{
216-
Process.Start(Path.Combine(outputFolder, (string)listBoxRecordings.SelectedItem));
217+
ProcessHelper.ShellExecute(Path.Combine(outputFolder, (string)listBoxRecordings.SelectedItem));
217218
}
218219
}
219220

@@ -246,7 +247,7 @@ private void OnButtonDeleteClick(object sender, EventArgs e)
246247

247248
private void OnOpenFolderClick(object sender, EventArgs e)
248249
{
249-
Process.Start(outputFolder);
250+
ProcessHelper.ShellExecute(outputFolder);
250251
}
251252
}
252253

NAudioDemo/Utils/ProcessHelper.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Diagnostics;
2+
3+
namespace NAudioDemo.Utils
4+
{
5+
static class ProcessHelper
6+
{
7+
public static void ShellExecute(string file)
8+
{
9+
var process = new Process();
10+
process.StartInfo = new ProcessStartInfo(file)
11+
{
12+
UseShellExecute = true
13+
};
14+
process.Start();
15+
}
16+
}
17+
}

NAudioDemo/VolumeMixerDemo/VolumePanel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ private void cmbDevice_SelectedIndexChanged(object sender, EventArgs e)
167167
private void btnSoundProperties_Click(object sender, EventArgs e)
168168
{
169169
if (!devicePanel)
170-
System.Diagnostics.Process.Start("control", "mmsys.cpl,,2");
170+
Process.Start("control", "mmsys.cpl,,2");
171171
else
172-
System.Diagnostics.Process.Start("control", "mmsys.cpl,,0");
172+
Process.Start("control", "mmsys.cpl,,0");
173173
}
174174

175175
private void tbVolume_MouseCaptureChanged(object sender, EventArgs e)

NAudioWpfDemo/WasapiCaptureDemo/RecordingsViewModel.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,17 @@ public RecordingsViewModel()
3535

3636
private void OpenFolder()
3737
{
38-
Process.Start(OutputFolder);
38+
ShellExecute(OutputFolder);
39+
}
40+
41+
private static void ShellExecute(string file)
42+
{
43+
var process = new Process();
44+
process.StartInfo = new ProcessStartInfo(file)
45+
{
46+
UseShellExecute = true
47+
};
48+
process.Start();
3949
}
4050

4151
private void Delete()
@@ -59,7 +69,7 @@ private void Play()
5969
{
6070
if (SelectedRecording != null)
6171
{
62-
Process.Start(Path.Combine(OutputFolder, SelectedRecording));
72+
ShellExecute(Path.Combine(OutputFolder, SelectedRecording));
6373
}
6474
}
6575

0 commit comments

Comments
 (0)