tags:

views:

329

answers:

4

I've got a C# program that's supposed to play audio files. I've figured out how to play any sound file for which Windows has a codec by using DirectShow, but now I want to properly fill in the file type filter box on the Open dialog. I'd like to automatically list any file format for which Windows has a codec. If some random user installs a codec for an obscure format, its associated extension(s) and file type description(s) need to show up in the list.

Any ideas?

+2  A: 

If I remember correctly, a codec does not know which file types, i.e. file extensions, it supports, since a codec takes some stream as input and not actually a file. So if what you want is to display the file extensions of the supported audio file formats, you'll most likely be out of luck unless you have a extensive list of file extensions and associated codecs, but even then you'll get problems with container formats and all that.

For example, my Windows Media Player happily plays m4b files, but does not know anything about them. I had to manually associate it with the file type.

OregonGhost
A: 

You could look in the Windows Registry for all file types with a content type of "audio/*". Specifically, look at all of the keys under HKCR/Software/*/Content Type.

Adam Rosenfield
A: 

Just Use mm codec apis. Never use registry.

A: 

You can use the NAudio open source .NET audio library to enumerate all the ACM codecs installed on your system. Take a look at the AcmDriver class.

Mark Heath