Questions tagged [soundplayer]

SoundPlayer is a method which plays .wav files in c#

133 questions
2
votes
2 answers

URI Prefix not supported

I am trying to load and play a wave file using: SoundPlayer simpleSound = new SoundPlayer(@"pack://application:,,,/MyAssembly;component/Sounds/10meters.wav"); simpleSound.Play(); With no success. I get a System.NotSupportedException :(…
GETah
  • 20,922
  • 7
  • 61
  • 103
2
votes
1 answer

I can't find the System.Media namespace in Visual Studio 2019

Edit - ANSWER: I found the solution thanks to @LexLi and @Amy; I accidentally created a .NET Core console application instead of .NET Framework. Once I remade it as a .NET Framework app it had "System.Media" available. I'm relatively new (only a few…
Robby Heckman
  • 29
  • 1
  • 3
2
votes
1 answer

C# SoundPlayer class isn't finding the file at the specified path

I'm using the Path.GetFullPath of the System.IO namespace and it is correctly pulling the absolute filepath for the sound file that I have stored in the program. It is displaying it in a MessageBox and the filepath is definitely correct. However,…
coreynj
  • 25
  • 5
2
votes
3 answers

Traversing List C#

I am playing around with some C# and I was coding a piano application. Whenever the user clicks a piano note, I am storing the location of the sound (.wav) into a list... the following is some code in the button1_MouseDown method. if (e.Button ==…
Axel
  • 57
  • 1
  • 10
2
votes
2 answers

playback audio file from byte code (audio file format is CCITT A-Law)

I want to playback audio file from byte code. I already have byte code for audio file. But when I playback with System.Media.SoundPlayer, I got error as "{Sound API only supports playing PCM wave files."}. My audio file format is (CCITT A-Law). Can…
CNN
  • 21
  • 2
2
votes
2 answers

Do something after a music ends with SoundPlayer

I need to do something after my Async Loaded music file finishes. Let's say I want the program to exit or something. Now how do I make it do is after the music finishes? private void button1_Click(object sender, EventArgs e) { …
Tom Lenc
  • 765
  • 1
  • 17
  • 41
2
votes
2 answers

The wave header is corrupt using C#

I am trying to play a Wav file in C# Some of my files come through with the error "The wave header is corrupt." I set the Position = 0 and it still happens. using (System.Media.SoundPlayer sound = new System.Media.SoundPlayer(soundStream)) …
Yossi
  • 136
  • 2
  • 7
2
votes
2 answers

Play sound from WAV file at a time offset from start in C#

I'm trying to coordinate playing sound with displaying some other data on a graph recorded at the same time. If the user drags the graph forward or backwards how can I skip forward or backward in the WAV file so the sound is still coordinated? I…
parsley72
  • 8,449
  • 8
  • 65
  • 98
2
votes
1 answer

Windows Form: Play sound, but not from beginning

I want to play a track (.wav file) in my Windows Forms Application. But I do not want it to play from the beginning, but from a certain point somewhere in the track (let's say 10 seconds). To play the track from beginning is no problem: private void…
marius
  • 163
  • 1
  • 2
  • 16
2
votes
0 answers

Get length of wav file? (playing wav with soundplayer class)

I'm playing wav sound files using the .NET SoundPlayer class in my program, is it somehow possible to get the length of the wav file (in milliseconds)? Thanks for answers.
ibmkahm
  • 21
  • 3
2
votes
2 answers

How to set the duratiion of a song in C #

I have an application that plays a particular song for a specified time, as the result of a select. I can already play the songs, but I can not set a time duration. public void PlaySound() { int i = 0; foreach (string…
Flávio Costa
  • 895
  • 5
  • 18
  • 41
2
votes
0 answers

How to stop PlaySync() in SoundPlayer on button click in C# windows forms

I have a window application that enables you to play sound based on the letter you click. You can repeat the sound based on the number you entered in the TextBox and you can play from 1 to 3 in a sequence. It is all working with the bellow code. but…
msandlana
  • 51
  • 4
2
votes
3 answers

SoundPlayer not playing any bundled windows sounds PCM wav files

In C# I cannot get SoundPlayer class from System.Media to play any wav from my C:\Windows\Media folder using the following code. All I get is no sound: String filename = "C:\\Windows\\Media\\tada.wav"; SoundPlayer sp = new…
user1547462
2
votes
1 answer

Alternatives to SoundPlayer

I'm using the SoundPlayer class to play WAV files in my WPF application. The files are short and are part of the application and are played in response to events that occur in the program. The user has no control over what sound is played and…
Tony Vitabile
  • 8,298
  • 15
  • 67
  • 123
1
vote
1 answer

What is better solution for playing sounds in .net application: Audio from DirectX lib or System.Media.SoundPlayer?

As i know SoundPlayer plays only .wav files..And what is the point of it if Audio can play any format(if you have the right codec)? Isnt it better to just use Audio in your classes and be happy?
0x49D1
  • 8,505
  • 11
  • 76
  • 127
1
2
3
8 9