Android Ultimate Plugin tutorial part 7 – Audio Recorder

Hello Guys, it’s me again and now i will show  you on how to use our Audio Recorder from our Android Ultimate Plugin. let’s start!

Permission needed for your Android Manifest  if you forgot to add this your app will not work or it will just stop , so please add this to prevent any problems.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />

First we need to get the instance of AudiodRecorderPlugin

private AudioRecorderPlugin audioRecorderPlugin = AudioRecorderPlugin.GetInstance();

Next we need to SetDebug method to 0 because i don’t want to see those toast Debug messages but if you want you just need to pass 1 on it.

audioRecorderPlugin.SetDebug(0);

Then we need to prepare our audio file name and output path

string filename = "testAudioRecord";
string outputPath = Application.persistentDataPath;

After that we can now initialize our AudioRecorderPlugin by calling InitAudioRecorder() method and passing filename and out path on it. the third parameter is only tells if you wanted to use persistent path and in our case we want it.

audioRecorderPlugin.InitAudioRecorder(outputPath,filename,true);

To set Volume call SetVolume() method

float volume =1f;
audioRecorderPlugin.SetVolume(volume);

To Start Audio Recording just call StartAudioRecord() method

audioRecorderPlugin.StartAudioRecord();

To Stop Audio Recording call StopAudioRecord() method

audioRecorderPlugin.StopAudioRecord();

To Load the recorded Audio call LoadRecordedAudio() method

audioRecorderPlugin.LoadRecordedAudio();

To play Recorded Audio just call  PlayAudioRecord() method and pass the pitch that you wanted

float pitch = 1f;
audioRecorderPlugin.PlayAudioRecord(pitch);

To Stop playing recorded Audio just call StopAudioRecordPlay() method

audioRecorderPlugin.StopAudioRecordPlay();

To Pause recorded Audio just call PauseAudioRecordPlay() method

audioRecorderPlugin.PauseAudioRecordPlay();

When you are done using Audio Recorder you must release the Audio Recorder Service on Android by calling ReleaseAudio() method

audioRecorderPlugin.ReleaseAudio();

Note: without doing this Audio Recorder will not be available on other applications, when this happened you need to restart your Android Device to make Audio Recorder Service available again. so  please release it, let it go.

And  there you have it!

Thanks for reading our tutorial and Happy coding 🙂

And as usual if you encounter any problems or errors or bugs or it’s not working at all please email us at gigadrillgames@gmail.com or you can comment below.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.