Issues when setting MediaPosition

Oct 11, 2009 at 5:00 PM

Hi,
first thank you for your library, it definitely works better than the existing WPF media player control, especially when dealing with codec issues.

Maybe it's just my fault, but I found that the latest release of your library has fixed the issue with playback under Win XP but it seems it has introduced a new one when positioning to a specific position in the media file. I have written a small user control wrapping your media control to be consumed in a MVVM application, where I have to arbitrarily move to a specific position during playback and/or to start from a specific position after loading a media file. This worked with the previous release, even if I had to resort to some tricks to do it, but it seems it does no more work with your latest release, where when I try to set the MediaPosition I get no error and apparently the value of the property is changed, but the player skips back to the absolute file beginning rather to the desired position. This happens only the 1st time I play a loaded media; if during play I try to skip ahead by N seconds (by setting MediaPosition in the same way) it works.

If anyone is interested I can upload somewhere a sample dummy application which just reproduces this issue; I found no way in codeplex for attaching files. The application is just a WPF application as created by VS2008: the unique window contains a user control which wraps an instance of MediaUriElement and adds some essential buttons for start/stop/play. The main window adds a button for opening a media file, a textbox to specify the start playback position, and another to skip backward or forward by N seconds (as typed in another textbox). As written above, these skip-button work, while the control seems to ignore the initial playback position (I can see the progress playback bar bump to the right for a second and then it's reset to the beginning; instead, in the previous release this worked).

Thanks to all in advance!

Coordinator
Oct 13, 2009 at 10:17 PM
Can you please provide a sample to my email?

  Email to jeremiah.morrill [at] gmail.  Gmail wont let you send it if it has any exe's or dlls in it, so just rename the .zip to .anything.
Oct 14, 2009 at 12:35 PM

Hi,

I tried the following

wpfMediaKitElement.BeginInit();
                        wpfMediaKitElement.Source = new Uri("SOME SOURCE");
                        wpfMediaKitElement.MediaPosition = POSITION_IN_SECONDS *DSHOW_ONE_SECOND_UNIT;
                        wpfMediaKitElement.EndInit();

The issue is that the mediaposition is first set to the desired position correctly but after endinit is called OnMediaPlayerOpened is fired in MediaSeekingElement and MediaPosition set to 0.

I commented that line and the whole thing works as expected.

When the media is opened and MediaPosition is not specified, it always starts at position 0. So, was there a reason to specifically set the position to 0.

Oct 14, 2009 at 6:23 PM

Hi all, I have not yet tried the proposed solution anyway I've just sent the test project by email to the specified address.

Thanks to all!