Answered by:
Can you play a sound file in Console?

Question
-
I've been trying to find help online but I couldn't see anyithing. I want that a wav file or any other sound file starts playing if I press a button. Is it possible in the Console?
- Edited by Soul KniTTer Monday, December 28, 2015 1:54 PM
Monday, December 28, 2015 1:54 PM
Answers
-
A thread is supposed to be just one question.
As soon as you start on "just one more question" then you are really supposed to start a new thread. Unless that is a clarification of some aspect.
When you ask 3 questions then that's ... you get the picture.
The question should be the title.
This is not just a silly pointless rule, it's so the forum works as a searchable resource.
Your thread is supposed to be re-usable. Answered once, read many times.
Many people don't bother with the searching and reading so much, but there are also a lot of people browse.
.
You can play a sound in a console app, although as Sabah has pointed mention of a button does rather suggest a different sort of app like winforms or wpf.
One which is designed to actually have a ui.
http://stackoverflow.com/questions/22028688/playing-sounds-on-console-c-sharp
.
And you can process start a file so that it will be run by it's default app. Or you can process start an exe. If there are command line parameters, you can also supply those.
Back to your first question - if you process.start a wav file then that would be played by whatever you have registered to play files with the .wav extension.
There are also a bunch of other parameters you could read up on, at length.
.
I'm not at all sure where you're headed here.
If you don't have enough from this thread.
What's the end aim you want to achieve?
- Proposed as answer by Kristin Xie Tuesday, January 5, 2016 2:49 AM
- Marked as answer by Kristin Xie Wednesday, January 6, 2016 1:21 AM
Monday, December 28, 2015 4:30 PM
All replies
-
Hi Soul,
Console window doesn't provide any UI that user can intereact so you cannot use button there. You could use WinForm program to achieve this as it button control.
How to: Play Sounds in an Application
Thanks,
Sabah Shariq
- Edited by Sabah ShariqMVP Monday, December 28, 2015 2:11 PM
Monday, December 28, 2015 2:09 PM -
Thank you for your help.
I have 1 more question in addittion. Can you start a file using console?
A jpeg or an exe?Monday, December 28, 2015 2:12 PM -
Yes you can start a file from console program. Like if you want to run a batch script (.bat) file you can use the following in the main method.
System.Diagnostics.Process.Start("c:\\batchfilename.bat");
Thanks,
Sabah Shariq
- Edited by Sabah ShariqMVP Monday, December 28, 2015 2:19 PM
Monday, December 28, 2015 2:19 PM -
A thread is supposed to be just one question.
As soon as you start on "just one more question" then you are really supposed to start a new thread. Unless that is a clarification of some aspect.
When you ask 3 questions then that's ... you get the picture.
The question should be the title.
This is not just a silly pointless rule, it's so the forum works as a searchable resource.
Your thread is supposed to be re-usable. Answered once, read many times.
Many people don't bother with the searching and reading so much, but there are also a lot of people browse.
.
You can play a sound in a console app, although as Sabah has pointed mention of a button does rather suggest a different sort of app like winforms or wpf.
One which is designed to actually have a ui.
http://stackoverflow.com/questions/22028688/playing-sounds-on-console-c-sharp
.
And you can process start a file so that it will be run by it's default app. Or you can process start an exe. If there are command line parameters, you can also supply those.
Back to your first question - if you process.start a wav file then that would be played by whatever you have registered to play files with the .wav extension.
There are also a bunch of other parameters you could read up on, at length.
.
I'm not at all sure where you're headed here.
If you don't have enough from this thread.
What's the end aim you want to achieve?
- Proposed as answer by Kristin Xie Tuesday, January 5, 2016 2:49 AM
- Marked as answer by Kristin Xie Wednesday, January 6, 2016 1:21 AM
Monday, December 28, 2015 4:30 PM