tchvu3 / capacitor-voice-recorder

Capacitor plugin for voice recording
MIT License
75 stars 61 forks source link

Questions regarding the plugin #12

Closed lucasmrl closed 3 years ago

lucasmrl commented 3 years ago

@tchvu3 thanks for your amazing work here!

I'm about to start a simple journal app where I can record an entry and later on add some more information to that recording. A few questions:

Thank you!

tchvu3 commented 3 years ago

Hey friends. i'm happy you like this plugin. Regarding your question, as you can see in the snipped below from the android impl:

    private void setRecorderOutputFile() throws IOException {
        File outputDir = context.getCacheDir();
        outputFile = File.createTempFile("voice_record_temp", ".aac", outputDir);
        outputFile.deleteOnExit();
        mediaRecorder.setOutputFile(outputFile.getAbsolutePath());
    }

I output the recording to the cache directory on the phone and mark it for delete. this means that the file will be removed as soon as the java process is shutdown (this is a precaution). Plus, notice that in the stopRecording method I also manually delete the recording file: mediaRecorder.deleteOutputFile();

which means all I return is the base64 string that represent the recording while the file that holds the recording is long gone. you can of course just take this base64 string and save it to the file system using the appropriate "Filesystem" plugin