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

Recommended Answers

All 3 Replies

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:)

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();          
        }

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.

thanks to share the answer and don't forget to mark this thread solved to make it easy to find.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.