Home   Index   About
Ultimate Pack


Custom Search
Playing a Device

The play (MCI_PLAY) command starts playing a device. Without any flags, this command starts playing from the current position and plays until the command is interrupted or until the end of the media or file is reached. After playback, the current position is at the end of the media. You can also use the seek (MCI_SEEK) command to change the current position.

Most devices that support the play command also support the "from" (MCI_FROM) and "to" (MCI_TO) flags. These flags indicate the position at which the device should start and stop playing. For example, the following command plays a CD audio disc from the beginning of the first track:

mciSendString("play cdaudio from 0", lpszReturnString,
lstrlen(lpszReturnString), NULL);

Some device types extend this command to exploit the capabilities of a particular device. For example, the play command for the videodisc device type includes the "fast" (MCI_VD_PLAY_FAST) , "slow" (MCI_VD_PLAY_SLOW), and "scan" (MCI_VD_PLAY_SCAN) flags.

Note The units assigned to the position value depend on the time format used by the device. Each device has a default time format, but you should specify the time format by using the set (MCI_SET) command before issuing any commands that use position values.

Playing an AVI File

Video files in Windows are made up of at least two interleaved data streams: a video (pictorial) stream and an audio stream. You can easily play these audio-video interleaved (AVI) files by using MCI commands. The following sections discuss playing AVI files.

Setting Up an MCIAVI Playback Window

Your application can specify the following options to define the playback window for playing an AVI file:

  • Use the MCIAVI driver's default pop-up window.

  • Specify a parent window and window style that the MCIAVI driver can use to create the playback window.

  • Specify a playback window for the MCIAVI driver to use for playback.

  • Play the AVI file on a full-screen display.

If your application does not specify any window options, the MCIAVI driver creates a default window for playing the sequence. The driver creates this playback window for the open (MCI_OPEN) command, but it does not display the window until your application sends a command to either display the window or play the file. This default playback window is a pop-up window with a sizing border, title bar, a thick frame, a window menu, and a Minimize button.

Your application can also specify a parent window handle and a window style when it issues the open command. In this case, the MCIAVI driver creates a window based on these specifications instead of the default pop-up window. Your application can specify any window style available for the CreateWindow function. Styles that require a parent window, such as WS_CHILD, should include a parent window handle.

Your application can also create its own window and supply the handle to the MCIAVI driver by using the window (MCI_WINDOW) command. The MCIAVI driver uses this window instead of creating one of its own.

When the MCIAVI driver creates the playback window or obtains a window handle from your application, it does not display the window until your application either plays the sequence or sends a command to display the window. Your application can use the window command to display the window without playing the sequence. For example, the following command displays the window using the command-string interface:

mciSendString("window movie state show", lpszReturnString,
lstrlen(lpszReturnString), NULL);

In this example, "movie" is an alias for the digital-video device.

Your application can also play an AVI file full-screen. To play full-screen, modify the play (MCI_PLAY) command with the "fullscreen" (MCI_MCIAVI_PLAY_FULLSCREEN) flag. When your application uses this flag, the MCIAVI driver uses a 320- by 240-pixel full-screen format for playing the sequence. For example, the following command plays the opened file full-screen (using "movie" as an alias):

mciSendString("play movie fullscreen", lpszReturnString,
lstrlen(lpszReturnString), NULL);

Changing the Playback State for an AVI file

Your application can use the seek (MCI_SEEK) command to move the current position to the beginning, the end, or an arbitrary position in an AVI file. There are two seek modes for the MCIAVI driver: exact and inexact. Your application can change the seek mode by using the set (MCI_SET) command. When you use set "seek exactly on", the MCIAVI driver seeks exactly to the frame your application specifies. This might cause a delay if the file is temporally compressed and your application does not specify a key frame. When you use set "seek exactly off", the MCIAVI driver seeks to the nearest key frame in a temporally compressed file.

Some MCI commands let your application alter the playback of an AVI file in other ways. For example, an AVI file, by default, plays at its normal speed, but your application can increase or decrease this speed by using the "speed" flag with the set command. For AVI files, a speed value of 1000 is typical. Thus, to play a movie at half its typical speed, your application can use the command set "movie speed 500"; alternatively, it can use set "movie speed 2000" to play the sequence at twice its normal speed.

The setaudio (MCI_SETAUDIO) command lets your application control the audio portion of an AVI file. Your application can mute audio during playback or, in the case of multiple audio stream files, select the audio stream that is played.

The MCIAVI driver has a dialog box to control some of its playback options. Some of the options available to the user include selecting window-oriented or full-screen playback, selecting the seek mode, and zooming the image. Your application can have MCIAVI display this dialog box by using the configure (MCI_CONFIGURE) command.

Stream Handlers

The data in an AVI file is treated as a series of streams. An AVI file typically contains an audio and video stream, and there might also be a custom stream that contains text or some other custom data. The MCIAVI driver can use different handlers for these data streams. For more information about custom AVI files, see Custom File and Stream Handlers.


Last news from Greatis Software

Nostalgia .Net     Nostalgia .Net     .Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes.  More »

Recommended software for developers

Ultimate Pack for Delphi and C++ Builder     Ultimate Pack     Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price.  More »

Form Designer .Net     Form Designer .Net     Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro!  More »

Print Suite .Net     Print Suite .Net     Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available  More »

Gradient Controls .Net     Gradient Controls .Net     Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available  More »

iGrid     Greatis iGrid     iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors.  More »


All the contacts and projects

Dmitry Vasiliev (just.dmitry)

Related Links

Software for Visual Studio .NET developers
Software for Delphi and C++ Builder developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference
Win32 Multimedia Programmer's Reference
OLE Programmer's Reference
Microsoft Windows Pen API Programmer's Reference
Microsoft Windows Sockets 2 Reference
Microsoft Windows Telephony API (TAPI) Programmer's Reference
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008-2012 Free Tech Secrets ;) greatis just4fun network just4fun