| | |
button to play wav file
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 4
Reputation:
Solved Threads: 0
Hello,
I am new to C#, very new, i started actually right after getting done learning queries and stuff from SQL 2005, two questions, first i am writing out a simple program where you click on a button and it plays the wav file with the path already within the program so it plays the wav file. problem is, i am new so i dont know what is the command to do that, i have the entire program entered below. The second thing is, i want to Learn C#, JAVA (since they are close related or similiar), SQL, and maybe something else, what other language though? the reason is i want to get into the programming field as a professional, right now i am a softwar test engineer still learning programming so please any advice, tutorials, documentation on C# would greatly help including SQL and java.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "Hi Everybody!";
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void button3_Click(object sender, EventArgs e)
{
SoundPlayer simplesound = new SoundPlayer(@"d:\additional\daboo.wave");
simplesound.Play();
}
}
}
Thank you in advance
I am new to C#, very new, i started actually right after getting done learning queries and stuff from SQL 2005, two questions, first i am writing out a simple program where you click on a button and it plays the wav file with the path already within the program so it plays the wav file. problem is, i am new so i dont know what is the command to do that, i have the entire program entered below. The second thing is, i want to Learn C#, JAVA (since they are close related or similiar), SQL, and maybe something else, what other language though? the reason is i want to get into the programming field as a professional, right now i am a softwar test engineer still learning programming so please any advice, tutorials, documentation on C# would greatly help including SQL and java.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "Hi Everybody!";
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void button3_Click(object sender, EventArgs e)
{
SoundPlayer simplesound = new SoundPlayer(@"d:\additional\daboo.wave");
simplesound.Play();
}
}
}
Thank you in advance
•
•
Join Date: Feb 2008
Posts: 2
Reputation:
Solved Threads: 0
There's 2 ways to do this:
Assuming that SoundPlayer is the application use to play your wav file.
1st Method
private void button3_Click(object sender, EventArgs e)
{
Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "SoundPlayer";
proc.Start();
proc.WaitForExit();
}
However this method only open the application...i'm not sure on how to pass the command line and make it automatically play the file. but the second method can
2nd Method
private void button3_Click(object sender, EventArgs e)
{
Process.Start("SoundPlayer","d:\additional\daboo.wave");
}
Hope this works for you
Assuming that SoundPlayer is the application use to play your wav file.
1st Method
private void button3_Click(object sender, EventArgs e)
{
Process proc = new Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "SoundPlayer";
proc.Start();
proc.WaitForExit();
}
However this method only open the application...i'm not sure on how to pass the command line and make it automatically play the file. but the second method can
2nd Method
private void button3_Click(object sender, EventArgs e)
{
Process.Start("SoundPlayer","d:\additional\daboo.wave");
}
Hope this works for you
•
•
Join Date: Jun 2008
Posts: 4
Reputation:
Solved Threads: 0
Hello,
Thanks for the info not sure if that will work but i will try, i found the answer which is below, i was missing the using system.media on top including the information below. hope this helps everyone as it did me.
private void button3_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer simplesound = new System.Media.SoundPlayer(@"d:\audio1.wav");
simplesound.Play();
}
Thanks for the info not sure if that will work but i will try, i found the answer which is below, i was missing the using system.media on top including the information below. hope this helps everyone as it did me.
private void button3_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer simplesound = new System.Media.SoundPlayer(@"d:\audio1.wav");
simplesound.Play();
}
•
•
•
•
Hello,
Thanks for the info not sure if that will work but i will try, i found the answer which is below, i was missing the using system.media on top including the information below. hope this helps everyone as it did me.
private void button3_Click(object sender, EventArgs e)
{
System.Media.SoundPlayer simplesound = new System.Media.SoundPlayer(@"d:\audio1.wav");
simplesound.Play();
}
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
![]() |
Similar Threads
- wx.media.MediaCtrl (Python)
- Playing a wav file (C#)
- media player in vb6 (Visual Basic 4 / 5 / 6)
- Microphone Not Working (USB Devices and other Peripherals)
- please how do i load sounds into visual basic (Visual Basic 4 / 5 / 6)
- Compression/Decompression Wave File to MP3 and Vice Versa (C++)
- How to convert wav to mp3 using VB? (Visual Basic 4 / 5 / 6)
- Please~~~ Need help including sound files in the form! (C#)
Other Threads in the C# Forum
- Previous Thread: how to create exe in .net which will install only once.
- Next Thread: curl for C#
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array bitmap box broadcast buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms ftp function gdi+ httpwebrequest image index install java label list listbox listener login mandelbrot math mouseclick mysql networking object operator oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation visualstudio webbrowser windows winforms wpf xml






