Show: Delphi C++
Example of Adding Audio or Video Clips (VCL Only)
From RAD Studio XE2
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:
- Double-click the media player icon on the System category of the Tool palette.
- Using the Object Inspector, set the Name property of the media player to VideoPlayer1.
- Select its DeviceType property and choose dtAVIVideo from the drop-down list.
- Select its FileName property, click the ellipsis (...) button, locate and choose an AVI file. Click Open in the Open dialog.
- Set its AutoOpen property to True and its Visible property to False.
- 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.
- Click the media player to bring back focus to it. Select its Display property and choose Animate1 from the drop down list.
- 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.
- Double-click the form's OnActivate event and write the following code to run the AVI video when the form is in focus:
- 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
usesclause (Delphi) or
#includeShellAnimations (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.