Może to jest plik WAV w innym formacie niż zwykły PCM po prostu?
A ja używałem odtwarzania WAV z czasów C# 1.1, kiedy nie było SoundPlayer. Nie jestem pewien, czy zadziała również, możliwe, że oba przykłady odwołują się do tego samego API.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
namespace Ktos
{
class Urd
{
// PlaySound()
[DllImport("winmm.dll", SetLastError = true,
CallingConvention = CallingConvention.Winapi)]
static extern bool PlaySound(
string pszSound,
IntPtr hMod,
SoundFlags sf);
// Flags for playing sounds. For this example, we are reading
// the sound from a filename, so we need only specify
// SND_FILENAME | SND_ASYNC
[Flags]
public enum SoundFlags : int
{
SND_SYNC = 0x0000, // play synchronously (default)
SND_ASYNC = 0x0001, // play asynchronously
SND_NODEFAULT = 0x0002, // silence (!default) if sound not found
SND_MEMORY = 0x0004, // pszSound points to a memory file
SND_LOOP = 0x0008, // loop the sound until next sndPlaySound
SND_NOSTOP = 0x0010, // don't stop any currently playing sound
SND_NOWAIT = 0x00002000, // don't wait if the driver is busy
SND_ALIAS = 0x00010000, // name is a registry alias
SND_ALIAS_ID = 0x00110000, // alias is a predefined ID
SND_FILENAME = 0x00020000, // name is file name
SND_RESOURCE = 0x00040004 // name is resource name or atom
}
static void Main(string[] args)
{
int err = 0;
try
{
if (File.Exists(args[0]))
{
if (!PlaySound(args[0], IntPtr.Zero, SoundFlags.SND_FILENAME))
Console.WriteLine("Urd: Nie odnaleziono wskazanego pliku");
}
else
Console.WriteLine("Urd: Nie odnaleziono wskazanego pliku");
}
catch (Exception e)
{
err = Marshal.GetLastWin32Error();
Console.WriteLine(" Funkcja PlaySound() zawiodła, kod błedu " + err.ToString());
}
}
}
}