You can find the VideoPlayback sample project at:
- Start | Programs | Embarcadero RAD Studio Sydney | Samples and navigate to:
Object Pascal\Mobile Snippets\VideoPlayback
- Subversion Repository:
- You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
- Selecting different videos.
- Playing and stopping the video.
- Moving the video forward, backward, to the beginning, and to the end.
- Using a TRectangle as parent for the TMediaPlayerControl to hide and show the video as well as to move up and down the position of the video.
How to Use the Sample
- Navigate to the location given above and open:
- Delphi: VideoPlayerTest.dproj.
- Select your target platform (iOS or Android supported).
F9or choose Run > Run.
- Select one of the files to play from the file list.
- Use the Play, Stop, To The Start, 10 Sec Backward, 10 Sec Forward, and To The End buttons to interact with the video.
- Use the Moving Parent Up, Moving Parent Down, and Change Parents Visible buttons to interact with the TRectangle that contains the TMediaPlayerControl.
|File in Delphi||Contains|
The project itself.
The main form where the components are located.
Used to define and implement the sample.
The video files to play in the sample.
- The sample uses the TMediaPlayer component to access the media files.
- TMediaPlayerControl is used to display the video media file.
- The TMediaPlayerControl.MediaPlayer property is used to link the media player control with the media player to access the video files.
- TMediaPlayer.Play is used to play the video.
- TMediaPlayer.Stop is used to stop the video.
- TMediaPlayer.CurrentTime is used to know, as well as to specify the current position of the video.
- TMediaPlayer.Duration is used to know the total duration time of the video.
The Rectangle Used as Parent
- TRectangle is the rectangle that serves as parent for the TMediaPlayerControl component.
- TRectangle.Position with TPosition type is used to get and update the X and Y positions of the rectangle.
- The TRectangle.Visible property is used to hide and show the rectangle when the Change Parent Visible button is clicked.
- Since the rectangle is the parent of the media player control, changing the position as well as hiding and showing the rectangle also moves, hides or shows the video.
Selecting the Video
- When a list box item is clicked, the sample sets the TMediaPlayer.FileName property to the file that corresponds with the item that was clicked; combining the path to the file, according to the platform, and the list box item text.
- The TTimer is used to repeat the following actions after a given interval, that specifies the time interval between the TTimer.OnTimer events:
On From Creation
When the form is created the sample:
- Gets the appropriate paths to access the video files:
Platformproperty of TOSVersion is used to know the platform the sample is running on. Depending on the platform, a different path to the video is used.
- Fills the TListBox with the available video files.
- Sets the volume:
- MediaPlayer (Delphi)
- MediaPlayer (C++)
- RTL.MediaPlayer Sample
- TMediaPlayerEject (Delphi)
- TMediaPlayerEject (C++)
- VCL.VideoPlayer Sample