Analysis of the use of multimedia components in Delphi

Source: Internet
Author: User
Tags rewind

Delphi is the United States Borland company launched a very good software development platform. With its powerful development function, it is the most outmanoeuvred in many development environments, especially in the development of multimedia software. On the Delphi Component Board System page, there is a component called MediaPlayer, which is the core of multimedia software production, the following will be MediaPlayer

The use of the component is detailed.

The MediaPlayer component is primarily used to control MCI (mediacontrolinterface) devices, which provide a series of buttons for controlling multimedia devices such as CD-ROMs, MIDI, VCRs, and so on, which can be hardware or software. The buttons are left to right by default: Play (playback), Pause (pause), stop (stop), next (next track), Prev (previous track), Step (stepping), back (backward), record (recording), Eject (Eject media) and so on 9 function buttons. In a user-developed program, a multimedia device can achieve these 9 features in two ways, by placing the MediaPlayer component on a form, clicking the corresponding button while the program is running, and by using the corresponding method of the button to implement these features.

The above 9 buttons allow for a selection of views and features that can be implemented by changing the +visiblebuttons and +enabledbuttons properties in the property page of the Objectinspector (Object monitor), and the consumer only needs to double-click this property to make the "+" becomes "-", and assigns the value of the corresponding child property to true in the new Child property table below

/false can be.

The MediaPlayer component has many properties and methods (method). A property is set in the Objectinspector (Object monitor) at design time, and it does not have to be encoded by the person who develops the program (of course, it can be set in the code), and the method is the process and function that the program developer must use in the program code. Under normal circumstances, Delphi sets the commonly used properties to the default values that are sufficient for general development, but some key attribute values must be given by the user themselves. Some of the most important attributes and their use are shown in the following table:

MediaPlayer Component Method In addition to the 9-button method mentioned earlier, Delphi also provides some important methods for MediaPlayer components, such as open, save, rewind, resume, pauseonly, and close. Details of their use are as follows:

1. Open method:

The Open method opens a multimedia device. Before calling this method, you must ensure that the correct multimedia device type is set in the DeviceType (device type) attribute of the MediaPlayer component.

The following code is used to play CD music when the program starts running.

  procedureTForm1.FormCreat(Sender:Tobject);
  begin
  with MediaPlayer1 do
  begin
  DeviceType:=dtCDAudio;
  Visible:=False;
  open;
  play;
  end;
  end;

2. Save method:

The Save method is used to save the currently loaded media content to the file specified by the FileName property. The Save method is ignored for devices that cannot be accessed with media, such as Videodiscs.

3. Rewind method:

The rewind method is used to set the current position to the beginning of the media, which is the position of the value saved with the Start property.

Sample the following code uses a MediaPlayer component and a button component. When the button button is clicked, the Wavaudio media returns to the beginning and plays.

  procedureTForm1.FormClick(Sender:Tobject);
  begin
  MediaPlayer1.DeviceType:=dtWavAudio;
  MediaPlayer1.fileName:=′c:windowschimes.wav′;
  Button1.Caption:=′返回并开始播放′;
  Button1.width:=125;
  end;
  procedureTForm1.Button1Click(Sender:Tobject);
  begin
  MediaPlayer1.Rewind;
  MediaPlayer1.play;
  end;

4. Resume Method:

The Resume method is used to restart the playback or recording of the currently paused multimedia device.

5. Close method:

The Close method closes the currently open multimedia device.

6. Pauseonly Method:

The Pauseonly method is used only to pause a multimedia device, and if the device is paused, the device remains paused when the Pauseonly method is invoked.

These are the most commonly used properties and methods for MediaPlayer components. If you like, you can use these properties and methods in your application to achieve multimedia audio and video effects.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.