[Lazarus] Play sound in Lazarus 3.4?

Kostas Michalopoulos badsector at runtimeterror.com
Fri Nov 22 20:56:31 CET 2024


On 11/22/24 8:12 PM, Timothy Groves via lazarus wrote:
> I cannot find an acceptable answer to this anywhere online.  I've been 
> looking for an hour.
> 
> How do I play back a wav file?
> 
> Preferably, how do I store a bunch of them, play them back as needed 
> when called?
> 

On Windows you could use PlaySound. There is no cross-platform high 
level audio support in FPC or Lazarus (fcl-sound could be a candidate 
but all it provides right now is reading WAV files, there is no support 
for audio playback).

You can use OpenAL as a cross-platform audio library. The OpenAL 
bindings for Free Pascal have an example of loading and playing WAV 
files directly in packages/examples/wavopenal.pas.




More information about the lazarus mailing list