Play an AVI file in a Progress window

It can be attractive to play an animation, for example while the user has to wait while your application communicates with the AppServer.
The source in this example uses some of the MCI series of API commands, making it possible to use this source on a window or on a dialog, and making it possible to play AVI's with or without soundtrack!

The complete example source (aviwin.w) is attached. It is a UIB-generated window (not SmartWindow) so the source is a bit too large to show on this page.

The source relies on the availablity of windows.i and windows.p, timestamp Sep 8, 1997 or later.

The window contains two buttons: button-open and button-stop.

Button-open is used to open (and play) an AVI file, button-close calls the procedure to stop (and close) the AVI file. The AVI file repeats infinitely and has a low priority in order to perform other Progress tasks, like FOR EACH processing in the meantime.
Normally you won't offer your users these buttons, they are here for demonstration purposes only.

The window also contains a frame (frame fdisplay): this will be the target window where the AVI output will be shown. It does not have to be a frame: you might also play the AVI on a button...

The AVI file is not opened in shared mode, so if you forget to Close the AVI-player you won't be able to open the AVI file again!
This makes it extremely important to run the 'close' procedure when the AVI is not needed anymore: you must never close the window without closing the AVI first! This is implemented by 'run PlayerClose' after the mainblock's 'WAIT-FOR' loop. If you use this code in a SmartObject you should run PlayerClose in local-destroy or somewhere around there.

Attachments : download source example