Home > Blockchain >  how to save realtime recording file to google drive
how to save realtime recording file to google drive

Time:02-21

I'm developing android app that recording voice and upload to google drive.

The simple solution is to save recording file to the local cache directory and then upload that file to google drive using google drive api.

But I want to upload recording file to google drive directly not saving into local cache directory.

Like this

recorder = MediaRecorder()
            .apply {
                setAudioSource(MediaRecorder.AudioSource.MIC)
                setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP) 
               setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB) 
                setOutputFile('googleDrivePath')
                prepare()
            }
        recorder?.start()

But I don't know how to get google drive path

CodePudding user response:

According to the docs:

Set the output file name using setOutputFile(). You must specify a file descriptor that represents an actual file.

As I also can’t find a way to retrieve the file as a byte array on a MediaRecorder in the javadoc, or redirect it to an OutputStream, I think I can assume it is impossible to not write it to a file.

  • Related