I need to implement Pause and Resume events of a MP3 player inside the same button click event. following is the code i have tried and its not working,Can any one give me the solution
private void button3_Click(object sender, EventArgs e)
{
if (button3.Text == "Pause")
{
CommandString = "pause mp3file";
mciSendString(CommandString, null, 0, 0);
Status = true;
button3.Text = "Resume";
}
if (button3.Text == "Resume")
{
CommandString = "resume mp3file";
mciSendString(CommandString, null, 0, 0);
}
}
You are changing the button3.Text property within the first if statement.
When the second if statement is tested it is true (both if statements are running with each button click when the Text property is “Pause”)
Use if, else to run one code block or another.
Use if, else if statements if you want a test to be run on the second code block also.
You should also take account of the possibility that neither of these cases is true.