FMX.PlayAudioFile Sample
This sample demonstrates how to include an audio file for playback in your iOS or Android application.
Contents
Location
You can find the PlayAudioFile sample project at:
- Start | Programs | Embarcadero RAD Studio Berlin | Samples and then navigate to:
Object Pascal\Mobile Snippets\PlayAudioFile
CPP\Mobile Snippets\PlayAudioFile
- Subversion Repository:
Description
The PlayAudioFile sample demonstrates how to include an audio file for playback on iOS and Android devices. The sample uses the nonvisual TMediaPlayer component for media file playback.
How to Use the Sample
- Navigate to one of the locations given above and open:
- Delphi: AccessCameraApp.dproj.
- C++: AccessCamera.cbproj.
- Select the target platform, iOS and Android supported.
- Press F9 or choose Run > Run.
- Interact with the sample.
- Click the play button to reproduce the audio file.
- Click the stop button to stop the reproduction of the audio file.
Files
File in Delphi | File in C++ | Contains |
---|---|---|
PlayAudioFile.dproj |
PlayAudioFile.cbproj |
The project itself. |
PlayAudioFile.fmx |
PlayAudioFile.fmx |
The main form where the components are located. |
PlayAudioFile.pas |
PlayAudioPCH.h, PlayAudio.cpp |
Used to define and implement the sample. |
soundsample.mp3 |
soundsample.mp3 |
The audio file. |
Classes
TAudioPlayBackForm is the main form that represents the main window of the sample. It contains the following components:
- A TMediaPlayer object.
- A ToolBar object with:
- Two TSpeedButton objects.
- A TLabel object.
Implementation
- The sample uses GetDocumentsPath to obtain the path to the directory where user documents are stored.
- The sample uses TMediaPlayer component for easy access to media files.
- The sample uses TSpeedButton to implement two push-buttons for playing and stoping the reproduction of the audio file.
When you run the aplication, the sample shows a ToolBar with two TSpeedButton objects with the stylelookup set to stoptoolbuttonbordered and playtoolbuttonbordered. When you click the play button, the sample uses GetDocumentsPath to obtain the media file, and TMediaPlayer.Play to reproduce it. When you click on the stop button, the sample uses TMediaPlayer.Stop to stop the reproduction of the media file.
Uses
See Also
Samples
- RTL Media Player sample
- FireMonkey Media Player HD sample
- FireMonkey Music Player sample
- FireMonkey Audio Rec-Play sample