FMX.StreamingMedia Sample
This sample demonstrates how to stream audio and video files.
Contents
Location
You can find the StreamingMedia project at:
- Start | Programs | Embarcadero RAD Studio Athens | Samples and then navigate to either of the following folders:
Object Pascal\Multi-Device Samples\Media\StreamingMedia
CPP\Multi-Device Samples\Media\StreamingMedia
- Subversion Repository:
- You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
Description
The StreamingMedia sample application shows how to stream audio and video content. The sample uses the TMediaPlayer component for media file playback.
How to Use the Sample
- Navigate to one of the locations given above and open:
- Delphi: StreamingMedia.dproj.
- C++: StreamingMedia_Cpp.cbproj.
- Select the target platform.
- Press F9 or choose Run > Run.
- Interact with the sample.
- Video tab:
- Select one item from the list.
- Click the play button to reproduce the video file.
- Click the stop button to stop the reproduction of the video file.
- Music tab:
- Introduce a web site.
- Click Scan to start searching for audio content.
- Select one item from the list.
- Click the play button to reproduce the audio file.
- Note: If the media file is not supported by the OS, a error message could appear.
- Video tab:
Files
File in Delphi | File in C++ | Contains |
---|---|---|
StreamingMedia.dproj |
StreamingMedia_Cpp.cbproj |
The project itself. |
Unit1.fmx |
Unit1.fmx |
The main form where the components are located. |
Unit1.pas |
Unit1.h, Unit1.cpp |
Used to define and implement the sample. |
StreamingMedia.dpr |
StreamingMedia_Cpp.cpp |
Source of the project file that manages the running of the application. |
Implementation
- The application defines the following event handlers:
Button1Click
: The OnClick event stops or pauses the TMediaPlayer. It checks the active TabIndex of the TTabControl and plays the selected item of the TListBox.Button2Click
: The OnClick event callsIdHTTP.TIdHTTP.Get
for an HTTP get request that permints obtaining the data from the URL defined at the TEdit control. It callsScanText
with the obtained data as an argument to get the audio items and list them in the TListBox.Button3Click
: The OnClick event stops or pauses the TMediaPlayer.FormCreate
: The OnCreate event of the TForm populates the TListBox of the Video tab with video files from the URLhttp://techslides.com/demos/sample/<FileName.extension>
.
- The application defines the following methods:
ScanText
gets as an argument the data obtained fromIdHTTP.TIdHTTP.Get
. The method callsAddItem
to populate the TListBox with the audio files from the URL.GetTagValue
provides the URL to the videos from the raw data obtained inIdHTTP.TIdHTTP.Get
. The URL is the item that usesScanText
to populate the list of available audio files.IsItemCorrect
is used inScanText
to check ig the item is an mp3 audio file.AddItem
adds the items to the TListBox.
- The application defines the following significant controls:
Uses
See Also
Samples
- RTL Media Player sample
- FireMonkey Media Player HD sample
- FireMonkey Music Player sample
- FireMonkey Audio Rec-Play sample