Well, as promised, here's some information I have compiled and discovered about MPEG playback in Director. The following scripts work with both the Reel Magic Cards and the MP400 from Creative Labs, and should work with every card that follows the Microsoft guidelines for MPEG playback under Windows. PLEASE contact me if you discover that these scripts work (or not) with other decoders, so we can compile information about them. The part of this code that gets the handler to the stage is copied from the MPEG playback example provided by Macromedia with the DLLGlue XObject. Please notice that this code works for me and should work for you, but use it on your own risk. The DLLGLUE XObject is a very powerful one and calls directly to the Windows API, and MCI controls hang or crash or system if called wrongly, so YOU HAVE BENN WARNED!!!!
THERE IS AN INCOMPATIBILITY BETWEEN VERSIONS 2.10 - 2.20 OF THE REAL MAGIC DRIVERS AND QUICKTIME FOR WINDOWS VERSION 2.0 - 2.01. IF YOU CAN'T GET V 2.21 PLEASE DELETE THE FILE REALMAGC.QTC FROM YOUR WINDOWS/SYSTEM DIRECTORY.
on startMovie
global gcursor
global gWindowHandle
openXLib the pathname&"DLLGLUE"
put dllglue(mNew, "USER.EXE", "GetActiveWindow", "W", "V") into gWindowHandle
if NOT objectP(gWindowHandle) then
alert "Windows has returned an error. Cancelling execution"
quit
end if
end
on openmpeg mpegfile mpeglocation
global gWindowHandle
put gWindowHandle(mWindowHandle) into hwnd
if (gWindowHandle (mStatus))<>0 then
alert "Error. Cancelling execution"
quit
end if
mci("open"&&the pathname&mpegfile&&"alias clip style child parent"&&hwnd)
-- "clip" is the alias I'm using to refer to the open mpeg file. You can
-- use other word.
mci("put clip window at"&&mpeglocation)
mci("window clip state hide")
mci("setvideo clip key index to 253")
-- 253 is the index of the color that is to be used for chromakey.
-- IMPORTANT! Color 0 is the LAST
-- of the palette, and color 255 is the first, so count backwards....
end
on closempeg
mci("close clip")
end
on pausempeg
mci("pause clip")
end
on plaympeg
mci("play clip")
end
on restartmpeg
mci("play clip from 0")
end
on stopMovie
global gWindowHandle
mci("close clip")
if objectP(gWindowHandle) then gWindowHandle(mDispose)
closeXLib the pathname & "DLLGLUE"
end
OPENMPEG(mpegfile,mpeglocation)In this example, the mpeg file is supposed to be in the same directory as the projector. mpeglocation is a string of four number that defines the position of the MPEG Window. The first two numbers define the top left corner of the window, and the other two define the window size.
Example:
on mouseDown
openmpeg("test.mpg","0 0 320 240")
end
This will open the file and prepare it to play. You should open
the file in a frame and then go to another frame to begin
playing it. In this 'playing' frame you should place a shape
filled with the color you've defined as the key color, so the
video will appear without flashes. You can even use a transition
to reveal the shape!!! To begin playing the file, use
on enterFrame PLAYMPEG endDon't forget to add a (on exitframe go to the frame end) script to keep the playback head from moving. or you can keep it moving and key animations over the video... cool!! If you want more control, you can assign the following handlers to buttons, to pause, resume, close and restart the movie. (Resuming a paused video is accomplished using the PLAYMPEG command).
PAUSEMPEG CLOSEMPEG RESTARTMPEGThanks to our chroma-key approach, all this operations will (hopefully!!) occur without flashes and cleanly. To close the movie, first move to another frame that doen't contains any keyable areas, and then issue the closempeg handler.