I need to play the开发者_运维知识库 audio files like mp3 and .wav using c#. I don't want to use the com dll's and I need some functionality like to set the current time and end time of the file to play. etc.
Need some sample exmaples for the same.
To play audio using C# at some point the managed code will need to call into unmanaged APIs. NAudio provides wrappers for four different Windows audio playback APIs. WaveOut would be the most appropriate choice for you, since it is not COM based.
To decode MP3, you have a choice of using the codecs that come with Windows or trying to find a fully managed MP3 decoder. NAudio provides interop wrappers for two different Windows MP3 decoders - the Fraunhofer ACM codec that comes with Windows XP and above and the DirectX Media Object decoder that comes with Windows Vista and above. If you want a fully managed MP3 decoder, you can try NLayer which is a port I made of JavaLayer to .NET, although its public API doesn't currently allow it to slot neatly into an NAudio app.
精彩评论