2

I am trying to voice record 5 sec after a button is click. Is there a ways to do it ? For example, when user clock on a button it starts recording 5 secs and stops. Whatever gets recorded should be saved in mp3 file. The file name is hard coded.

Thanks

Xarels
  • 37
  • 7

1 Answers1

2

Refer to Android Audio Capture documentation for recording audio and playing sound back.

This is possibly a duplicate of How to Record Voice in android?

saeed foroughi
  • 1,662
  • 1
  • 13
  • 25
Alex
  • 206
  • 2
  • 10
  • 1
    Hi, it is not a duplicate although question is similar. I am mainly interested in a way to start recording for 5 sec and stop after that time. Save a file with an audio recorded. Etc. It is for my case study to check users awareness. I tried to loop it with for loop and stop it when when I == 5 but it did not worked. I was wondering of a way to start recording for 5 sec only. Without the need to click stop button etc. – Xarels Feb 14 '20 at 17:14
  • 2
    @Xarels I believe there is a Timer class or you could create your own. You simply just run the stop function after 5 seconds. The voice recording if done correctly should run until you call the stop function. In pseudo it would be startRecording(); Timer.Run(5000ms,stopRecording()); – Alex Feb 15 '20 at 00:32
  • 2
    @Xarels If you want to post a minimal verifiable example I can try to assist with your specific code. – Alex Feb 15 '20 at 00:35
  • Thank you. This pretty much answers my question. I – Xarels Feb 15 '20 at 22:41
  • Thanks i will do so tomorrow – Xarels Feb 16 '20 at 01:05