0

I have a axWindowsMediaPlayer on WinForm with uiMode=none. I am using my custom controls to handle playback. I am using this method to associate a trackBar with axWindowsMediaPlayer.

I want to change the video position (jump to specific time) when the user scrolls the trackBar, just like windows media player.

private void trackBar_Scroll(object sender, EventArgs e)
{
    if (axWindowsMediaPlayer.playState == WMPLib.WMPPlayState.wmppsPlaying)
    {
        axWindowsMediaPlayer.Ctlcontrols.currentPosition = trackBar.Value;
    }
}

This is not working. I have checked many Stackoverflow answers including this, this, and the Microsoft documentation but none is working.

I have two objectives:

  1. When playing media, the trackBar should show the current position of the media file being played. This is working fine.
  2. When the user scrolls the trackBar, the media player should change the video current position based on the trackBar value. This is not working.

Any help will be highly appreciated.

Raja Ayaz
  • 91
  • 12
  • When it is the user that moves the trackbar thumb (use a bool variable to see the difference) then you need to pause playback first. – Hans Passant Sep 26 '18 at 16:49

1 Answers1

0

I solved the issue. The problem was not with the media player, the problem was with the media files being played with the axWindowsMediaPlayer.

axWindowsMediaPlayer plays the files such as MKV fine, but if the proper codecs are not installed, the Ctlcontrols mainly the Trackbar does not work from code or UI. With natively supported formats, this code works perfectly fine.

private void trackBar_Scroll(object sender, EventArgs e)
{
    if (axWindowsMediaPlayer.playState == WMPLib.WMPPlayState.wmppsPlaying)
        axWindowsMediaPlayer.Ctlcontrols.currentPosition = trackBar.Value;      
}

For media files not natively supported, their codecs need to be installed. For details of supported file formats, see this KB article File types supported by Windows Media Player

Raja Ayaz
  • 91
  • 12