Video Seek (MediaPosition) doesnt work for online videos

Mar 16, 2015 at 8:53 PM
Edited Mar 16, 2015 at 9:14 PM
I tested the MediaPosition property using MediaUriElement to change the video position with a local video, it worked fine. But when I try with a video on the web, the video plays without problem, but changing the MediaPosition property cause the video to freeze instead of changing the position. I even tried to call play/pause before/after changing it but no effect. Also looks like it doesnt have any "Buffering" event, so I cant even know if it is buffering or just idle.

Anyone had this issue already? There is a workaround to this?

Edit: btw changing position on online videos works fine on WPF MediaElement.
Edit 2: After further testing, looks like it's pretty random, the seek worked once but stopped to work again, also after the video freeze, even if I load another video (change Source) and call Play it remains frozen.
Mar 17, 2015 at 2:19 PM
What protocol is your online video?

If it is HTTP (i.e. URL of http://.....), then it is streamed over to the player. Any buffering needs to be done by the player. MediaUriElement is based on DirectShow, so you'll need to see if your DirectShow setup allows for buffering streams.

Many web servers may not support seeking to a position in the URL or downloading just a portion of a URL. So I guess if you try to seek forward, the player is just downloading the video and hangs until it reaches the point you're seeking. If you try to seek backwards, it should (theoretically) just replay from its buffer -- if the buffer is large enough. How much video it keeps depends on the source filter -- I know some source filters will buffer the entire video file in the temp folder, and some source filters just stream without buffering.

WPF MediaElement may be more intelligent than DirectShow...
Mar 17, 2015 at 7:58 PM
Thanks, actually it's HTTPS. WPF MediaElement have a bug that make it unable to play SSL streams, and Microsoft is not going to fix it for now, so this made me move to MediaKit. Seeking backward give the same problem too - video freeze. This web server does allow seeking, in Windows Media Player for example the very same URL works fine with seeking. So I guess Ill play around with DirectShow settings.
Mar 19, 2015 at 6:58 AM
I am not a pro on this, but I understand there are advanced HTTP protocols that support seeking to a certain position in the stream. Maybe Media Player uses it. I doubt the standard FileAsync DirectShow filter will support something like this though.

You may want to try out other source filters, e.g. Haali or LAV or something, to see if any of them support what you need.

Use GraphStudio or something similar to load the source, render the graph and test the seeking. If you can't even get it to work with raw DirectShow, WPF MediaKit is not going to help you any here.
  • Stephen