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.
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.
To set Volume call SetVolume() method
float volume =1f; audioRecorderPlugin.SetVolume(volume);
To Start Audio Recording just call StartAudioRecord() method
To Stop Audio Recording call StopAudioRecord() method
To Load the recorded Audio call LoadRecordedAudio() method
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
To Pause recorded Audio just call PauseAudioRecordPlay() method
When you are done using Audio Recorder you must release the Audio Recorder Service on Android by calling ReleaseAudio() method
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 firstname.lastname@example.org or you can comment below.