Previous to the installation, you should remove "Microsoft Visual C++ 2010 Redistributable", otherwise the error "S1023" occurs (here is more information about this error).
After the installation, you only need to add a reference in the C# project (Browse - Microsoft.DirectX.DirectSound, I found the file at C:\Windows\assembly\GAC\Microsoft.DirectX.DirectSound).
Additionally, App.config has to be modified a bit. At first it looked like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
<startup>
has to be modified to <startup useLegacyV2RuntimeActivationPolicy="true">
, now everything looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
The code to play sounds is the following:
Device applicationDevice = new Device();
applicationDevice.SetCooperativeLevel(this, CooperativeLevel.Priority );
soundBuffer1 = new SecondaryBuffer( "c:\afile1.wav", applicationDevice );
soundBuffer2 = new SecondaryBuffer( "c:\afile2.wav", applicationDevice );
soundBuffer1.Play( 0, BufferPlayFlags.Looping );
soundBuffer2.Play( 0, BufferPlayFlags.Looping );
No comments:
Post a Comment