Use the MMC (multimedia control). The control's Command property makes the control do things. The control supports
the following commands:
|Open||Opens the MP3 file|
|Play||Plays the open MP3 file|
|Stop||Stops playing the MP3 file|
|Close||Closes the MP3 file|
This program's cmdPlay button opens the indicated file and plays it. It then changes the button's Caption to Stop.
When the user clicks the button again, the program stops playing the file.
The MMC's StatusUpdate event fires regularly so the program can display status. In this case, the program displays the
control's position in the file.
The MMC's Done event fires when the file is done playing, either because the control reached the end of the file
or because the user clicked the Stop button and the program set the MMC's Command property to Stop. The event handler
closes the MP3 file and resets the button's caption.
The form's Unload event handler closes the MP3 file in case it is still open.