Amplituda icon indicating copy to clipboard operation
Amplituda copied to clipboard

Process audio from Uri feature

Open lincollincol opened this issue 3 years ago • 3 comments

lincollincol avatar Feb 19 '22 16:02 lincollincol

@niklasdahlheimer Currently, It's not possible to process uri with Amplituda directly, but I'm working on it. This code will help you to convert uri to an internal file that can be processed with Amplituda. This approach also solves problems such as obtaining a path or access to a file

So, the reason Amplituda doesn't work with uri, is that I need to get the context to process uri. I don't really like this approach, but it seems there are no other options. Currently, I'm looking for the opportunity to work with uri in NDK, but there are no results yet

lincollincol avatar Feb 22 '22 11:02 lincollincol

Thanks for you response! The mentioned workaround does it's job but a big disadvantage is, that the cacheDir will unnecessarily grow and grow and, like I already mentioned, the performance will suffer from cloning all audio files (especially for big wave files).

I don't like passing the context around either, but in this case I think it's reasonable as all other API functions which process URIs also do that. Besides that it would be up to the user if one uses processAudio(File: file) or processAudio(Context: context, Uri: uri).

You could simply adapt the way MediaExtractor is handling URIs: setDataSource(Context context, Uri uri, Map<String, String> headers) is just a wrapper around setDataSource(String path, Map<String, String> headers): Android Source code

niklasdahlheimer avatar Feb 23 '22 09:02 niklasdahlheimer

Hi @niklasdahlheimer, how to processAudio with url from API has headers.

khiemdnt avatar Dec 05 '23 02:12 khiemdnt