1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram

  5. Delphifan Magazine
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

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 AdminDF, Jul 29, 2014.

  1. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan 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
     
    XoreDev likes this.
  2. edney.barros@gmail.com
    Offline

    [email protected] 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