Recent Resources
-
GLSL 4.0: Discarding Fragments to Create a Perf...
-
GLSL 4.0: Using Subroutines to Select Shader Fu...
-
Building a Complete Board-based Puzzle Game wit...
-
JIRA: Programming Workflows
-
.NET Generics 4.0: Container Patterns and Best...
-
Raw Meat: Game Design Tips from Team Meat's...
-
Sedge: An Automated Error Reporting Tool
Playing AVI Files with DirectX
By Gert Wollny | Published Sep 21 1999 02:27 PM in DirectX and XNA
Download attached article resource
Download attached article resource
General Information:
CAviSurface implements an interface to play a true- or high-color AVI file into a DirectDrawSurface. CAviSurfaceWithSound extends this to play the sound simultaneously into a streaming DirectSoundBuffer.
To use the classes you have to use DirectDraw in a 16-Bit or 24-Bit colormodus. 8-Bit Colordepth is currently not supported, neither as sourceformat nor as targetformat. This is partially due to the usually installed AVI - Decompressors and partially due to my own laziness.
To use the class you simply have to use the following codefrags:
CAviSurface(char *lpszFilename,LPDIRECTDRAW lpDDraw,BOOL bLoop=FALSE)
CAviSurfaceWithSound(char *lpszFilename,LPDIRECTDRAW lpDDraw,LPDIRECTSOUND lpDS,BOOL bLoop)
Files in the included archive:
Remember to run the program in an 16 or 24 bit colordepth environment, because it works in a window, and only supports the high/truecolor target.
To Do:
I don't promise that this software works and in no case I will be liable to any damage, this software does. (But if you find any bugs, please let me know!) You can use this software for whatever you want. You don't have to pay me. If you use it in a program, please credit me, send a postcard (or a copy of the program).
Gert Wollny
Henricistr. 29
04177 Leipzig
Germany
CAviSurface implements an interface to play a true- or high-color AVI file into a DirectDrawSurface. CAviSurfaceWithSound extends this to play the sound simultaneously into a streaming DirectSoundBuffer.
To use the classes you have to use DirectDraw in a 16-Bit or 24-Bit colormodus. 8-Bit Colordepth is currently not supported, neither as sourceformat nor as targetformat. This is partially due to the usually installed AVI - Decompressors and partially due to my own laziness.
To use the class you simply have to use the following codefrags:
- Construct the DirectDraw (and DirectSound) Interface.
- Call the constructor lpAviSurface = new CAviSurface (or CAviSurfaceWithSound)
- To start the playback, call lpAviSurface->Start(); // Sound begins to play when using CAviSurfaceWithSound
- In your general UpdateFrame-Method of the Application call lpAviSurface->BltTo(where.x,where.y,lpddsTargetSurface);
- Call lpAviSurface->Stop() to suspend playback, another call to lpAviSurface->Start() will contiue the playback.
- Destroy the Object with delete lpAviSurface;
CAviSurface(char *lpszFilename,LPDIRECTDRAW lpDDraw,BOOL bLoop=FALSE)
- Constructs a DirectDrawSurface, linked with an AVI-File
- Set a Keycolor (no Keyspace)
- Draws Videosurface to (left,upper) = (x,y) in Targetsurface
- Draws Videosurface to Targetrectangle in TargetSuface
- Starts Videoplayback into surface
- Stops the playback
CAviSurfaceWithSound(char *lpszFilename,LPDIRECTDRAW lpDDraw,LPDIRECTSOUND lpDS,BOOL bLoop)
- Opens the AVI-File lpszFilename and attaches it to a Directdrawsurface and a DirectSoundbuffer.
- bLoop specifys, if the AVI-File is played looping.
- Frees all the stuff
- Starts the soundplay and the videoplayback
- Stops the soundplay and the videoplayback
Files in the included archive:
- avisurface.cpp, avisurface.h - Implementation of the classes
- dderrmsg.cpp, dderrmsg.h - translates a DDraw errormessage into a text string
- standartmacros.h - exactly one macro (grin)
- videoexample.* MSDEV Projectfiles for the examplecode
- aboutbox.cpp, aboutbox.h - guess what it is
- ddframw.cpp, ddframw.h - the applications main window
- resources.h - the resource defines
- videoexample.exe - release build
- AVISurface.html - this file
Remember to run the program in an 16 or 24 bit colordepth environment, because it works in a window, and only supports the high/truecolor target.
To Do:
- I currently do not know how to interpret the value AVIStreamInfo.dwInitialFrames exactly, so there is a problem in the synchronization of the sound and the graphics in some AVI's.
- Adding support for 8-Bit and 32-Bit Colordepth. (I currently do not need this, so no time to do it)
I don't promise that this software works and in no case I will be liable to any damage, this software does. (But if you find any bugs, please let me know!) You can use this software for whatever you want. You don't have to pay me. If you use it in a program, please credit me, send a postcard (or a copy of the program).
Gert Wollny
Henricistr. 29
04177 Leipzig
Germany
Download attached article resource


















