-1

I am creating a c# winform application to play video, what i want is to pause the player and prevent that to stop after media ending:

private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
    {
        if (e.newState == 8)//media ended
        {
            //To pause and prevent stop.
        }
    }

I tested some things:

if (e.newState == 8)
        {
            axWindowsMediaPlayer1.Ctlcontrols.pause();
        }

but after this player automatically goes to stop. after this test:

if (e.newState == 8)
        {
            axWindowsMediaPlayer1.Ctlcontrols.pause();
            Thread.CurrentThread.Join(5000);
        }

The player pauses and wait for 5 seconds then stop! Do you have a solution for this? Thanks.

Farzin
  • 3
  • 3

1 Answers1

0

Try:

    private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
    {
        if (e.newState == 1)
        {
            axWindowsMediaPlayer1.Ctlcontrols.currentPosition = axWindowsMediaPlayer1.currentMedia.duration - .001;
            axWindowsMediaPlayer1.Ctlcontrols.play();
            axWindowsMediaPlayer1.Ctlcontrols.pause();
        }
    }
Idle_Mind
  • 38,363
  • 3
  • 29
  • 40
  • After player stop (e.newState == 1) the currentPosition will be zero. I get the currentPosition with timing function when player is in playing state: if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPlaying) { currentPosition = axWindowsMediaPlayer1.Ctlcontrols.currentPosition; } – Farzin Oct 22 '15 at 17:31