NateRickard / Plugin.AudioRecorder

Audio Recorder plugin for Xamarin and Windows
MIT License
164 stars 68 forks source link

Added in-memory audio stream and audio level event #48

Open EverOddish opened 4 years ago

EverOddish commented 4 years ago

I plan to implement an app using Plugin.AudioRecorder that will use a continuous stream of audio. I won't necessarily need to store the audio in files on disk, so I've added a MemoryStream option to Plugin.AudioRecorder. I have not changed the default behaviour of storing audio to a file, so the changes should not affect any existing users of Plugin.AudioRecorder.

I would also like my app to display a visual representation of the current audio level, so I've added an event that is invoked when the audio level is updated.

I would greatly appreciate if these changes could be added to the next release of Plugin.AudioRecorder. Thank you!

Haarmees commented 3 years ago

@NateRickard is it possible to merge and release this PR? For security reasons, we can't store audio as a file on the device. It would be nice if we could use this (awesome) library.

NateRickard commented 3 years ago

Thanks for the ping on this. I'm definitely interested in getting it merged in, but I'll have to recreate my build environment to generate the NuGet - I no longer have VS 2017 and the VS plugin I was using to properly generate the package is no longer maintained/exists for 2019. I'll try to revisit this shortly, stay tuned.

Haarmees commented 3 years ago

Thanks for the response. I looked a bit at this PR and discovered this solution may not work for me either. I need to make long recordings, which I want to send to a server. So a memory stream may not be the right choice. I decided to implement my own solution, where you can give a stream to the StartRecording function: var audioRecordTask = await recorder.StartRecording (myStream); It will write the data to the provided stream. If no stream is provided, it falls back to writing a file.

I will make a PR for this functionality by the end of the week, if that's ok. It should also cover this scenario, by giving a memorystream to the function.

EverOddish commented 3 years ago

I can't remember if I had to make further changes to my pull request to get it working, but I can check when I have a chance. Let me know if there are any issues.