1

I am currently working with WmpLib.WindowsMediaPlayer () but when I click on play after clicking pause the music starts again at the beginning instead of continuing and I do not understand why.

Could someone explain to me?

private void play_Click(object sender, EventArgs e)
    {
        player = new WMPLib.WindowsMediaPlayer();
        player.URL = SoundFilePath;
        player.controls.play();
    }


private void pause_Click(object sender, EventArgs e)
   {
       player.controls.pause();
   }
Lennart
  • 9,657
  • 16
  • 68
  • 84
gggkg
  • 3
  • 6
  • It starts back at the start of the song because the code creates a complete new instance of WMP *and* assigns the URL again. Don't do that, you need to know to skip these things when you click Play again. Use a variable named, say, *Paused" and set it to true in your Pause event handler. Only ever create the WindowsMediaPlayer once, it is an expensive mother, consider the constructor of your form. – Hans Passant Aug 01 '18 at 10:20
  • I've created new instance before play() function but no positive response. – gggkg Aug 01 '18 at 12:35

0 Answers0