FMX.PlayAudioFile Sample

From RAD Studio Code Examples
Jump to: navigation, search

This sample demonstrates how to include an audio file for playback in your iOS or Android application.

Location

You can find the PlayAudioFile sample project at:

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

  1. Navigate to one of the locations given above and open:
    • Delphi: AccessCameraApp.dproj.
    • C++: AccessCamera.cbproj.
  2. Select the target platform, iOS and Android supported.
  3. Press F9 or choose Run > Run.
  4. 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:

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