i have made a simple wav player in c# and here is my code
*******************************************
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;
using System.Media;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void next_Click(object sender, EventArgs e)
{
}
private void nnext_Click(object sender, EventArgs e)
{
}
private void playpause_Click(object sender, EventArgs e)
{
try
{
string sptbvs = sptb.Text;
SoundPlayer my_wave_file = new SoundPlayer(sptbvs);
my_wave_file.PlaySync();
}
catch (InvalidCastException)
{
MessageBox.Show("Error 502 :invalid Path.");
}
}
private void sptb_TextChanged(object sender, EventArgs e)
{
string sptbvs = sptb.Text;
}
private void before_Click(object sender, EventArgs e)
{
}
private void bbefore_Click(object sender, EventArgs e)
{
}
}
}
*********************************************
but when i click the play/pause button the song starts properly and after some seconds (usualy 4) it stops playing the song
why is this happening
please help