I'm not quite sure where to start on this one so wanted to ask for some help.
In a Blazor web app, I am downloading an MP3 audio file from S3 without any problems. It's kept in memory only at the moment via a MemoryStream (for further processing).
I now need to figure out the duration of the audio eg. 90 seconds or whatever.
Is it possible to do this via the MemoryStream ? Or do I need to download and write the file to disk, then inspect it ? Also what library can I use to inspect the MP3 file so as to determine the duration of the audio ?
Here's the relevant piece of code which is downloading (from S3) the file:
MemoryStream ms = null;
GetObjectRequest getObjectRequest = new GetObjectRequest
{
BucketName = bucketName,
Key = fileName
};
using (var response = await s3Client.GetObjectAsync(getObjectRequest))
{
if (response.HttpStatusCode == HttpStatusCode.OK)
{
using (ms = new MemoryStream())
{
await response.ResponseStream.CopyToAsync(ms);
}
}
}
return ms;