I'm using the (managed) Microsoft.DirectX.AudioVideoPlayback namespace
to program an app where I want to quickly swap the video that is being
displayed, playing the new video from the position where the old one
left off. Here's a sample of the relevant code:
// when this code is executed the current video
// is happily playing
current.Pause();
double pos = current.CurrentPosition;
current.Ending -= endHandler;
current = nextVideo; // next video has already been loaded
current.Ending += endHandler;
current.CurrentPosition = pos;
current.Owner = this.DisplayBox;
current.Play();
The problem is there is a brief black interval before the next video
starts playing. Because the interval is longer the further into the
video that the swap happens, I'm assuming that this has to do with the
codec getting the information ready. Problem is, I can't figure out any
way to force the codec to do this before I start playing, thereby
avoiding the black screen.
I've tried:
1- using Pause() or Play() before setting the Owner. Unfortunately this
opens a second display window.
2- Creating a second invisible PictureBox and assigning this as the
Owner. Then setting CurrentPosition and Pauseing. Then making it Visible
and Playing. The black interval still happens. Seems the Codec won't do
any decoding until it's actual got a surface to render to? (The video is
in DivX, processed with VirtualDub)
3 - Using SeekCurrentPosition(pos, IncrementalPositioning) instead of an
assignment to CurrentPosition. This didn't work at all, the video did
not play from the correct point.
Does anyone have any suggestions to try? Has anyone else solved this
problem?
Dave