Edit

Share via


play command

The play command starts playing a device. CD audio, digital-video, MIDI sequencer, videodisc, VCR, and waveform-audio devices recognize this command.

To send this command, call the mciSendString function with the lpszCommand parameter set as follows.

_stprintf_s(
  lpszCommand, 
  TEXT("play %s %s %s"), 
  lpszDeviceID, 
  lpszPlayFlags, 
  lpszFlags
); 

Parameters

lpszDeviceID

Identifier of an MCI device. This identifier or alias is assigned when the device is opened.

lpszPlayFlags

Flag for playing a device. The following table lists device types that recognize the play command and the flags used by each type.

Value Meaning Meaning
cdaudio from position to position
digitalvideo from positionfullscreen repeat reverse to positionwindow
sequencer from position to position
vcr at timefrom positionreverse scan to position
videodisc fast from positionreverse scan slow speed integerto position
waveaudio from position to position

The following table lists the flags that can be specified in the lpszPlayFlags parameter and their meanings.

Value Meaning
at time Indicates when the device should begin performing this command, or, if the device has been cued, when the cued command begins. For more information, see the cue command.
fast Indicates that the device should play faster than normal. To determine the exact speed on a videodisc player, use the "speed" flag of the status command. To specify the speed more precisely, use the "speed" flag of this command.
from position Specifies a starting position for the playback. If the "from" flag is not specified, playback begins at the current position. For cdaudio devices, if the "from" position is greater than the end position of the disc, or if the "from" position is greater than the "to" position, the driver returns an error. For videodisc devices, the default positions are in frames for CAV discs and in hours, minutes, and seconds for CLV discs.
fullscreen Specifies that a full-screen display should be used. Use this flag only when playing compressed files. (Uncompressed files won't play full-screen.)
repeat Specifies that playback should restart when the end of the content is reached.
reverse Specifies that the play direction is backward. You cannot specify an ending location with the "reverse" flag. For videodiscs, "scan" applies only to CAV format.
scan Plays as fast as possible without disabling video (although audio might be disabled). For videodiscs, "scan" applies only to CAV format.
slow Plays slowly. To determine the exact speed on a videodisc player, use the "speed" flag of the status command. To specify the speed more precisely, use the "speed" flag of this command. For videodiscs, "slow" applies only to CAV format.
speed integer Plays a videodisc at the specified speed, in frames per second. This flag applies only to CAV discs.
to position Specifies an ending position for the playback. If the "to" flag is not specified, playback stops at the end of the content. For cdaudio devices, if the "to" position is greater than the end position of the disc, the driver returns an error. For videodisc devices, the default positions are in frames for CAV discs and in hours, minutes, and seconds for CLV discs.
window Specifies that playing should use the window associated with the device instance. This is the default setting.

lpszFlags

Can be "wait", "notify", or both. For digital-video and VCR devices, "test" can also be specified. For more information about these flags, see The Wait, Notify, and Test Flags.

Return Value

Returns zero if successful or an error otherwise.

Remarks

Before issuing commands that use position values, you should set the desired time format by using the set command. This command begins playing at the current speed, as set with the set "speed" command. The direction is reverse if the "reverse" flag is specified, or if the "to" flag is specified as a value less than the "from" flag. If the "from" flag is not specified, playback begins at the current position. The "to" and "reverse" flags cannot be used together.

Examples

The following command plays the "mysound" device from position 1000 through position 2000, sending a notification message when the playback completes.

play mysound from 1000 to 2000 notify

Requirements

Requirement Value
Minimum supported client
Windows 2000 Professional [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]

See also

MCI

MCI Command Strings

cue

set