I am trying to play an AVI file from the beginning up to a set time. I have tried IMediaPosition.put_StopTime() but it has no effect and no error is generated. The entire video will play. I can use IMediaPosition.put_CurrentPosition() to play the end part of a clip, without any problem, so I am perplexed that put_StopTime() doesn't work. Could I be overlooking something or is there a different interface that I should be trying?
Without having tried it (at least in a long time), I'd be thinking:
1) Stoptime is specified in seconds, not some fraction of a second like a lot of other DS interfaces.
2) Stoptime is relative to the start of the stream. If you set starttime to 5 seconds and stoptime to 6 seconds, you (should) get the 6 seconds starting at 5 seconds, not just 1 second as you might expect.
3) Since the function works on stream time, if you have disabled the clock for the graph, this function may not work.
That's off the top of my head. You might experiment with get_CurrentPosition to make sure it is returning values you expect. If it is, perhaps a timer event will get you what you need.
The particular clip that I am testing is 3.7 seconds long. I try to set the stop position to 2 seconds and start position to zero. I would think that would play the first two seconds of the clip. Immediately after setting the stop position, I call get_StopTime() and it returns 3.7, which is the duration of the clip. So, obviously the call to set_StopTime() is not working. It is strange that I can play just the last part of a clip, but not just the first part.
I doubt that I disabled the clock. I'll have to dig back through my code.
Well, those were the easy guesses. Always check those first. It's weird that set_StopTime fails without returning any error. Our testsuite suggests that it works (at least in some cases). You are calling this after you completely build the graph but before you start running, right?
Looking at the docs, it says "Applications should use IMediaSeeking instead of IMediaPosition." So you might try SetPosition and see if that works any better. Note that it uses different units to specify times than StopTime().
Also, you are getting these interfaces from the graph, not the filter, right?
You can run your graph as normal and use IMediaEvent.WaitForCompletion with a timeout corresponding to your end time and right after call IMediaControl.Stop.
Ugly but sould works...
Please I need to knoe How to play Existing Video File into panel not in windows media player
@Mariam Louis - Maybe you should start a new thread instead of hijacking this one;-)
Sorry I have started a new thread but I need your help How have you play an AVI file