Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8337337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:16:39+00:00 2026-06-09T04:16:39+00:00

In C# I cannot get SoundPlayer class from System.Media to play any wav from

  • 0

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 SoundPlayer(filename);
sp.Load();
sp.Play();

I have checked the wave file “tada.wav” with a program called “Gspot” that tells me the audio codec is “PCM Audio”. I do not receive any compiler warnings or errors and there is no exceptions raised when I run the program. I just do not get any sound. My speakers are on, and I can play the file with Windows Media Player.

Adding the wav as a project resource does not make any difference. Could somebody please help me figure out why I cannot get any sound?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:16:40+00:00Added an answer on June 9, 2026 at 4:16 am

    Are you using this as the body of a main() method in a console application? The application is probably ending, thereby shutting down the thread which plays the audio.

    I copied and pasted your code into the main of a new “Visual C# Console Application”. I added the “using System.Text;” line at the top of the file, compiled, stepped through it, and it worked. When I ran it (without debugging) I got no sound.

    If you add the line:

    System.Threading.Thread.Sleep(2000);

    After the call to Play(), the application will stay around long enough to play the audio.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cannot get the following route to fire when a url is requested from
I cannot get any help information from my octave command prompt. Example, when I
I cannot get Javascript to run after a ASP.NET postback from a client script
I cannot get my Canon Pixma MP150 to scan a color scan from c#
I cannot get the following stringstreamm to compile stringstream qss; qss.operator << some text
I cannot get my code to work! I am trying to implement the quick
I cannot get any new entries in the textbox:txtMyString to set to the property
Cannot get this to work. First time using variables passed into functions. Unchecking radio
I cannot get time remaining from groupon HTML. I did find a method before
I cannot get James Taylor's excellent little seek-bzip2 to compile under Windows? It can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.