button to play wav file

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2008
Posts: 4
Reputation: Siten0308 is an unknown quantity at this point 
Solved Threads: 0
Siten0308 Siten0308 is offline Offline
Newbie Poster

button to play wav file

 
0
  #1
Jun 18th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 2
Reputation: lizjaja is an unknown quantity at this point 
Solved Threads: 0
lizjaja lizjaja is offline Offline
Newbie Poster

Re: button to play wav file

 
0
  #2
Jun 19th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 4
Reputation: Siten0308 is an unknown quantity at this point 
Solved Threads: 0
Siten0308 Siten0308 is offline Offline
Newbie Poster

Re: button to play wav file

 
0
  #3
Jun 19th, 2008
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();
}
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: button to play wav file

 
0
  #4
Jun 19th, 2008
Originally Posted by Siten0308 View Post
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 to share the answer and don't forget to mark this thread solved to make it easy to find.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC