Ionic media iOS 11 - record audio issue when reusing same file / media object


#1

Hi everyone,

I’ve got a problem with update to iOS 11.
I want to record an audio file. So what I do is :

  • Create a new file using Ionic Native File
  • Create a new media object based on the file using Ionic Native Media
  • Start recording for 5 seconds
  • Stop recording
  • Start recording (using same media object) for 9 seconds
  • Stop recording

Unfortunately, the second record length can’t be over the first record length. When I play the second one, it cuts at 5 seconds.

It worked pretty well on iOS 10 but starting in iOS 11 it just doesn’t accept a longer record.

Below is my code :

import { Media, MediaObject } from '@ionic-native/media';
// Things

let audioFileDirectory = this.file.tempDirectory;
        let audioFilename = 'recording.wav';
        this.audioFilepath = audioFileDirectory + audioFilename;
        this.file.createFile(audioFileDirectory, audioFilename, true).then(() => {
          this.audioFileMedia = this.media.create(audioFileDirectory.replace(/^file:\/\//, '') + audioFilename);
        });
this.audioFileMedia.startRecord();
this.audioFileMedia.stopRecord();

My environment is :

cli packages: (/usr/local/lib/node_modules)

    @ionic/cli-utils  : 1.19.0
    ionic (Ionic CLI) : 3.19.0

global packages:

    cordova (Cordova CLI) : 8.0.0 

local packages:

    @ionic/app-scripts : 3.0.1
    Cordova Platforms  : ios 4.5.4
    Ionic Framework    : ionic-angular 3.8.0

System:

    Android SDK Tools : 26.0.2
    ios-deploy        : 1.9.2 
    ios-sim           : 5.0.13 
    Node              : v8.2.1
    npm               : 5.4.2 
    OS                : macOS High Sierra
    Xcode             : Xcode 9.2 Build version 9C40b

Version of Cordova is :

    <plugin name="cordova-plugin-file" spec="^5.0.0" />
    <plugin name="cordova-plugin-media" spec="^5.0.0" />

Thank you !


#2

Hi, did you resolve this?

Thanks