Search code examples
c#wpfmedia-playermediaplayback

Media player fast forward


I have spent a great deal of time searching, and with all different key phrases. I am working on a Media Player and have a menu strip with an option to fast forward and reverse. Here is what I have currently:

private void increaseRateToolStripMenuItem_Click(object sender, System.EventArgs e)
{
    if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPlaying)
    {
        WMPLib.IWMPControls3 controls = (WMPLib.IWMPControls3)axWindowsMediaPlayer1.Ctlcontrols;
        if (controls.get_isAvailable("fastForward"))
        {
            controls.fastForward();
        }
    }
}

Which essentially is the circle that I have been going around. I started here, tinkered, and then ended up back here. It is driving me crazy. In theory it sounds so simple, but I am getting nothing.

The example I used above was off of the MSDN example here: http://msdn.microsoft.com/en-us/library/windows/desktop/dd564741(v=vs.85).aspx

So I am here asking, how can I fast forward (and reverse) the video when the menu item is clicked in C#?


Solution

  • This is an extension from my answer on this related question.

    According to the OP over there (see comments on my answer) this would work if you're playing an MP4 file, but if you're trying to play an AVI it won't work as they're not indexed. He instead suggested that you increment the currentPosition property (MSDN documentation) to achieve this effect.

    So to summarise, instead of controls.fastForward(), try controls.currentPosition += someIncrement in a loop of some sort (perhaps this question might help you achieve this: C# how to loop while mouse button is held down)