Pergunta

I am trying to read "Bit rate" property of audio files. I know how to get the value but the way I am doing it I don't think is the most efficient.

Shell shell = new Shell32.Shell();
Folder objFolder = shell.NameSpace(path);
for (int i = 0; i < short.MaxValue; i++)
{
    string property = objFolder.GetDetailsOf(null, i);
    if (String.IsNullOrEmpty(property))
        break;
    if (property.Equals("Bit rate"))
    {
        index = i;
        break;
    }
}
FolderItem item = objFolder.ParseName(fileName);
string bitRateValue = objFolder.GetDetailsOf(item, index);

My concern is that for loop which I need to get the index of "Bit rate", so for all my tests returned me index 28, therefore I started to wonder if Bit rate can be found always at index 28? If not then is there any better way to find out at which index Bit rate is located?

Foi útil?

Solução

After a bit of research and help from other members, I got what I was looking for. This answer is for those who may land here searching for bitrate property of audio files.

First of all, if we use Shell then bitrate property will always be found at index 28. However it is upto Shell object if it contains any value for that property. as Shell's main purpose is not to read the audio files, so we should not be relying on it to read any audio file properties.

This Thread explains what we need to do to read the .wav's bitrate.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top