squti/Android-Wave-Recorder

Add `changeFile` feature

Closed this issue · 8 comments

If I have to do two recordings, I'm forced to created a new instance of WaveRecorder since the filePath is private in WaveRecorder():

class WaveRecorder(private var filePath: String)

@squti I'm thinking the changeFile(newFilePath: String) function should change the filePath when the isRecording = false and throw an IllegalStateException if otherwise.

squti commented

In what situations do you need change the file path without creating a new instance? Because it is safer to create a new instance for a new file.

Mainly in a recording app, a user may finish recording and then desire to record another audio file.
If all the recording and renaming is done within the same fragment, there is no need to create another instance when one instance can be recycled.
An example would be MediaPlayer's API.

mediaPlayer.reset()
mediaPlayer.setDataSource(filePath)
mediaPlayer.prepare()
mediaPlayer.start()
squti commented

I will add this in the next version. Thanks for your suggestion.

Could I try working on this issue then if the code is clean enough, you can merge it

squti commented

Sure. I've assigned it to you.

squti commented

Feature has been added to the project. Thanks for your contribution.

Hi, @squti @andre-max can we add file path on direct startRecording function? Because I would like to fix issue of scope storage.

I have designed a function like below. Check it.

image

Sounds like a great idea. Do the necessary changes then pull for review. Scoped storage has been a tough topic I'm yet to grasp and I would like to read some scoped storage code.