Sample Multimedia Classes

Two of the classes (SoundPlayer and VideoFrame) and in the Visual FoxPro Samples\Classes\Samples.vcx class library allow you to use the MCI (Multimedia Command Interface) to play multimedia files.

The documentation for the MCI commands is in Chapter 7 of the Windows SDK Multimedia Programmer's Reference.

Sound Player Class

This class can be used to play a non-visual multimedia file, such as a .WAV audio file. It allows you to specify the file to be played, and then provides built-in methods to easily play the media file.

Property Description
AutoOpen Specifies whether the sound file should be automatically opened and displayed when the object is instantiated. The default value is true (.T.).
AutoPlay Specifies whether the sound file should be automatically played when it is opened. The default value is true (.T.).
AutoRepeat Specifies whether the sound file plays continuously.  The default value is false (.F.).
ControlSource Specifies the column that contains the sound file reference. If empty, the class expects a static file name to be in the SoundFile property.
MCIAlias Specifies the alias to be used by MCI. If left empty, the alias defaults to the Name property of the class.  Normally this can be left empty, but if the user wants to play the same sound file twice at the same time, a different alias would need to be specified for each.
SoundFile Holds the name of a sound file to play, for example “C:\WINDOWS\CHIMES.WAV

Method Description
OpenSound Opens the sound file.
PlaySound Plays the sound file. The file must be opened with the OpenSound method before it can be played.
PauseSound Pauses the playing of a sound file. Play can be continued by calling the PlaySound method.
SetPosition Allows the user to specify the position of the media file.  It can be executed at any time after the file has been opened.  Valid values are "Start," "End," or a specific millisecond into the sound.
CloseSound Closes the sound file and releases all resources associated with it.

VideoFrame Class

The VideoFrame class can be used to play a visual multimedia file, such as a video for Windows file. This class allows you to position and size the video to be played, and then provides built-in methods to easily play the media file.

For an example of using this class, see Video.scx in the Visual FoxPro Samples\Solution\Forms folder.

Property Description
AutoOpen Specifies whether the video file should automatically opened and displayed when the object is instantiated.  The default value is true (.T.).
AutoPlay Specifies whether the video file should automatically play when it is opened. The default value is true (.T.).
AutoRepeat Specifies whether the video file will loop the video.  Setting this to .T. will cause the video to play continuously. The default value is false (.F.).
ControlSource Specifies a Field that contains the video file reference.  If empty, the class expects a static file name to be in the VideoFile property.
MCIalias Specifies the alias to be used by MCI. If left empty, the alias defaults to the Name property of the class.  Normally this can be left empty, but if the user wants to play the same video file twice at the same time, a different alias would need to be specified for each.
VideoFile Holds the name of a video file to play, for example:  "C:\VFP\SAMPLES\SOLUTION\FORMS\FOX.AVI"

Method Description
CloseVideo Closes the video file and releases all resources associated with it.
DoMCI Called by the other methods to execute MCI commands.  It can also be called by a user to execute a specific MCI command.
OpenVideo Opens the video file and shows the first frame.
PauseVideo Pauses a playing video.  The video can be restarted by using the PlayVideo method
PlayVideo Plays the video file.  The video file must be opened in the OpenVideo method before it can be played.
SetPosition Allows the user to specify the position of the media file.  It can be executed at any time after the video file has been opened.  Valid values are "Start", "End", or a specific millisecond into the video.