DQBplayFLI
FUNCTION

Prototype

DECLARE FUNCTION DQBplayFLI (FileName AS STRING, BufLayer AS INTEGER, KeyStop
                             AS INTEGER, LoopFlag AS INTEGER)

Parameters

FileName - FLI file name

BufLayer - Layer to be used for double buffering

KeyStop - Scancode of the stop key

LoopFlag - Flag for animation looping

Returns

> 0 Operation successful > 1 Not enough free base memory > 2 Cannot open file or file does not exist > 3 General file reading error > 4 Bad or unknown file format

Description

Plays a whole animation from a specified FLI file; actually, FLC files are not supported. The file can be played using a double buffer, to achieve flickerless animations: using this feature requires an additional existing layer number to be specified into the "BufLayer" parameter; this layer can be in EMS as well as in conventional memory. If you tell the function to use the VIDEO as the needed layer, the animation will be decoded directly onto the screen, avoiding the double buffering. On fast computers this will look almost the same as if the buffer is used, but on older machines it is recommended that you always use buffered decoding. The animation can be looped, and you can also specify a key to stop it at any time and return the execution to your program. By specifying KEYANY as "KeyStop" parameter, the player will stop once any key is pressed; if you don't want to allow the user to stop an animation, pass NONE as this parameter. The use of the stop key feature requires that the DirectQB keyboard handler has been previously installed, otherwise the function will ignore any keyboard strokes. The last parameter tells DQBplayFLI whenever to loop the animation once the last frame is reached; you can use the ONCE and LOOPED constants here. To avoid infinite loops, if you want to play a looped animation you must also specify a stop key, and therefore you must first install the keyboard handler. If no stop key is defined, and you try to play an animation with looping, it'll be played as if the ONCE mode was selected.

Notes:

Other than the layer used for double buffering, this function also requires 64K of free conventional memory for fast decoding purposes. As always, you should call SETMEM to free some memory from the QB far heap, so that DQB functions can use it. If you're also using a blender map, and you don't have so much free base mem, you may want to call DQBremoveBmap before calling DQBplayFLI, and then reallocate it after the animation ends; this way only 64K of memory are required. If you want to have more control over the animation (like adding text over each frame before showing it, or changing the playback speed), you can use the DQBopenFLI, DQBplayFLIstep and DQBcloseFLI functions; check them out!

Example

*****************************************************************************

' All integers for speed
DEFINT A-Z

'$INCLUDE:'DIRECTQB.BI'

' Let's initialize the library with one extra layer and no sounds nor EMS
IF DQBinit(1, 0, 0) THEN DQBclose: PRINT DQBerror$: END

' Prompts the user for the FLI file name
INPUT "Enter full FLI file name (hit enter to quit): ", FileName$

' Switches to VGA mode
DQBinitVGA

' Installs the keyboard handler
DQBinstallKeyboard

' Frees 64K of memory for animation decoding
dummy& = SETMEM(-66000)

IF FileName$ <> "" THEN

  ' Plays looped animation, using layer 1 for double buffering
  IF DQBplayFLI(FileName$, 1, KEYANY, LOOPED) THEN
    ' An error has occured
    DQBclose
    PRINT DQBerror$
    dummy& = SETMEM(66000)
    END

  END IF

END IF

' The animation stops whenever the user press any key
DQBclose
dummy& = SETMEM(66000)
END

*****************************************************************************