This article contains information about you can use Appmethod and Object Pascal for audio recording in a multi-device (Windows, OSX, iOS and Android) project using the Mobile Snippet AudioRecPlay sample (C:\Users\Public\Documents\Appmethod\13.0\Demos\Object Pascal\Mobile Snippets\AudioRecPlay).

You can record to several audio file formats depending on the device you have. AudioRecPlay does work on my Samsung Galaxy S4. I modified the code to set the filename to .mp3 instead of .3gp and it worked. Appmethod supports several video and audio formats on different platforms.
The following audio and video formats are supported using the TMediaCodecManager’s RegisterMediaCodecClass.
iOS:
TMediaCodecManager.RegisterMediaCodecClass('.mov', SVMOVFiles, TMediaType.Video, TAVMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.m4v', SVM4VFiles, TMediaType.Video, TAVMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.mp4', SVMP4Files, TMediaType.Video, TAVMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.mp3', SVMP3Files, TMediaType.Audio, TAVMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.caf', SVCAFFiles, TMediaType.Audio, TAVMediaCodec);
Android:
TMediaCodecManager.RegisterMediaCodecClass('.mov', SVMOVFiles, TMediaType.Video, TAndroidVideoCodec);
TMediaCodecManager.RegisterMediaCodecClass('.m4v', SVM4VFiles, TMediaType.Video, TAndroidVideoCodec);
TMediaCodecManager.RegisterMediaCodecClass('.mp4', SVMP4Files, TMediaType.Video, TAndroidVideoCodec);
TMediaCodecManager.RegisterMediaCodecClass('.mp3', SVMP3Files, TMediaType.Audio, TAndroidMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.caf', SVCAFFiles, TMediaType.Audio, TAndroidMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.3gp', SV3GPFiles, TMediaType.Audio, TAndroidMediaCodec);
Windows:
TMediaCodecManager.RegisterMediaCodecClass('.avi', SVAviFiles, TMediaType.Video, TWindowsMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.wmv', SVWMVFiles, TMediaType.Video, TWindowsMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.mp4', SVMP4Files, TMediaType.Video, TWindowsMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.m4v', SVMP4Files, TMediaType.Video, TWindowsMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.mov', SVMOVFiles, TMediaType.Video, TWindowsMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.wma', SVWMAFiles, TMediaType.Audio, TWindowsMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.mp3', SVMP3Files, TMediaType.Audio, TWindowsMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.wav', SVWAVFiles, TMediaType.Audio, TWindowsMediaCodec);
Mac OS X:
TMediaCodecManager.RegisterMediaCodecClass('.mov', SVMOVFiles, TMediaType.Video, TQTMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.m4v', SVMP4Files, TMediaType.Video, TQTMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.mp4', SVMP4Files, TMediaType.Video, TQTMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.avi', SVAviFiles, TMediaType.Video, TQTMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.wav', SVWAVFiles, TMediaType.Audio, TQTMediaCodec);
TMediaCodecManager.RegisterMediaCodecClass('.mp3', SVMP3Files, TMediaType.Audio, TQTMediaCodec);
Suggested audio file formats
The documentation(http://docwiki.appmethod.com/appmethod/1.13/topics/en/Audio_Recording) recommends that you save and use audio media files in the following formats:
- .wav on Windows
- .caf on iOS and Mac
- .3GP on Android
You also can play other types of media files, such as MP3 files. AudioRecPlay Mobile Code SnippetHere is the sample code that I modified in the AudioRecPlay mobile code snippet to record to mp3 – a format available on all platforms and as far as I know on all of the most popular Operating Systems. I tested the program on my Samsung Galaxy S4 and it recorded and played back successfully.
procedure TAudioRecPlayForm.btnStartPlayClick(Sender: TObject);
begin
btnStopRecClick(Self);
FMediaPlayer := TMediaPlayer.Create(Self);
{$IFDEF ANDROID}
// FMediaPlayer.FileName := TPath.GetHomePath + '/test.3GP';
FMediaPlayer.FileName := TPath.GetHomePath + '/test.mp3';
{$endif}
{$IFDEF IOS}
// FMediaPlayer.FileName := TPath.GetHomePath + '/Documents/test.caf';
FMediaPlayer.FileName := TPath.GetHomePath + '/Documents/test.mp3';
{$endif}
if Assigned(FMediaPlayer) then
if Assigned(FMediaPlayer.Media) then
FMediaPlayer.Play;
end;
procedure TAudioRecPlayForm.btnStartRecClick(Sender: TObject);
begin
btnStopPlayClick(Self);
{ get the microphone device }
FMicrophone := TCaptureDeviceManager.Current.DefaultAudioCaptureDevice;
if Assigned(FMicrophone) then
begin
{$IFDEF ANDROID}
// FMicrophone.FileName := TPath.GetHomePath + '/test.3GP';
FMicrophone.FileName := TPath.GetHomePath + '/test.mp3';
{$endif}
{$IFDEF IOS}
// FMicrophone.FileName := TPath.GetHomePath + '/Documents/test.caf';
FMicrophone.FileName := TPath.GetHomePath + '/Documents/test.mp3';
{$endif}
try
FMicrophone.StartCapture;
imgOn.Visible := True;
except
imgOn.Visible := False;
ShowMessage('StartCapture:Operation not supported by this device');
end;
end else
ShowMessage('No microphone is available.');
end;
You can also add your own formats that you want supported via the manager classes for audio and video, of course for these you will need to make sure that the codecs are available on the platforms.