Adding Audio or Video Clips to an Application

From RAD Studio
Jump to: navigation, search

Go Up to Working with Multimedia


With the media player component, you can add audio and/or video clips to your application. The media player opens a media device and plays, stops, pauses and records the audio and/or video clips used by the media device. The media device may be hardware or software.

Delphi VCL Note: If you are using Windows 7, you need to add ShellAnimations to your uses clause so that the CommonAVIs (such as Vcl.ComCtrls.TAnimateParams.CommonAVI) work correctly. This addition links AVI resources similar to the ones in Windows XP.

C++ VCL Note: If you are using Windows 7, you need to add ShellAnimations to your #include clause so that the CommonAVIs (such as Vcl.ComCtrls.TAnimateParams.CommonAVI) work correctly. This addition links AVI resources similar to the ones in Windows XP.

To add an audio and/or video clip to an application:

  1. Double-click the media player icon on the System category of the Tool palette. This automatically puts a media player control on the form.
  2. Using the Object Inspector, select the Name property and enter a new name for your media player control. You use this name when you call the media player control. (Follow the standard rules for naming Delphi identifiers.) Always work directly with the Object Inspector when setting design-time properties and creating event handlers.
  3. Select the DeviceType property and choose the appropriate device type to open using the AutoOpen property or the Open method. (If DeviceType is dtAutoSelect the device type is selected based on the file extension of the media file specified by the FileName property.) For more information on device types and their functions, see the table below.
  4. If the device stores its media in a file, specify the name of the media file using the FileName property:
    1. Select the FileName property, click the ellipsis (...) button, and choose a media file from any available local or network directories.
    2. Click Open in the Open dialog.
    Otherwise, at run time, insert the media on which the audio or video is stored (disk, cassette, and so on).
  5. Set the AutoOpen property to True. This way the media player automatically opens the specified device when the form containing the media player control is created at run time. If AutoOpen is False, the device must be opened with a call to the Open method.
  6. Set the AutoEnable property to True to automatically enable or disable the media player buttons as required at run time; or, double-click the EnabledButtons property to set each button to True or False depending on which ones you want to enable or disable.
    The multimedia device is played, paused, stopped, and so on when the user clicks the corresponding button on the media player component. The device can also be controlled by the TMediaPlayer methods that correspond to the buttons (Play, Pause, Stop, Next, Previous, and so on).
  7. Position the media player control bar on the form by either clicking and dragging it to the appropriate place on the form or by selecting the Align property and choosing the appropriate align position from the drop down list.
    If you want the media player to be invisible at run time, set the Visible property to False and control the device by calling the appropriate methods ( Play, Pause, Stop, Next, Previous, Step, Back, StartRecording, Eject).
  8. Make any other changes to the Vcl.MPlayer.TMediaPlayer control settings. For example, if the media requires a display window, set the Display property to the control that displays the media. If the device uses multiple tracks, set the Tracks property to the desired track.

Multimedia device types and their functions :

Device Type Software/Hardware used Plays Uses Tracks   Uses a Display Window

dtAVIVideo

AVI Video Player for Windows

AVI Video files

No

Yes

dtCDAudio

CD Audio Player for Windows or a CD Audio Player

CD Audio Disks

Yes

No

dtDAT

Digital Audio Tape Player

Digital Audio Tapes

Yes

No

dtDigitalVideo

Digital Video Player for Windows

AVI, MPG, MOV files

No

Yes

dtMMMovie

MM Movie Player

MM film

No

Yes

dtOverlay

Overlay device

Analog Video

No

Yes

dtScanner

Image Scanner

N/A for Play (scans images on Record)

No

No

dtSequencer

MIDI Sequencer for Windows

MIDI files

Yes

No

dtVCR

Video Cassette Recorder

Video Cassettes

No

Yes

dtWaveAudio

Wave Audio Player for Windows

WAV files

No

No



For more information on using the media player control, see the topic Example of Adding Audio or Video Clips (VCL Only).

See Also