Jump to content

MCI_SEEK

From EDM2

This message is sent to change the current media position of the device.

Syntax

param1
ULONG ulParam1; /* Message flags. */

param2
PMCI_SEEK_PARMS pParam2; /* Pointer to the MCI_SEEK_PARMS structure. */

Parameters

ulParam1 (ULONG) - input
The following flags can be used:
  • MCI_NOTIFY Posts a notification message when the action completes.
  • MCI_WAIT Does not return control until the action is completed.
  • MCI_TO Indicates that the ulTo field of the parameter structure specifies the destination position. If the position is beyond the end of the media, `MCIERR_OUTOFRANGE` is returned.
  • MCI_TO_START Seeks to the first playable position on the media (not necessarily position 0).
  • MCI_TO_END Seeks to the end of the media.
Digital Video Extensions
* MCI_TO_NEAREST_IFRAME Seeks to the nearest I-frame preceding the point specified by `MCI_TO`.
Videodisc Extensions
* MCI_VD_SEEK_REVERSE Initiates a seek backward.
pParam2 (PMCI_SEEK_PARMS) - input
A pointer to the MCI_SEEK_PARMS structure.

Returns

rc (ULONG) - returns
  • MCIERR_SUCCESS Command completed successfully.
  • MCIERR_INVALID_DEVICE_ID Invalid device ID given.
  • MCIERR_INSTANCE_INACTIVE The device is currently inactive. Use MCI_ACQUIREDEVICE.
  • MCIERR_FILE_NOT_FOUND File has not been loaded.
  • MCIERR_HARDWARE Device hardware error.
  • MCIERR_OUTOFRANGE The specified position is out of range.

Remarks

The values for the `MCI_TO` parameter must be specified in the currently selected time format (see MCI_SET).

The following example illustrates how the `MCI_TO` parameter is interpreted: If a file has 100 samples (numbered 0 to 99):

  • If `MCI_TO` is 0, the media is at the start. Issuing MCI_PLAY plays from sample 0.
  • If `MCI_TO` is 99, the media is before the last sample. MCI_PLAY plays the last sample.
  • Specifying `MCI_TO_END` positions the media at 100. MCI_PLAY would return success without playing anything.

Example Code

The following code illustrates how to seek to the beginning of the playable media for a device.

    USHORT           usDeviceID;
    MCI_SEEK_PARMS   mseekp;

    /* Seek the device to the beginning */

    /* Assign hwndCallback the handle to the PM Window */
    mseekp.hwndCallback = hwndMyWindow;

    mciSendCommand( usDeviceID,               /* Device ID                */
     MCI_SEEK,                                /* MCI seek message         */
     MCI_NOTIFY | MCI_TO_START,               /* Flags for this message   */
     (PVOID) &mseekp,                         /* Data structure           */
     0);                                      /* No user parm             */

Related Messages