SoundPlayer is a method which plays .wav files in c#
Questions tagged [soundplayer]
129 questions
11
votes
1 answer
Play wav/mp3 from memory
I play mp3/wav from file to create a push effect. However on an Atom CPU based tablet PC, there is a delay when I touch the button.
I'll try to play wav/mp3 from memory instead of file system. Can anyone give a code snippet or a clue?…
![](../../users/profiles/627193.webp)
Nime Cloud
- 5,691
- 13
- 38
- 70
8
votes
8 answers
SoundPlayer causing Memory Leaks?
I'm writing a basic writing app in C# and I wanted to have the program make typewriter sounds as you typed. I've hooked the KeyPress event on my RichTextBox to a function that uses a SoundPlayer to play a short wav file every time a key is pressed,…
![](../../users/profiles/315544.webp)
Nick Udell
- 2,306
- 5
- 41
- 81
5
votes
1 answer
How to know when SoundPlayer has finished playing a sound
I am using the following code to dynamically create a frequency tone in memory and play the tone asynchronously:
public static void PlayTone(UInt16 frequency, int msDuration, UInt16 volume = 16383)
{
using (var mStrm = new MemoryStream())
{
…
![](../../users/profiles/98094.webp)
Icemanind
- 43,745
- 45
- 159
- 272
5
votes
2 answers
Play a sound using SoundPlayer
I'm trying to play a specific sound.
However I can't seem to reach the file that I added in my Solution Explorer.
(I have this folder called "Sounds/" with several .wav-soundeffects in it)
When I hardcode a filepath to a random fixed location on my…
![](../../users/profiles/947083.webp)
Totumus Maximus
- 7,331
- 6
- 40
- 68
5
votes
3 answers
Playing sounds on Console - C#
I'm writing a Console application on C# and I want to play a sound when I display texts continuously. This is what I've done :
static SoundPlayer typewriter = new SoundPlayer("typewriter");
static public void print(string str, int delay)
{
…
![](../../users/profiles/2625813.webp)
user26830
- 979
- 3
- 13
- 23
5
votes
5 answers
Playing wav file which has relative path inside project
I have some problems with relative paths and reproduction of wav files. I have this simple code which works perfectly:
SoundPlayer player = new SoundPlayer();
player.SoundLocation = @"C:\Users\Admin\Documents\Visual Studio…
![](../../users/profiles/1291514.webp)
Cristiano
- 2,699
- 9
- 39
- 66
4
votes
1 answer
Is there a faster way to play a sound than SoundPlayer in C#?
I am trying to play a typing sound every time a key is pressed, using the SoundPlayer class (to simulate typewriter sounds).
public void MyKeyDown(object sender, KeyEventArgs)
{
player = new System.Media.SoundPlayer(@"f:\sounds\2.wav");
…
![](../../users/profiles/61905.webp)
Sylverdrag
- 8,560
- 5
- 32
- 49
4
votes
0 answers
How can I SoundPlayer.PlaySync() in one thread and Stop() it in another thread?
I'm writing a simple .wav player. There are two buttons: Play button, Stop button.
I've 2 solutions:
1. use Play() api to play a .wav file; use Stop() api to stop it.
The issue is I cannot do something when a .wav file is stopped (eg. disable the…
![](../../users/profiles/1275719.webp)
ricky
- 1,768
- 3
- 15
- 40
3
votes
1 answer
C# windows forms application volume slider
I have an application that plays a .wav file using the soundplayer, I looked it up and couldn't find a way to change the volume it plays in. What I'm looking for is either to change the volume of the file independently through the program or have a…
![](../../users/profiles/6139498.webp)
dvs
- 97
- 1
- 8
3
votes
1 answer
How do I fade out the audio of a .wav file using SoundPlayer instead of stopping it immediately?
I'm trying to stop sound as soon as I release the button, but what happens is that file is played fully.
I don't want to stop the sound abruptly as it happened with sp.Stop().
Is there a way to do this?
private void button1_MouseDown(object sender,…
![](../../users/profiles/5667798.webp)
Gleb Eliseev
- 55
- 11
3
votes
2 answers
Why are local variables not shown in debug view in eclipse?
Here is what I am seeing in my debug view.
The second picture
I want to examine the state of all the local variables so I can understand why a UnsupportedAudioFileException is being thrown. The first picture looks fine (all the values of the local…
![](../../users/profiles/3761297.webp)
committedandroider
- 7,124
- 12
- 48
- 114
3
votes
1 answer
WPF SoundPlayer multi-channel sound?
I have an app that emits sounds at a random interval. When two sounds collide they do not nicely overplay each other but one interrupts the other.
I'm using SoundPlayer to play the sounds. (this is a WPF app)
How can I use multiple sound channels…
![](../../users/profiles/107945.webp)
Kelly
- 6,187
- 9
- 51
- 71
3
votes
1 answer
powershell 'system.windows.media.mediaplayer' Register-ObjectEvent
I'm trying to use the 'system.windows.media.mediaplayer' media player, to play a list of sound files, however I'm having trouble getting the media player to know when to play the next sound file.
I'm trying to use the 'MediaEnded' event handle to…
![](../../users/profiles/2475760.webp)
Josh Budd
- 59
- 2
- 5
3
votes
1 answer
How to append .wav format sounds to each other
I am studying C# by myself by reading some books and watching some tutorials. So, i decided to make a small project at the same time, to get more experience and harden my knowledge. I am trying to create a text to speech program in Georgian(my…
![](../../users/profiles/1083364.webp)
vato
- 141
- 2
- 10
2
votes
3 answers
How to play a music file for a specified amount of time
What I'm trying to do is play a music file for a specified duration, and then stop playing. However, the whole music file is being played. Any ideas?
I've tried starting a new thread, still doesnt work.
![](../../users/profiles/856132.webp)
Dot NET
- 4,828
- 11
- 49
- 94