Assume you want to toggle Play and Pause using button. In case of URL not set then only you need to set one. so you can check URL first as below
if(!string.IsNullOrEmpty(axWindowsMediaPlayer1.URL)
{
}else
{
}
if you already have URL set then your video may be paused then you need to play it otherwise you need to paused it
if(axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPaused){
axWindowsMediaPlayer1.Ctlcontrols.play();
}else{
axWindowsMediaPlayer1.Ctlcontrols.pause();
}
full code:
private void button3_Click(object sender, EventArgs e)
{
if(!string.IsNullOrEmpty(axWindowsMediaPlayer1.URL)
{
if(axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPaused){
axWindowsMediaPlayer1.Ctlcontrols.play();
}else{
axWindowsMediaPlayer1.Ctlcontrols.pause();
}
}else
{
axWindowsMediaPlayer1.URL = mediaList[listBox1.SelectedIndex];
axWindowsMediaPlayer1.Ctlcontrols.play();
}
}