Search code examples
c#winformsaudiosoundplayer

Playing sounds: accessing length and position


I'm using the System.Media.SoundPlayer for playing sounds in C# desktop application passing the sound location.

Everything works fine. But how can I access the total file length (in milliseconds) and the player position?

Theses properties are accessible?


Solution

  • The System.Media.SoundPlayer class is not suitable for providing this information.

    http://msdn.microsoft.com/en-us/library/system.media.soundplayer.aspx

    The SoundPlayer class provides a simple interface for loading and playing a .wav file. The SoundPlayer class supports loading a .wav file from a file path, a URL, a Stream that contains a .wav file, or an embedded resource that contains a .wav file.

    You may want to look at some other libraries for audio playback, suggested here: C# Audio Library