How to get IMediaControl.Run () to run a file without delay

I am trying to use DirectShow to play two AVI files at the same time (one after another) so as not to interrupt the sound or video when the player moves from one file to another.

I have two user controls in my form. Each of them was preloaded with an AVI file, and before starting playback, I configured all DirectShow interfaces, installed video windows and resized them, called IMediaControl.Run (), then IMediaControl.Pause (), then IMediaSeeking.SetPositions to reset for frame 0, to both controls. In the form, you can see that both files are paused in the source frames.

Then I call IMediaControl.Run () on the first control and wait for it to complete before calling Run () on the second control. First, I connected to the first video ad EC_COMPLETE and used it to run the second. Thinking that this event may be slow to arrive (it turns out that it exists, but for some strange reason), I tried two more approaches:

  • Check the first current video position in the timer, which turns off every second or so (using IMediaPosition.get_CurrentPosition). When the current position is within a second of the video stop time (known in advance from IMediaPosition.get_StopTime), I go into a closed loop whileand wait until the current position is equal to the stop time, and then call Run () on the second video.
  • The same as the first, except that I replace the loop with a whilecall timeSetEventfrom winmm.dll, with a delay set so that it works when the first file should be completed. I use callback to run () the second file.

Any of these two methods significantly reduces the delay between the end of the first file and the beginning of the second, indicating that the EC_COMPLETE message does not arrive immediately after the file ends (I also tried to connect the EC_SEGMENT_COMPLETE message, which is supposed to be used to write to the file, but, by - apparently, no one supports this - it never occurs on my machine, at least).

, ; , , , .

- , . ( ), IMediaControl.Run() .

- -, , ? , , . Windows, , .

: AVI, , ( ), , , DirectShow ( ). , , , , .

, , ; , , BringToFront , . , - , , , .

: 30-50 "", , , , , Run() . , , , .

: , , AVI , . , , . IMediaControl RenderFile(), RenderStream RenderMemory.

+3
1

IMediaControl:: Run , ( ). . , , GetState() S_OK, , . 10 "" . , Run, dshow , , , , .

, , . ( ) IMediaFilter GetSyncSource SetSyncSource . , . , IMediaFilter:: Run IMediaControl:: Run, . , ( ).

- . , . www.gdcl.co.uk/gmfbridge.

+8

Source: https://habr.com/ru/post/1737520/


All Articles