hello,
I am working in windows 10.
if you are working in windows, you can use the MCI (Media Control Interface). The Media Control Interface is a high-level API developed by Microsoft and IBM for controlling multimedia peripherals connected to a Microsoft Windows.
With it, you can play mp3, wav etc.. files. You have only to add the
MMSystem unit in your
uses. No need thirdpart units or packages or dlls.
In attachment a small Lazarus project to discover how to use MCI in Lazarus.
With this project :
- You can play the sound files which are in a ListBox.
- You can stop playing sound.
- You can loop playing all the sounds.
- You can load sound files from an opendialog window.
In this project, i use a notify procedure. The
MM_MCINOTIFY message notifies an application that an MCI device has completed an operation.
You can have a long delay time between the open command and the play command. To avoid this, open your sound file for example in the form create. Then you can play the sound of the file loaded. If you want to play more than one time this file instead of close and reopen the file, use the command
seek audio to start (to "rewind" the sound if
audio is your alias)
Friendly, J.P