First add a reference to the Microsoft.DirectX.AudioVideoPlayback library.
When the user clicks the Play/Stop button, the program checks the button's caption to see whether it should start or stop playing. To start playing, it creates a new Audio object, passing its constructor the name of the file to play. It calls the object's Play method, records the time, and enables the tmrPosition Timer control.
When the Timer's event fires, the program displays the elapsed time and the audio file's total time.
To stop playing, the program calls the Audio object's Stop method. It then calls its Dispose method to free system resources.
|