It does not save an audio recording to a file

I have created the function to save and record and stop the recording, but it does not work, it creates the file but does not store the recording, the file weighs 0B.
I use a xiaomi mobile with android 10.

I have the following code

  startRecord() {
    if ('ios')) {
      this.fileName = 'record' + new Date().getDate() + new Date().getMonth() + new Date().getFullYear() + new Date().getHours() + new Date().getMinutes() + new Date().getSeconds() + '.mp3';
      this.filePath = this.file.documentsDirectory.replace(/file:\/\//g, '') + this.fileName; =;
    } else if ('android')) {
      this.fileName = 'record'+new Date().getDate()+new Date().getMonth()+new Date().getFullYear()+new Date().getHours()+new Date().getMinutes()+new Date().getSeconds()+'.mp3';
      this.filePath = this.file.externalDataDirectory.replace(/file:\/\//g, '') + this.fileName; =;;

    this.recording = true;
  stopRecord() {
      (base64: any) => {
        let dataAudio = base64.substr(34, base64.length);
        let x = base64.substr(13, base64.length);
        x = "data:audio/mpeg;base64" + x;
      }, err=>{
        console.log("base64 err", err);
    this.recording = false;

Additional Information


   Ionic CLI                     : 5.4.16 (/usr/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 5.3.5
   @angular-devkit/build-angular : 0.1000.8
   @angular-devkit/schematics    : 10.0.8
   @angular/cli                  : 10.0.8
   @ionic/angular-toolkit        : 2.3.3


   Cordova CLI       : 10.0.0
   Cordova Platforms : android 9.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 18 other plugins)


   cordova-res                          : 0.15.1
   native-run (update available: 1.2.2) : 0.2.9


   Android SDK Tools : 26.1.1 (/root/Android/Sdk)
   NodeJS            : v12.19.0 (/usr/bin/node)
   npm               : 6.14.8
   OS                : Linux 4.15

You speak frequently of “it”. Who is “it”? What library are you using to capture audio? Why did you choose it? What other options did you consider and why did you reject them?

I use the media ( @ionic-native/media) and file(@ionic-native/file) plugin to create an mp3 file and in that file with media I record the audio but the recording is not saved.
I have not considered any more, but if I have tried so that the other plugins such as media-capture, open the cell phone recording app which is not my goal, but to record the audio without leaving the app, as a reference record audios as WhatsApp

How about using browser capabilities such as documented in this article?