i have some code and some .wav files in the folder that contains my sourse code, but instead of playing the defined sound, eg when a bullet it fired, it plays a windows sound, this is the code i have any help much appreciated
private Thread oThread = null;
[DllImport("winmm.dll")]
public static extern long PlaySound(String lpszName, long hModule, long dwFlags);
private string m_strCurrentSoundFile;
public void PlayASound()
{
if (m_strCurrentSoundFile.Length > 0)
{
PlaySound(Application.StartupPath + "\\" + m_strCurrentSoundFile, 0, 0);
}
//m_strCurrentSoundFile = "";
//m_nCurrentPriority = 3;
//oThread.Abort();
}
int m_nCurrentPriority = 3;
public void PlaySoundInThread(string wavefile, int priority)
{
if (priority <= m_nCurrentPriority)
{
//m_nCurrentPriority = priority;
//if (oThread != null)
//oThread.Abort();
m_strCurrentSoundFile = wavefile;
oThread = new Thread(new ThreadStart(PlayASound));
oThread.Start();
}
}
Then under the keydown event for the fire bullet i have
PlaySoundInThread("laz.wav", 3);
any help is much appreciated, p.s i have commented out some of the code above
private Thread oThread = null;
[DllImport("winmm.dll")]
public static extern long PlaySound(String lpszName, long hModule, long dwFlags);
private string m_strCurrentSoundFile;
public void PlayASound()
{
if (m_strCurrentSoundFile.Length > 0)
{
PlaySound(Application.StartupPath + "\\" + m_strCurrentSoundFile, 0, 0);
}
//m_strCurrentSoundFile = "";
//m_nCurrentPriority = 3;
//oThread.Abort();
}
int m_nCurrentPriority = 3;
public void PlaySoundInThread(string wavefile, int priority)
{
if (priority <= m_nCurrentPriority)
{
//m_nCurrentPriority = priority;
//if (oThread != null)
//oThread.Abort();
m_strCurrentSoundFile = wavefile;
oThread = new Thread(new ThreadStart(PlayASound));
oThread.Start();
}
}
Then under the keydown event for the fire bullet i have
PlaySoundInThread("laz.wav", 3);
any help is much appreciated, p.s i have commented out some of the code above