Example of Adding Audio or Video Clips (VCL Only)

From RAD Studio
Jump to: navigation, search

Go Up to Adding Audio or Video Clips to an Application

This example runs an AVI video clip of a multimedia advertisement.

To run this example, create a new project and save the Unit1.pas file to FrmAd.pas and save the Project1.dpr file to DelphiAd.dpr. Then:

  1. Double-click the media player icon on the System category of the Tool palette.
  2. Using the Object Inspector, set the Name property of the media player to VideoPlayer1.
  3. Select its DeviceType property and choose dtAVIVideo from the drop-down list.
  4. Select its FileName property, click the ellipsis (...) button, locate and choose an AVI file. Click Open in the Open dialog.
  5. Set its AutoOpen property to True and its Visible property to False.
  6. Double-click the Animate icon from the Win32 category of the Tool palette. Set its AutoSize property to False, its Height property to 175 and Width property to 200. Click and drag the animation control to the top left corner of the form.
  7. Click the media player to bring back focus to it. Select its Display property and choose Animate1 from the drop down list.
  8. Click the form to bring focus to it and select its Name property and enter Delphi_Ad. Now resize the form to the size of the animation control.
  9. Double-click the form's OnActivate event and write the following code to run the AVI video when the form is in focus:
  10. Choose Run > Run to execute the AVI video.

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

See Also