Search code examples
vb6directshow

Using DirectShow IMediaEvent.GetEvent from VB6


I know I'm traveling back in time but I really do need VB6 assistance (-:

I'm trying to seamlessly loop a video using DirectShow as documented for VB6 at this link. Since there is no internal Loop implementation I'm looking for completion and seeking back to position 0.

To see completion I've set up an event handler using IMediaEvent.SetNotifyWindow. As I understand it, when this event pops I must loop through all queued events using .GetEvent until the event queue is empty, checking for the event of interest (EC_COMPLETE or EC_END_OF_SEGMENT).

But I have no idea when the event queue is empty. The docs seem to imply that .GetEvent will return an error code when this happens but according to the VB6 properties viewer .GetEvent is a Sub (a void function) so it isn't capable of returning error codes.

What to do? How else might this work?


Solution

  • Your understanding is correct. C++ GetEvent returns E_ABORT for empty queue and this is what you are supposed to see to end trying fetching the events.

    In VB6 the error should get converted to VB6 runtime error. So you don't see the return value (Sub) and you should be ready to - typically with zero timeout - handle the error (On Error Goto..., I suppose):

    If no event is on the queue, this method waits up to msTimeout milliseconds for one to arrive. If the time-out expires, the method raises run-time error 287.