using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Media;
using System.IO;

namespace PlaySound
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            #if DEBUG
                MinimizeBox = false;
            #else
                MinimizeBox = true;
            #endif
        }

        private SoundPlayer mediaSoundPlayer = new SoundPlayer();
        
        private void butPlayFromResource_Click(object sender, EventArgs e)
        {
            var memstream = new MemoryStream(Properties.Resources.tada);

            mediaSoundPlayer.Stream = memstream;
            mediaSoundPlayer.PlayLooping();
            memstream.Dispose();
        }

        private void butPlayFromFile_Click(object sender, EventArgs e)
        {
            string wavePath = @"\windows\Alarm2.wav";
            mediaSoundPlayer.SoundLocation = wavePath;
            mediaSoundPlayer.PlayLooping();
        }

        private void butStop_Click(object sender, EventArgs e)
        {
            mediaSoundPlayer.Stop();
        }
    }
}