473,394 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

wav file played from resource is "scratchy"

I have an application that plays short (2-5 seconds) sounds from resources at
specific times. About 10% of the time the wav file will start playing fine
and at some undetermined point during the playback it will play loud tones
for the duration of the sound files normal time. I cannot figure out what
actually causes it. I can click a different button and have another sound
play fine out of the resource while the first sound is malfunctioning. It
appears that the malfunctions are completely random. It only appears to
occur when i play the sound from a resource, as i seem to be able to play
sounds fine when i point them at the file on the harddrive instead of passing
in the stream from the resource.

The code is very simple. I have an overall setting that turns sounds on and
off. Then a setting that allows the user to change the applause sound. If
the path is empty or doesn't point to a valid sound file it will play the
default from a resource
public static void PlayApplause()
{
if (!PlaySound(Settings.Default.ApplauseSoundPath))
PlaySound(Resources.applausesmall_Sound);
}
public static bool PlaySound(Stream toPlay)
{
bool rVal = false;
try
{
if (Settings.Default.PlaySounds)
{
SoundPlayer sp = new SoundPlayer(toPlay);
sp.Load();
sp.Play();
rVal = true;
}
}
catch { rVal = false; }
return rVal;
}
public static bool PlaySound(string Path)
{
bool rVal = false;
try
{
if (Settings.Default.PlaySounds &&
!string.IsNullOrEmpty(Path) && File.Exists(Path))
{
SoundPlayer sp = new SoundPlayer(Path);
sp.Load();
sp.Play();
rVal = true;
}
}
catch
{
rVal = false;
}
return rVal;
}

Jun 27 '08 #1
0 856

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Greg Heilers | last post by:
Hola all.... I need to code a site for a friend who wants a 3-box layout, such as this: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.