How to play sound in C#

2 Answers

0 votes
using System.Media;

namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SoundPlayer player = new SoundPlayer("song.wav");
            player.Load();
            player.PlayLooping();
        }
    }
}




/*
 * run:
 *
 *
 * 
 */

 



answered Aug 28, 2023 by avibootz
0 votes
using System.Media;

namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SoundPlayer player = new SoundPlayer("song.wav");
            player.Play();
        }
    }
}




/*
 * run:
 *
 *
 * 
 */

 



answered Aug 28, 2023 by avibootz

Related questions

...