Q: I'm trying to play a QuickTime 4 for Windows movie into my own DirectDraw surface. However, I cannot seem to get the QuickTime for Windows QTSetDDPrimarySurface function to draw to my surface properly. What do I need to do?
A: If you want QuickTime to use your DirectDraw object, you need to pass a flag to the QuickTime for Windows InitializeQTML function to prevent QuickTime from creating its own DirectDraw object, as follows:
InitializeQTML(kInitializeQTMLUseGDIFlag);
|
Keep in mind that QuickTime has 3 ways of talking to the screen: DirectDraw , DCI , and GDI . If DirectDraw doesn't work, QuickTime tries DCI , and if that doesn't work, QuickTime falls back to GDI . This decision making all occurs inside the InitializeQTML function.
Passing in the kInitializeQTMLUseGDIFlag flag forces QuickTime for Windows to not use DirectDraw or DCI (which is what you want). Then, when you later tell us about your DirectDraw object, we'll go ahead and use that, just like you wanted.
Here's a short code snippet that uses the InitializeQTML function as described above, along with the QuickTime for Windows utility functions to tell QuickTime to draw into a specific DirectDraw surface:
OSErr err;
LPDIRECTDRAWSURFACE4 theSurface4;
LPDIRECTDRAWSURFACE theSurface;
HRESULT ddResult;
/* Initialize QuickTime using the kInitializeQTMLUseGDIFlag flag so
QuickTime doesn't create its own DirectDraw object */
err = InitializeQTML(kInitializeQTMLUseGDIFlag);
if (err == noErr)
{
err = EnterMovies();
if (err == noErr)
{
/* now tell QuickTime to use our existing DirectDraw object */
err = QTSetDDObject(gDirectDrawObject);
if (err == noErr)
{
theSurface4 = gPrimarySurface;
if (theSurface4 != NULL)
{
/* get a plain old DIRECTDRAWSURFACE interface to our
primary surface, as this is the only interface that
QuickTime can currently handle. */
ddResult = theSurface4->QueryInterface(IID_IDirectDrawSurface,
(LPVOID *)&theSurface);
if (ddResult == DD_OK)
{
/* set QuickTime's primary surface */
err = QTSetDDPrimarySurface(theSurface, 0);
if (err == noErr)
{
/* release the DIRECTDRAWSURFACE interface */
theSurface->Release();
}
}
}
}
}
}
|
[Nov 01 1999]
|