Please enable JavaScript to view this site.

KOL/MCK - User Guide

Initially, this object was in the main composition of KOL, but later it was moved to a separate module. The main reason for this decision was to reduce the dependence of applications on the MMSystem module, which contains the necessary definitions and is not required by most applications. Functionally, the TMediaPlayer object from this module is not much different from the component with which you may have happened in the VCL. But in KOL it is not visual, and does not automatically provide buttons to control the process of playing music or video. Since the object uses MCI (Media Control Interface) commands, using this object it is possible to play any media file for which all the necessary drivers and decoders (codecs) are installed in the system.

 

The basic procedure for working with this object is as follows. It is created by the constructor:

NewMediaPlayer(filename, wnd) - the optional parameter file (can be an empty string) specifies the file to be played, the wnd parameter (it can also be zero for sound files) passes the object's constructor a handle to the window in which the video image will be played.

 

 

High-level properties and methods:

 

Display - window descriptor for displaying video images;

DisplayRect - rectangle in the Display window for the image;

Width, Height - return the own width and height of the open video file;

Filename - allows you to change the name of the file for playback;

DeviceType - returns the type of the open file, it is not necessary to set it, since in the case of a file the system itself is able to determine the data format;

DeviceID - returns the logical device identifier, which can be used in low-level commands;

TimeFormat - sets the time format for operating with the length and position in the stream being played (milliseconds, bytes, frames - for video, samples - for sound, as well as some formatted values, see the text and system documentation for more details);

Length - returns the length of the file (in units specified by the TimeFormat property);

Position - the current position in the file or on the device (it can be changed if the device contains several tracks; to get the starting position of the track, use the TrackStartPosition property);

TrackCount - number of tracks, for devices with multiple tracks;

Track - number of the current track (from 1 to TrackCount);

TrackStartPosition - returns the start position of the current track on the device;

TrackLength - the length of the current track;

Error - error code (if there are no errors, contains 0);

ErrorMessage - text describing the error;

State - the current state of the device (not ready, stopped, playing, recording, searching or rewinding, etc.);

Wait- set this property to TRUE to perform all operations with synchronization (i.e., return from any command will occur only upon completion of this operation). By default, all operations are performed asynchronously, that is, the command is passed to the system for execution, after which control is returned to your code;

OnNotify - this event is triggered when the previous asynchronous operation completes;

Open- method for opening the file specified by the Filename property. If, when creating an object, the Filename parameter pointed to an existing file, then the Open method is called for it automatically;

Alias- a string that, after opening a file, can be used in MCI commands as a device alias. Should be installed before opening the media file and before changing the file name;

Play(start, length) - starts playback of an open file from the specified position, the length parameter sets the portion to play. As the length parameter, you can specify the special value –1, which means that the file will be played until the end of the file. For the start parameter it is also possible to specify a value of –1, which means "from the current position";

StartRecording(FromPos, ToPos) - starts recording on the recorder. Similar to the Play method, the special value –1 can also be used for both parameters, with the same semantic meaning;

Pause - returns TRUE if the device is suspended, it can also be used to programmatically suspend the device by assigning the TRUE value;

Stop - stops playback or recording;

Close - this method closes the device (but does not necessarily stop playback! To stop, you must first put the device in the “pause” or “stopped” state);

Ready - TRUE if the device is “ready” (start recording or playback);

Eject - ejects the media from the device, if such a command is provided for it (for example, for CDAudio);

DoorClose - inverse operation with respect to Eject. The peculiarity of this operation is that an automatic play or open operation can be performed for the media, if this setting is not disabled in the operating system. To prevent auto-opening, use the Insert operation;

Insert - similar to DoorClose, but automatic playback does not work;

Present - Returns TRUE if media is inserted into the device.

 

Next, I will skip a number of low-level properties and methods, I will only say that they allow you to get more detailed information depending on the type of device and media, control the on and off of individual channels, sound volume, and so on. I will dwell only on the lowest-level commands that allow you to send commands directly to the MCI system:

SendCommand(cmd, flags, buffer) - allows you to send a low-level command to the device, passing, if necessary, some parameters through the buffer, for example.

There is also a version of this method, asmSendCommand, which is executed with a deliberate violation of standard communication conventions (it is used in the object implementation itself, so it was convenient to do this for some code optimization).

In addition, you can always use the mciSendCommand and mciSendString API functions directly, passing the DeviceID or Device Alias, respectively, as a parameter identifying the device.

 

You can download the KOLMediaPlayer module here: https://www.artwerp.be/kol/kolmediaplayer.zip

 

KOL / MCK User Guide - Created by Carl Peeraer - Diamant Soft, based on the work of Vladimir Kladov - Artwerp.be

  

Keyboard Navigation

F7 for caret browsing
Hold ALT and press letter

This Info: ALT+q
Nav Header: ALT+n
Page Header: ALT+h
Topic Header: ALT+t
Topic Body: ALT+b
Exit Menu/Up: ESC