Dismiss Notice

REGISTRATION IS AFTER ADMIN ACTIVATION

DONATIONS WITH PAYPAL CLICK TO BUTTON

3 MONTHS VIP - 10$; 6 MONTHS VIP - 20$; 1 YEAR VIP - 30$; 2 YEARS VIP - 50$; GOLD USER FOR LIFE VIP - 150$

DONATIONS WITH Bitcoin Address:3NRs3CK3fhXifrNYxHEZKpETDd9vNLMsMD

Dismiss Notice
The registration is approved by the Administrator. It takes about 1 day to approve your registration
Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

Audio recording on multiple devices for Windows, OSX, iOS and Android

Discussion in 'Delphi Android And IOS' started by N0body, Jul 29, 2014.

  1. N0body
    Online

    N0bodyN0body is a Verified Member DelphiFan Administrator Staff Member DF Staff

    [​IMG]

    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:


    Code:
      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:


    Code:
      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:


    Code:
      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:


    Code:
      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.


    Code:
    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;
    


    Code:
    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.

    Thanks for David I
     
  2. edney.barros@gmail.com
    Offline

    edney.barros@gmail.com DF Junior

  3. bioman
    Offline

    bioman DF Junior

    RE:

    thanks
     
  4. psniper
    Offline

    psniper DF Member

    RE:

    thanks
     
  5. necko
    Offline

    necko DF Member

    Thanks
     
  6. youan
    Online

    youan Guest

    OK......
     
  7. sturgut
    Offline

    sturgut DF Junior

    thanks
     
  8. jeng
    Offline

    jeng DF Member

    thanks
     

Share This Page

Laws
Our website, law, laws, copyright and aims to be respectful of individual rights. Our site, as defined in the law of 5651 serves as a provider of space. According to the law, contrary to the law of site management has no obligation to monitor content. Therefore, our site has adopted the principle of fit and remove. Works are subject to copyright laws and is shared in a manner that violated their legal rights, or professional associations, rights holders who, adsdelphi@gmail.com I can reach us at e-mail address. Complaints considered to be infringing on the examination of the content will be removed from our site.
Donate Help To Us and Be VIP
DONATIONS WITH PAYPAL CLICK TO BUTTON
6 MONTHS VIP - 20$; 1 YEAR VIP - 30$; 2 YEARS VIP - 50$; GOLD USER FOR LIFE VIP - 150$
Social Block